utils/eventlogadm.c

ソースコードを見る。

関数

static void usage (char *s)
static void display_eventlog_names (void)
static int DoAddSourceCommand (int argc, char **argv, BOOL debugflag, char *exename)
static int DoWriteCommand (int argc, char **argv, BOOL debugflag, char *exename)
int main (int argc, char *argv[])

変数

int optind
char * optarg
int opt_debug = 0


関数

static void usage ( char *  s  )  [static]

eventlogadm.c36 行で定義されています。

参照先 printf().

00037 {
00038         printf( "\nUsage: %s [OPTION]\n\n", s );
00039         printf( " -o write <Eventlog Name> \t\t\t\t\tWrites records to eventlog from STDIN\n" );
00040         printf( " -o addsource <EventlogName> <sourcename> <msgfileDLLname> \tAdds the specified source & DLL eventlog registry entry\n" );
00041         printf( "\nMiscellaneous options:\n" );
00042         printf( " -d\t\t\t\t\t\t\t\tturn debug on\n" );
00043         printf( " -h\t\t\t\t\t\t\t\tdisplay help\n\n" );
00044 }

static void display_eventlog_names ( void   )  [static]

eventlogadm.c46 行で定義されています。

参照先 printf().

参照元 DoWriteCommand()main().

00047 {
00048         const char **elogs;
00049         int i;
00050 
00051         elogs = lp_eventlog_list(  );
00052         printf( "Active eventlog names (from smb.conf):\n" );
00053         printf( "--------------------------------------\n" );
00054         if ( elogs ) {
00055                 for ( i = 0; elogs[i]; i++ ) {
00056                         printf( "\t%s\n", elogs[i] );
00057                 }
00058         } 
00059         else
00060                 printf( "\t<None specified>\n");
00061 }

static int DoAddSourceCommand ( int  argc,
char **  argv,
BOOL  debugflag,
char *  exename 
) [static]

eventlogadm.c63 行で定義されています。

参照先 eventlog_add_source()printf()regdb_init().

参照元 main().

00064 {
00065 
00066         if ( argc < 3 ) {
00067                 printf( "need more arguments:\n" );
00068                 printf( "-o addsource EventlogName SourceName /path/to/EventMessageFile.dll\n" );
00069                 return -1;
00070         }
00071         /* must open the registry before we access it */
00072         if ( !regdb_init(  ) ) {
00073                 printf( "Can't open the registry.\n" );
00074                 return -1;
00075         }
00076 
00077         if ( !eventlog_add_source( argv[0], argv[1], argv[2] ) )
00078                 return -2;
00079         return 0;
00080 }

static int DoWriteCommand ( int  argc,
char **  argv,
BOOL  debugflag,
char *  exename 
) [static]

eventlogadm.c82 行で定義されています。

参照先 display_eventlog_names()elog_close_tdb()elog_open_tdb()fixup_eventlog_entry()opt_debugparse_logentry()printf()write_eventlog_tdb().

参照元 main().

