#include <config.h>#include <ctype.h>#include <errno.h>#include <stdarg.h>#include <stdio.h>#include <time.h>#include "misc.h"#include "empthread.h"#include "journal.h"#include "optlist.h"#include "player.h"#include "prototypes.h"Include dependency graph for journal.c:

Go to the source code of this file.
Functions | |
| static FILE * | journal_open (void) |
| static void | journal_entry (char *fmt,...) |
| int | journal_startup (void) |
| void | journal_shutdown (void) |
| int | journal_reopen (void) |
| void | journal_login (void) |
| void | journal_logout (void) |
| void | journal_input (char *input) |
| void | journal_update (int etu) |
Variables | |
| static char | journal_fname [] = "journal.log" |
| static FILE * | journal |
| static void journal_entry | ( | char * | fmt, | |
| ... | ||||
| ) | [static] |
Definition at line 73 of file journal.c.
References debug, empth_self(), journal, logerror(), and vsnprintf.
Referenced by journal_input(), journal_login(), journal_logout(), journal_shutdown(), journal_startup(), and journal_update().
00074 { 00075 static char buf[1024]; 00076 va_list ap; 00077 time_t now; 00078 unsigned char *p; 00079 00080 if (journal) { 00081 time(&now); 00082 fprintf(journal, "%.24s %p ", ctime(&now), empth_self()); 00083 00084 va_start(ap, fmt); 00085 vsnprintf(buf, sizeof(buf) - 1, fmt, ap); 00086 va_end(ap); 00087 00088 for (p = (unsigned char *)buf; *p; p++) { 00089 if (isprint(*p)) 00090 putc(*p, journal); 00091 else 00092 fprintf(journal, "\\%03o", *p); 00093 } 00094 fputs("\n", journal); 00095 if (debug) 00096 fflush(journal); 00097 if (ferror(journal)) { 00098 logerror("Error writing journal (%s)", strerror(errno)); 00099 clearerr(journal); 00100 } 00101 } 00102 }
Here is the call graph for this function:

| void journal_input | ( | char * | input | ) |
Definition at line 160 of file journal.c.
References journal_entry().
Referenced by recvclient().
00161 { 00162 journal_entry("input %s", input); 00163 }
Here is the call graph for this function:

| void journal_login | ( | void | ) |
Definition at line 147 of file journal.c.
References journal_entry().
Referenced by player_main().
00148 { 00149 journal_entry("login %d %s %s", 00150 player->cnum, player->hostaddr, player->userid); 00151 }
Here is the call graph for this function:

| void journal_logout | ( | void | ) |
Definition at line 154 of file journal.c.
References journal_entry().
Referenced by player_main().
00155 { 00156 journal_entry("logout %d", player->cnum); 00157 }
Here is the call graph for this function:

| static FILE* journal_open | ( | void | ) | [static] |
Definition at line 67 of file journal.c.
References journal_fname.
Referenced by journal_reopen(), and journal_startup().
00068 { 00069 return fopen(journal_fname, "a+"); 00070 }
| int journal_reopen | ( | void | ) |
Definition at line 129 of file journal.c.
References journal, journal_fname, journal_open(), keep_journal, and logerror().
Referenced by main(), and relo().
00130 { 00131 FILE *j; 00132 00133 if (!keep_journal) 00134 return 0; 00135 j = journal_open(); 00136 if (!j) { 00137 logerror("Can't open %s (%s)", journal_fname, strerror(errno)); 00138 return -1; 00139 } 00140 if (journal) 00141 fclose(journal); 00142 journal = j; 00143 return 0; 00144 }
Here is the call graph for this function:

| void journal_shutdown | ( | void | ) |
Definition at line 119 of file journal.c.
References journal, journal_entry(), and NULL.
Referenced by finish_server(), and panic().
00120 { 00121 journal_entry("shutdown"); 00122 if (journal) { 00123 fclose(journal); 00124 journal = NULL; 00125 } 00126 }
Here is the call graph for this function:

| int journal_startup | ( | void | ) |
Definition at line 105 of file journal.c.
References journal, journal_entry(), journal_fname, journal_open(), keep_journal, and logerror().
Referenced by start_server().
00106 { 00107 if (!keep_journal) 00108 return 0; 00109 journal = journal_open(); 00110 if (!journal) { 00111 logerror("Can't open %s (%s)", journal_fname, strerror(errno)); 00112 return -1; 00113 } 00114 journal_entry("startup"); 00115 return 0; 00116 }
Here is the call graph for this function:

| void journal_update | ( | int | etu | ) |
Definition at line 166 of file journal.c.
References journal_entry().
Referenced by update_main().
00167 { 00168 journal_entry("update %d", etu); 00169 }
Here is the call graph for this function:

FILE* journal [static] |
Definition at line 64 of file journal.c.
Referenced by journal_entry(), journal_reopen(), journal_shutdown(), and journal_startup().
char journal_fname[] = "journal.log" [static] |
Definition at line 63 of file journal.c.
Referenced by journal_open(), journal_reopen(), and journal_startup().
1.5.2