my_bool my_init(void) { char * str; if (my_init_done) return 0; my_init_done=1; mysys_usage_id++; my_umask= 0660; /* Default umask for new files */ my_umask_dir= 0700; /* Default umask for new directories */ init_glob_errs(); #if defined(THREAD) if (my_thread_global_init()) return 1; # if defined(SAFE_MUTEX) safe_mutex_global_init(); /* Must be called early */ # endif #endif #if defined(THREAD) && defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) fastmutex_global_init(); /* Must be called early */ #endif netware_init(); #ifdef THREAD #if defined(HAVE_PTHREAD_INIT) pthread_init(); /* Must be called before DBUG_ENTER */ #endif #if !defined( __WIN__) && !defined(__NETWARE__) sigfillset(&my_signals); /* signals blocked by mf_brkhant */ #endif #endif /* THREAD */ { DBUG_ENTER("my_init"); DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown")); if (!home_dir) { /* Don't initialize twice */ my_win_init(); if ((home_dir=getenv("HOME")) != 0) home_dir=intern_filename(home_dir_buff,home_dir); #ifndef VMS /* Default creation of new files */ if ((str=getenv("UMASK")) != 0) my_umask=(int) (atoi_octal(str) | 0600); /* Default creation of new dir's */ if ((str=getenv("UMASK_DIR")) != 0) my_umask_dir=(int) (atoi_octal(str) | 0700); #endif #ifdef VMS init_ctype(); /* Stupid linker don't link _ctype.c */ #endif DBUG_PRINT("exit",("home: '%s'",home_dir)); } #ifdef __WIN__ win32_init_tcp_ip(); #endif DBUG_RETURN(0); } } /* my_init */
void my_init(void) { my_string str; if (my_init_done) return; my_init_done=1; #if defined(THREAD) && defined(SAFE_MUTEX) safe_mutex_global_init(); /* Must be called early */ #endif netware_init(); #ifdef THREAD #if defined(HAVE_PTHREAD_INIT) pthread_init(); /* Must be called before DBUG_ENTER */ #endif my_thread_global_init(); #if !defined( __WIN__) && !defined(OS2) && !defined(__NETWARE__) sigfillset(&my_signals); /* signals blocked by mf_brkhant */ #endif #endif /* THREAD */ #ifdef UNIXWARE_7 (void) isatty(0); /* Go around connect() bug in UW7 */ #endif { DBUG_ENTER("my_init"); DBUG_PROCESS(my_progname ? my_progname : (char*) "unknown"); if (!home_dir) { /* Don't initialize twice */ my_win_init(); if ((home_dir=getenv("HOME")) != 0) home_dir=intern_filename(home_dir_buff,home_dir); #ifndef VMS /* Default creation of new files */ if ((str=getenv("UMASK")) != 0) my_umask=(int) (atoi_octal(str) | 0600); /* Default creation of new dir's */ if ((str=getenv("UMASK_DIR")) != 0) my_umask_dir=(int) (atoi_octal(str) | 0700); #endif #ifdef VMS init_ctype(); /* Stupid linker don't link _ctype.c */ #endif DBUG_PRINT("exit",("home: '%s'",home_dir)); } #ifdef __WIN__ win32_init_tcp_ip(); #endif DBUG_VOID_RETURN; } } /* my_init */
struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list **filelist) { char **args; struct symbol_list *list; // Initialize symbol stream first, so that we can add defines etc init_symbols(); args = argv; for (;;) { char *arg = *++args; if (!arg) break; if (arg[0] == '-' && arg[1]) { args = handle_switch(arg+1, args); continue; } add_ptr_list_notag(filelist, arg); } handle_switch_W_finalize(); handle_switch_v_finalize(); handle_arch_finalize(); list = NULL; if (!ptr_list_empty(filelist)) { // Initialize type system init_ctype(); create_builtin_stream(); add_pre_buffer("#define __CHECKER__ 1\n"); if (!preprocess_only) declare_builtin_functions(); list = sparse_initial(); /* * Protect the initial token allocations, since * they need to survive all the others */ protect_token_alloc(); } return list; }
int main(int argc, char **argv) { int c; char *lfname = NULL; char *cfname = NULL; char *wfname = NULL; DIR *dir; init_charmap(); init_collate(); init_ctype(); init_messages(); init_monetary(); init_numeric(); init_time(); yydebug = 0; (void) setlocale(LC_ALL, ""); while ((c = getopt(argc, argv, "w:i:cf:u:vUD")) != -1) { switch (c) { case 'D': dragonfly = 1; break; case 'v': verbose++; break; case 'i': lfname = optarg; break; case 'u': set_wide_encoding(optarg); break; case 'f': cfname = optarg; break; case 'U': undefok++; break; case 'c': warnok++; break; case 'w': wfname = optarg; break; case '?': usage(); break; } } if ((argc - 1) != (optind)) { usage(); } locname = argv[argc - 1]; if (verbose) { (void) printf("Processing locale %s.\n", locname); } if (cfname) { if (verbose) (void) printf("Loading charmap %s.\n", cfname); reset_scanner(cfname); (void) yyparse(); } if (wfname) { if (verbose) (void) printf("Loading widths %s.\n", wfname); reset_scanner(wfname); (void) yyparse(); } if (verbose) { (void) printf("Loading POSIX portable characters.\n"); } add_charmap_posix(); if (lfname) { reset_scanner(lfname); } else { reset_scanner(NULL); } /* make the directory for the locale if not already present */ if (!dragonfly) { while ((dir = opendir(locname)) == NULL) { if ((errno != ENOENT) || (mkdir(locname, 0755) < 0)) { errf(strerror(errno)); } } (void) closedir(dir); (void) mkdir(dirname(category_file()), 0755); } (void) yyparse(); if (verbose) { (void) printf("All done.\n"); } return (warnings ? 1 : 0); }