00083 {
00084         FILE *f1;
00085         char *argfname;
00086         ELOG_TDB *etdb;
00087 
00088         /* fixed constants are bad bad bad  */
00089         pstring linein;
00090         BOOL is_eor;
00091         Eventlog_entry ee;
00092         int rcnum;
00093 
00094         f1 = stdin;
00095         if ( !f1 ) {
00096                 printf( "Can't open STDIN\n" );
00097                 return -1;
00098         }
00099 
00100         if ( debugflag ) {
00101                 printf( "Starting write for eventlog [%s]\n", argv[0] );
00102                 display_eventlog_names(  );
00103         }
00104 
00105         argfname = argv[0];
00106 
00107         if ( !( etdb = elog_open_tdb( argfname, False ) ) ) {
00108                 printf( "can't open the eventlog TDB (%s)\n", argfname );
00109                 return -1;
00110         }
00111 
00112         ZERO_STRUCT( ee );      /* MUST initialize between records */
00113 
00114         while ( !feof( f1 ) ) {
00115                 fgets( linein, sizeof( linein ) - 1, f1 );
00116                 linein[strlen( linein ) - 1] = 0;       /* whack the line delimiter */
00117 
00118                 if ( debugflag )
00119                         printf( "Read line [%s]\n", linein );
00120 
00121                 is_eor = False;
00122 
00123 
00124                 parse_logentry( ( char * ) &linein, &ee, &is_eor );
00125                 /* should we do something with the return code? */
00126 
00127                 if ( is_eor ) {
00128                         fixup_eventlog_entry( &ee );
00129 
00130                         if ( opt_debug )
00131                                 printf( "record number [%d], tg [%d] , tw [%d]\n", ee.record.record_number, ee.record.time_generated, ee.record.time_written );
00132 
00133                         if ( ee.record.time_generated != 0 ) {
00134 
00135                                 /* printf("Writing to the event log\n"); */
00136 
00137                                 rcnum = write_eventlog_tdb( ELOG_TDB_CTX(etdb), &ee );
00138                                 if ( !rcnum ) {
00139                                         printf( "Can't write to the event log\n" );
00140                                 } else {
00141                                         if ( opt_debug )
00142                                                 printf( "Wrote record %d\n",
00143                                                         rcnum );
00144                                 }
00145                         } else {
00146                                 if ( opt_debug )
00147                                         printf( "<null record>\n" );
00148                         }
00149                         ZERO_STRUCT( ee );      /* MUST initialize between records */
00150                 }
00151         }
00152 
00153         elog_close_tdb( etdb , False );
00154 
00155         return 0;
00156 }

int main ( int  argc,
char *  argv[] 
)

eventlogadm.c160 行で定義されています。

参照先 display_eventlog_names()DoAddSourceCommand()DoWriteCommand()dyn_CONFIGFILEeventlog_add_source()load_case_tables()opt_debugoptargoptindprintf()StrCaseCmp()usage().

00161 {
00162         int opt, rc;
00163         char *exename;
00164 
00165 
00166         fstring opname;
00167 
00168         load_case_tables();
00169 
00170         opt_debug = 0;          /* todo set this from getopts */
00171 
00172         lp_load( dyn_CONFIGFILE, True, False, False, True);
00173 
00174         exename = argv[0];
00175 
00176         /* default */
00177 
00178         fstrcpy( opname, "write" );     /* the default */
00179 
00180 #if 0                           /* TESTING CODE */
00181         eventlog_add_source( "System", "TestSourceX", "SomeTestPathX" );
00182 #endif
00183         while ( ( opt = getopt( argc, argv, "dho:" ) ) != EOF ) {
00184                 switch ( opt ) {
00185 
00186                 case 'o':
00187                         fstrcpy( opname, optarg );
00188                         break;
00189 
00190                 case 'h':
00191                         usage( exename );
00192                         display_eventlog_names(  );
00193                         exit( 0 );
00194                         break;
00195 
00196                 case 'd':
00197                         opt_debug = 1;
00198                         break;
00199                 }
00200         }
00201 
00202         argc -= optind;
00203         argv += optind;
00204 
00205         if ( argc < 1 ) {
00206                 printf( "\nNot enough arguments!\n" );
00207                 usage( exename );
00208                 exit( 1 );
00209         }
00210 
00211         /*  note that the separate command types should call usage if they need to... */
00212         while ( 1 ) {
00213                 if ( !StrCaseCmp( opname, "addsource" ) ) {
00214                         rc = DoAddSourceCommand( argc, argv, opt_debug,
00215                                                  exename );
00216                         break;
00217                 }
00218                 if ( !StrCaseCmp( opname, "write" ) ) {
00219                         rc = DoWriteCommand( argc, argv, opt_debug, exename );
00220                         break;
00221                 }
00222                 printf( "unknown command [%s]\n", opname );
00223                 usage( exename );
00224                 exit( 1 );
00225                 break;
00226         }
00227         return rc;
00228 }


変数

int optind

char* optarg

int opt_debug = 0

eventlogadm.c34 行で定義されています。

参照元 DoWriteCommand()main().


Sambaに対してSat Aug 29 21:24:33 2009に生成されました。  doxygen 1.4.7