Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

util_log.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: util_log.c,v 12.4 2005/10/12 17:47:17 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 
00015 #include <stdlib.h>
00016 #if TIME_WITH_SYS_TIME
00017 #include <sys/time.h>
00018 #include <time.h>
00019 #else
00020 #if HAVE_SYS_TIME_H
00021 #include <sys/time.h>
00022 #else
00023 #include <time.h>
00024 #endif
00025 #endif
00026 
00027 #include <string.h>
00028 #endif
00029 
00030 #include "db_int.h"
00031 
00032 /*
00033  * __db_util_logset --
00034  *      Log that we're running.
00035  *
00036  * PUBLIC: int __db_util_logset __P((const char *, char *));
00037  */
00038 int
00039 __db_util_logset(progname, fname)
00040         const char *progname;
00041         char *fname;
00042 {
00043         pid_t pid;
00044         db_threadid_t tid;
00045         FILE *fp;
00046         time_t now;
00047 
00048         if ((fp = fopen(fname, "w")) == NULL)
00049                 goto err;
00050 
00051         (void)time(&now);
00052 
00053         __os_id(NULL, &pid, &tid);
00054         fprintf(fp, "%s: %lu %s", progname, (u_long)pid, ctime(&now));
00055 
00056         if (fclose(fp) == EOF)
00057                 goto err;
00058 
00059         return (0);
00060 
00061 err:    fprintf(stderr, "%s: %s: %s\n", progname, fname, strerror(errno));
00062         return (1);
00063 }

Generated on Sun Dec 25 12:14:17 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2