[5ebff60] | 1 | /********************************************************************\ |
---|
[b7d3cc34] | 2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
| 3 | * * |
---|
[0e788f5] | 4 | * Copyright 2002-2012 Wilmer van der Gaast and others * |
---|
[b7d3cc34] | 5 | \********************************************************************/ |
---|
| 6 | |
---|
| 7 | /* Main file (Unix specific part) */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | This program is free software; you can redistribute it and/or modify |
---|
| 11 | it under the terms of the GNU General Public License as published by |
---|
| 12 | the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | (at your option) any later version. |
---|
| 14 | |
---|
| 15 | This program is distributed in the hope that it will be useful, |
---|
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | GNU General Public License for more details. |
---|
| 19 | |
---|
| 20 | You should have received a copy of the GNU General Public License with |
---|
| 21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
[6f10697] | 22 | if not, write to the Free Software Foundation, Inc., 51 Franklin St., |
---|
| 23 | Fifth Floor, Boston, MA 02110-1301 USA |
---|
[b7d3cc34] | 24 | */ |
---|
| 25 | |
---|
| 26 | #include "bitlbee.h" |
---|
[7c9db24] | 27 | |
---|
| 28 | #include "arc.h" |
---|
| 29 | #include "base64.h" |
---|
[b7d3cc34] | 30 | #include "commands.h" |
---|
| 31 | #include "protocols/nogaim.h" |
---|
| 32 | #include "help.h" |
---|
[54879ab] | 33 | #include "ipc.h" |
---|
[7c9db24] | 34 | #include "md5.h" |
---|
| 35 | #include "misc.h" |
---|
[b7d3cc34] | 36 | #include <signal.h> |
---|
| 37 | #include <unistd.h> |
---|
| 38 | #include <sys/time.h> |
---|
[d25f6fc] | 39 | #include <sys/wait.h> |
---|
[aaf92a9] | 40 | #include <pwd.h> |
---|
[badd148] | 41 | #include <locale.h> |
---|
[ad46e4d] | 42 | #include <grp.h> |
---|
[b7d3cc34] | 43 | |
---|
[d150a9d] | 44 | #if defined(OTR_BI) || defined(OTR_PI) |
---|
| 45 | #include "otr.h" |
---|
| 46 | #endif |
---|
| 47 | |
---|
[0d2cd10] | 48 | #ifdef HAVE_BACKTRACE |
---|
| 49 | #include <execinfo.h> |
---|
| 50 | #endif |
---|
| 51 | |
---|
[5ebff60] | 52 | global_t global; /* Against global namespace pollution */ |
---|
[b7d3cc34] | 53 | |
---|
[2e99039] | 54 | static struct { |
---|
| 55 | int fd[2]; |
---|
| 56 | int tag; |
---|
| 57 | } shutdown_pipe = {{-1 , -1}, 0}; |
---|
| 58 | |
---|
[5ebff60] | 59 | static void sighandler_shutdown(int signal); |
---|
| 60 | static void sighandler_crash(int signal); |
---|
[b7d3cc34] | 61 | |
---|
[5ebff60] | 62 | static int crypt_main(int argc, char *argv[]); |
---|
[7c9db24] | 63 | |
---|
[5ebff60] | 64 | int main(int argc, char *argv[]) |
---|
[b7d3cc34] | 65 | { |
---|
| 66 | int i = 0; |
---|
[58bc4e6] | 67 | char *old_cwd = NULL; |
---|
[b7d3cc34] | 68 | struct sigaction sig, old; |
---|
[0d2cd10] | 69 | #ifdef HAVE_BACKTRACE |
---|
| 70 | void *unused[1]; |
---|
| 71 | #endif |
---|
[5ebff60] | 72 | |
---|
[badd148] | 73 | /* Required to make iconv to ASCII//TRANSLIT work. This makes BitlBee |
---|
| 74 | system-locale-sensitive. :-( */ |
---|
[5ebff60] | 75 | setlocale(LC_CTYPE, ""); |
---|
| 76 | |
---|
| 77 | if (argc > 1 && strcmp(argv[1], "-x") == 0) { |
---|
| 78 | return crypt_main(argc, argv); |
---|
| 79 | } |
---|
| 80 | |
---|
[d25f6fc] | 81 | log_init(); |
---|
[10b3683] | 82 | /* Catch early errors */ |
---|
| 83 | log_link(LOGLVL_ERROR, LOGOUTPUT_CONSOLE); |
---|
| 84 | log_link(LOGLVL_WARNING, LOGOUTPUT_CONSOLE); |
---|
[5ebff60] | 85 | |
---|
| 86 | global.conf_file = g_strdup(CONF_FILE_DEF); |
---|
| 87 | global.conf = conf_load(argc, argv); |
---|
| 88 | if (global.conf == NULL) { |
---|
| 89 | return(1); |
---|
| 90 | } |
---|
| 91 | |
---|
[72d48b6] | 92 | if (global.conf->runmode == RUNMODE_INETD) { |
---|
| 93 | log_link(LOGLVL_ERROR, LOGOUTPUT_IRC); |
---|
| 94 | log_link(LOGLVL_WARNING, LOGOUTPUT_IRC); |
---|
| 95 | } else { |
---|
| 96 | log_link(LOGLVL_ERROR, LOGOUTPUT_CONSOLE); |
---|
| 97 | log_link(LOGLVL_WARNING, LOGOUTPUT_CONSOLE); |
---|
| 98 | } |
---|
| 99 | |
---|
[60c1a4e] | 100 | b_main_init(); |
---|
[5ebff60] | 101 | |
---|
[3fc6c32] | 102 | /* libpurple doesn't like fork()s after initializing itself, so if |
---|
| 103 | we use it, do this init a little later (in case we're running in |
---|
| 104 | ForkDaemon mode). */ |
---|
| 105 | #ifndef WITH_PURPLE |
---|
| 106 | nogaim_init(); |
---|
| 107 | #endif |
---|
[5ebff60] | 108 | |
---|
[858ea01] | 109 | #ifdef OTR_BI |
---|
[5ebff60] | 110 | otr_init(); |
---|
[858ea01] | 111 | #endif |
---|
[5ebff60] | 112 | |
---|
| 113 | global.helpfile = g_strdup(HELP_FILE); |
---|
| 114 | if (help_init(&global.help, global.helpfile) == NULL) { |
---|
| 115 | log_message(LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE); |
---|
[5674207] | 116 | } |
---|
[b7d3cc34] | 117 | |
---|
[5ebff60] | 118 | global.storage = storage_init(global.conf->primary_storage, global.conf->migrate_storage); |
---|
| 119 | if (global.storage == NULL) { |
---|
| 120 | log_message(LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage); |
---|
| 121 | return(1); |
---|
[8e6ecfe] | 122 | } |
---|
| 123 | |
---|
| 124 | global.auth = auth_init(global.conf->auth_backend); |
---|
| 125 | if (global.conf->auth_backend && global.auth == NULL) { |
---|
| 126 | log_message(LOGLVL_ERROR, "Unable to load authentication backend '%s'", global.conf->auth_backend); |
---|
| 127 | return(1); |
---|
[b7d3cc34] | 128 | } |
---|
[5ebff60] | 129 | |
---|
| 130 | if (global.conf->runmode == RUNMODE_INETD) { |
---|
| 131 | i = bitlbee_inetd_init(); |
---|
| 132 | log_message(LOGLVL_INFO, "%s %s starting in inetd mode.", PACKAGE, BITLBEE_VERSION); |
---|
| 133 | |
---|
| 134 | } else if (global.conf->runmode == RUNMODE_DAEMON) { |
---|
[b7d3cc34] | 135 | i = bitlbee_daemon_init(); |
---|
[5ebff60] | 136 | log_message(LOGLVL_INFO, "%s %s starting in daemon mode.", PACKAGE, BITLBEE_VERSION); |
---|
| 137 | } else if (global.conf->runmode == RUNMODE_FORKDAEMON) { |
---|
[54879ab] | 138 | /* In case the operator requests a restart, we need this. */ |
---|
[5ebff60] | 139 | old_cwd = g_malloc(256); |
---|
| 140 | if (getcwd(old_cwd, 255) == NULL) { |
---|
| 141 | log_message(LOGLVL_WARNING, "Could not save current directory: %s", strerror(errno)); |
---|
| 142 | g_free(old_cwd); |
---|
[54879ab] | 143 | old_cwd = NULL; |
---|
| 144 | } |
---|
[5ebff60] | 145 | |
---|
[d25f6fc] | 146 | i = bitlbee_daemon_init(); |
---|
[5ebff60] | 147 | log_message(LOGLVL_INFO, "%s %s starting in forking daemon mode.", PACKAGE, BITLBEE_VERSION); |
---|
| 148 | } |
---|
| 149 | if (i != 0) { |
---|
| 150 | return(i); |
---|
[d25f6fc] | 151 | } |
---|
[5ebff60] | 152 | |
---|
| 153 | if ((global.conf->user && *global.conf->user) && |
---|
| 154 | (global.conf->runmode == RUNMODE_DAEMON || |
---|
| 155 | global.conf->runmode == RUNMODE_FORKDAEMON) && |
---|
| 156 | (!getuid() || !geteuid())) { |
---|
[aaf92a9] | 157 | struct passwd *pw = NULL; |
---|
[5ebff60] | 158 | pw = getpwnam(global.conf->user); |
---|
[0483e1e] | 159 | if (!pw) { |
---|
| 160 | log_message(LOGLVL_ERROR, "Failed to look up user %s.", global.conf->user); |
---|
[30491ca] | 161 | return(EXIT_FAILURE); |
---|
[0483e1e] | 162 | |
---|
| 163 | } else if (initgroups(global.conf->user, pw->pw_gid) != 0) { |
---|
| 164 | log_message(LOGLVL_ERROR, "initgroups: %s.", strerror(errno)); |
---|
[fb774da] | 165 | return(EXIT_FAILURE); |
---|
[0483e1e] | 166 | |
---|
| 167 | } else if (setgid(pw->pw_gid) != 0) { |
---|
| 168 | log_message(LOGLVL_ERROR, "setgid(%d): %s.", pw->pw_gid, strerror(errno)); |
---|
[fb774da] | 169 | return(EXIT_FAILURE); |
---|
[0483e1e] | 170 | |
---|
| 171 | } else if (setuid(pw->pw_uid) != 0) { |
---|
| 172 | log_message(LOGLVL_ERROR, "setuid(%d): %s.", pw->pw_uid, strerror(errno)); |
---|
[fb774da] | 173 | return(EXIT_FAILURE); |
---|
[ad46e4d] | 174 | } |
---|
[aaf92a9] | 175 | } |
---|
[5ebff60] | 176 | |
---|
[b7d3cc34] | 177 | /* Catch some signals to tell the user what's happening before quitting */ |
---|
[5ebff60] | 178 | memset(&sig, 0, sizeof(sig)); |
---|
[7233f68] | 179 | sig.sa_handler = SIG_IGN; |
---|
[5ebff60] | 180 | sigaction(SIGCHLD, &sig, &old); |
---|
| 181 | sigaction(SIGPIPE, &sig, &old); |
---|
[b7d3cc34] | 182 | sig.sa_flags = SA_RESETHAND; |
---|
[7233f68] | 183 | sig.sa_handler = sighandler_crash; |
---|
[5ebff60] | 184 | sigaction(SIGSEGV, &sig, &old); |
---|
[7233f68] | 185 | |
---|
[2e99039] | 186 | sighandler_shutdown_setup(); |
---|
| 187 | |
---|
| 188 | sig.sa_handler = sighandler_shutdown; |
---|
| 189 | sigaction(SIGINT, &sig, &old); |
---|
| 190 | sigaction(SIGTERM, &sig, &old); |
---|
[5ebff60] | 191 | |
---|
[0d2cd10] | 192 | #ifdef HAVE_BACKTRACE |
---|
| 193 | /* As per the backtrace(3) man page, call this outside of the signal |
---|
| 194 | * handler once to ensure any dynamic libraries are loaded in an |
---|
| 195 | * async-signal-safe environment to prevent deadlocks */ |
---|
| 196 | backtrace(unused, 1); |
---|
| 197 | #endif |
---|
| 198 | |
---|
[5ebff60] | 199 | if (!getuid() || !geteuid()) { |
---|
| 200 | log_message(LOGLVL_WARNING, "BitlBee is running with root privileges. Why?"); |
---|
| 201 | } |
---|
| 202 | |
---|
[ba9edaa] | 203 | b_main_run(); |
---|
[5ebff60] | 204 | |
---|
[0fbda193] | 205 | /* Mainly good for restarting, to make sure we close the help.txt fd. */ |
---|
[5ebff60] | 206 | help_free(&global.help); |
---|
| 207 | |
---|
| 208 | if (global.restart) { |
---|
[54879ab] | 209 | char *fn = ipc_master_save_state(); |
---|
[daae10f] | 210 | char *env; |
---|
[5ebff60] | 211 | |
---|
| 212 | env = g_strdup_printf("_BITLBEE_RESTART_STATE=%s", fn); |
---|
| 213 | putenv(env); |
---|
| 214 | g_free(fn); |
---|
[daae10f] | 215 | /* Looks like env should *not* be freed here as putenv |
---|
| 216 | doesn't make a copy. Odd. */ |
---|
[5ebff60] | 217 | |
---|
| 218 | i = chdir(old_cwd); |
---|
| 219 | close(global.listen_socket); |
---|
| 220 | |
---|
| 221 | if (execv(argv[0], argv) == -1) { |
---|
[cd63d58] | 222 | /* Apparently the execve() failed, so let's just |
---|
| 223 | jump back into our own/current main(). */ |
---|
| 224 | /* Need more cleanup code to make this work. */ |
---|
| 225 | return 1; /* main( argc, argv ); */ |
---|
[5ebff60] | 226 | } |
---|
[54879ab] | 227 | } |
---|
[5ebff60] | 228 | |
---|
| 229 | return(0); |
---|
[b7d3cc34] | 230 | } |
---|
| 231 | |
---|
[5ebff60] | 232 | static int crypt_main(int argc, char *argv[]) |
---|
[7c9db24] | 233 | { |
---|
| 234 | int pass_len; |
---|
| 235 | unsigned char *pass_cr, *pass_cl; |
---|
[5ebff60] | 236 | |
---|
| 237 | if (argc < 4 || (strcmp(argv[2], "hash") != 0 && |
---|
| 238 | strcmp(argv[2], "unhash") != 0 && argc < 5)) { |
---|
| 239 | printf("Supported:\n" |
---|
| 240 | " %s -x enc <key> <cleartext password>\n" |
---|
| 241 | " %s -x dec <key> <encrypted password>\n" |
---|
| 242 | " %s -x hash <cleartext password>\n" |
---|
| 243 | " %s -x unhash <hashed password>\n" |
---|
| 244 | " %s -x chkhash <hashed password> <cleartext password>\n", |
---|
| 245 | argv[0], argv[0], argv[0], argv[0], argv[0]); |
---|
| 246 | } else if (strcmp(argv[2], "enc") == 0) { |
---|
[5535a47] | 247 | char *encoded; |
---|
| 248 | |
---|
| 249 | pass_len = arc_encode(argv[4], strlen(argv[4]), &pass_cr, argv[3], 12); |
---|
| 250 | |
---|
| 251 | encoded = base64_encode(pass_cr, pass_len); |
---|
| 252 | printf("%s\n", encoded); |
---|
| 253 | g_free(encoded); |
---|
| 254 | g_free(pass_cr); |
---|
[5ebff60] | 255 | } else if (strcmp(argv[2], "dec") == 0) { |
---|
[5535a47] | 256 | pass_len = base64_decode(argv[4], &pass_cr); |
---|
[5ebff60] | 257 | arc_decode(pass_cr, pass_len, (char **) &pass_cl, argv[3]); |
---|
| 258 | printf("%s\n", pass_cl); |
---|
[5535a47] | 259 | |
---|
| 260 | g_free(pass_cr); |
---|
| 261 | g_free(pass_cl); |
---|
[5ebff60] | 262 | } else if (strcmp(argv[2], "hash") == 0) { |
---|
[7c9db24] | 263 | md5_byte_t pass_md5[21]; |
---|
| 264 | md5_state_t md5_state; |
---|
[5535a47] | 265 | char *encoded; |
---|
[5ebff60] | 266 | |
---|
| 267 | random_bytes(pass_md5 + 16, 5); |
---|
| 268 | md5_init(&md5_state); |
---|
| 269 | md5_append(&md5_state, (md5_byte_t *) argv[3], strlen(argv[3])); |
---|
| 270 | md5_append(&md5_state, pass_md5 + 16, 5); /* Add the salt. */ |
---|
| 271 | md5_finish(&md5_state, pass_md5); |
---|
| 272 | |
---|
[5535a47] | 273 | encoded = base64_encode(pass_md5, 21); |
---|
| 274 | printf("%s\n", encoded); |
---|
| 275 | g_free(encoded); |
---|
[5ebff60] | 276 | } else if (strcmp(argv[2], "unhash") == 0) { |
---|
| 277 | printf("Hash %s submitted to a massive Beowulf cluster of\n" |
---|
| 278 | "overclocked 486s. Expect your answer next year somewhere around this time. :-)\n", argv[3]); |
---|
| 279 | } else if (strcmp(argv[2], "chkhash") == 0) { |
---|
| 280 | char *hash = strncmp(argv[3], "md5:", 4) == 0 ? argv[3] + 4 : argv[3]; |
---|
| 281 | int st = md5_verify_password(argv[4], hash); |
---|
| 282 | |
---|
| 283 | printf("Hash %s given password.\n", st == 0 ? "matches" : "does not match"); |
---|
| 284 | |
---|
[7c9db24] | 285 | return st; |
---|
| 286 | } |
---|
[5ebff60] | 287 | |
---|
[7c9db24] | 288 | return 0; |
---|
| 289 | } |
---|
| 290 | |
---|
[2e99039] | 291 | /* Set up a pipe for SIGTERM/SIGINT so the actual signal handler doesn't do anything unsafe */ |
---|
| 292 | void sighandler_shutdown_setup() |
---|
| 293 | { |
---|
| 294 | if (shutdown_pipe.fd[0] != -1) { |
---|
| 295 | /* called again from a forked process, clean up to avoid propagating the signal */ |
---|
| 296 | b_event_remove(shutdown_pipe.tag); |
---|
| 297 | close(shutdown_pipe.fd[0]); |
---|
| 298 | close(shutdown_pipe.fd[1]); |
---|
| 299 | } |
---|
| 300 | |
---|
| 301 | if (pipe(shutdown_pipe.fd) == 0) { |
---|
| 302 | shutdown_pipe.tag = b_input_add(shutdown_pipe.fd[0], B_EV_IO_READ, bitlbee_shutdown, NULL); |
---|
| 303 | } |
---|
| 304 | } |
---|
| 305 | |
---|
[7233f68] | 306 | /* Signal handler for SIGTERM and SIGINT */ |
---|
[5ebff60] | 307 | static void sighandler_shutdown(int signal) |
---|
[b7d3cc34] | 308 | { |
---|
[0483e1e] | 309 | int unused G_GNUC_UNUSED; |
---|
[7233f68] | 310 | /* Write a single null byte to the pipe, just to send a message to the main loop. |
---|
| 311 | * This gets handled by bitlbee_shutdown (the b_input_add callback for this pipe) */ |
---|
[0483e1e] | 312 | unused = write(shutdown_pipe.fd[1], "", 1); |
---|
[7233f68] | 313 | } |
---|
| 314 | |
---|
[0d2cd10] | 315 | #ifdef HAVE_BACKTRACE |
---|
| 316 | /* Writes a backtrace to (usually) /var/lib/bitlbee/crash.log |
---|
| 317 | * No malloc allowed means not a lot can be written to that file */ |
---|
| 318 | static void sighandler_crash_backtrace() |
---|
| 319 | { |
---|
| 320 | int fd, mapsfd; |
---|
| 321 | int size; |
---|
| 322 | void *trace[128]; |
---|
| 323 | const char message[] = "## " PACKAGE " crashed\n" |
---|
| 324 | "## Version: " BITLBEE_VERSION "\n" |
---|
| 325 | "## Configure args: " BITLBEE_CONFIGURE_ARGS "\n" |
---|
| 326 | "##\n" |
---|
| 327 | "## Backtrace:\n\n"; |
---|
| 328 | const char message2[] = "\n" |
---|
| 329 | "## Hint: To get details on addresses use\n" |
---|
| 330 | "## addr2line -e <binary> <address>\n" |
---|
| 331 | "## or\n" |
---|
| 332 | "## gdb <binary> -ex 'l *<address>' -ex q\n" |
---|
| 333 | "## where <binary> is a filename from above and <address> is the part between (...)\n" |
---|
| 334 | "##\n\n"; |
---|
| 335 | const char message3[] = "\n## End of memory maps. See above for the backtrace\n\n"; |
---|
| 336 | |
---|
| 337 | fd = open(CRASHFILE, O_WRONLY | O_APPEND | O_CREAT, 0600); |
---|
| 338 | |
---|
| 339 | if (fd == -1 || write(fd, message, sizeof(message) - 1) == -1) { |
---|
| 340 | return; |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | size = backtrace(trace, 128); |
---|
| 344 | backtrace_symbols_fd(trace, size, fd); |
---|
| 345 | |
---|
| 346 | (void) write(fd, message2, sizeof(message2) - 1); |
---|
| 347 | |
---|
| 348 | /* a bit too linux-specific, so fail gracefully */ |
---|
| 349 | mapsfd = open("/proc/self/maps", O_RDONLY, 0); |
---|
| 350 | |
---|
| 351 | if (mapsfd != -1) { |
---|
| 352 | char buf[4096] = {0}; |
---|
| 353 | ssize_t bytes; |
---|
| 354 | |
---|
| 355 | while ((bytes = read(mapsfd, buf, sizeof(buf))) > 0) { |
---|
| 356 | (void) write(fd, buf, bytes); |
---|
| 357 | } |
---|
| 358 | (void) close(mapsfd); |
---|
| 359 | (void) write(fd, message3, sizeof(message3) - 1); |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | (void) close(fd); |
---|
| 363 | } |
---|
| 364 | #endif |
---|
| 365 | |
---|
[7233f68] | 366 | /* Signal handler for SIGSEGV |
---|
| 367 | * A desperate attempt to tell the user that everything is wrong in the world. |
---|
| 368 | * Avoids using irc_abort() because it has several unsafe calls to malloc */ |
---|
[5ebff60] | 369 | static void sighandler_crash(int signal) |
---|
[7233f68] | 370 | { |
---|
| 371 | GSList *l; |
---|
[0d2cd10] | 372 | const char message[] = "ERROR :BitlBee crashed! (SIGSEGV received)\r\n" |
---|
| 373 | #ifdef HAVE_BACKTRACE |
---|
| 374 | "ERROR :Writing backtrace to " CRASHFILE "\r\n" |
---|
| 375 | #endif |
---|
| 376 | "ERROR :This is a bug either in BitlBee or a plugin, ask us on IRC if unsure\r\n"; |
---|
[7233f68] | 377 | |
---|
[5ebff60] | 378 | for (l = irc_connection_list; l; l = l->next) { |
---|
[7233f68] | 379 | irc_t *irc = l->data; |
---|
[c467adc] | 380 | sock_make_blocking(irc->fd); |
---|
[e1e5bd6] | 381 | if (irc->sendbuffer) { |
---|
[c82e4ca] | 382 | (void) write(irc->fd, irc->sendbuffer->str, irc->sendbuffer->len); |
---|
[e1e5bd6] | 383 | } |
---|
[0d2cd10] | 384 | (void) write(irc->fd, message, sizeof(message) - 1); |
---|
[b7d3cc34] | 385 | } |
---|
[7233f68] | 386 | |
---|
[0d2cd10] | 387 | #ifdef HAVE_BACKTRACE |
---|
| 388 | sighandler_crash_backtrace(); |
---|
| 389 | #endif |
---|
| 390 | |
---|
[5ebff60] | 391 | raise(signal); |
---|
[b7d3cc34] | 392 | } |
---|
| 393 | |
---|
| 394 | double gettime() |
---|
| 395 | { |
---|
| 396 | struct timeval time[1]; |
---|
| 397 | |
---|
[5ebff60] | 398 | gettimeofday(time, 0); |
---|
| 399 | return((double) time->tv_sec + (double) time->tv_usec / 1000000); |
---|
[b7d3cc34] | 400 | } |
---|