int main (int argc, char *argv[]) { int i; #ifdef DBUG_OFF return 1; #endif if (argc == 1) return 0; my_thread_global_init(); dup2(1, 2); for (i = 1; i < argc; i++) { if (strncmp(argv[i], "--push1=", 8) == 0) push1=argv[i]+8; else DBUG_PUSH (argv[i]); } { DBUG_ENTER ("main"); DBUG_PROCESS ("dbug-tests"); func1(); DBUG_EXECUTE_IF("dump", { char s[1000]; DBUG_EXPLAIN(s, sizeof(s)-1); DBUG_DUMP("dump", (uchar*)s, strlen(s)); });
int main(int argc, char **argv) { TIGER *tiger; TIGER_RECORD *record; uint x; DBUG_ENTER("main"); DBUG_PROCESS(argv[0]); //DBUG_PUSH("d:t"); if(!(tiger = tiger_init(0))) { fprintf(stderr, "Couldn't allocate TIGER\n"); exit(1); } tiger_open(tiger, argv[1], 'r'); tiger_dump(tiger); for(x=0; x<5 && (record = tiger_read_next(tiger, RT2)); x++) { tiger_record_dump(record); tiger_record_free(record); } tiger_free(tiger); DBUG_RETURN(0); }
int main(int argc __attribute__((unused)), char **argv) { const char **pos; char buff[FN_REFLEN],buff2[FN_REFLEN]; DBUG_ENTER ("main"); DBUG_PROCESS (argv[0]); MY_INIT(argv[0]); if (argv[1] && argv[1][1] == '#') DBUG_PUSH(argv[1]+2); for (pos=test_names; *pos ; pos++) { printf("org : '%s'\n",*pos); printf("pack: '%s'\n",fn_format(buff,*pos,"","",8)); printf("unpack: '%s'\n",fn_format(buff2,*pos,"","",4)); unpack_filename(buff,buff); if (strcmp(buff,buff2) != 0) { printf("error on cmp: '%s' != '%s'\n",buff,buff2); } puts(""); } DBUG_RETURN(0); }
int main(int argc, char *argv[]) { MY_DIR *a; uint f; DBUG_ENTER ("main"); DBUG_PROCESS (argv[0]); if (--argc > 0 && (*(++argv))[0] == '-' && (*argv)[1] == '#' ) DBUG_PUSH (*argv+2); a = my_dir("./", 0); for (f = 0; f < a->number_off_files; f++) { printf("%s\n", a->dir_entry[f].name); } a = my_dir("./", MY_WANT_STAT); for (f = 0; f < a->number_off_files; f++) { printf("%s %d %d %d %s\n", a->dir_entry[f].name, (int) a->dir_entry[f].mystat.st_size, (int) a->dir_entry[f].mystat.st_uid, (int) a->dir_entry[f].mystat.st_gid, S_ISDIR(a->dir_entry[f].mystat.st_mode) ? "dir" : ""); } DBUG_RETURN(0); }
int main(int argc, char **argv) { FIXED *fixed; RECORD *record; DBUG_ENTER("main"); DBUG_PROCESS(argv[0]); DBUG_PUSH("d:t"); if(!(fixed = fixed_init(0))) { fprintf(stderr, "Couldn't allocate FIXED\n"); exit(1); } fixed_options(fixed)->gap = 1; fixed_file_def(fixed, usps_state, 36); fixed_dump(fixed); fixed_open(fixed, argv[1], 'r'); while(record = fixed_read_next(fixed)) { record_dump(record); record_free(record); } fixed_close(fixed); fixed_free(fixed); DBUG_RETURN(0); }
/** Initialize my_sys functions, resources and variables @return Initialization result @retval 0 Success @retval 1 Error. Couldn't initialize environment */ 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 */ /* 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); init_glob_errs(); instrumented_stdin.m_file= stdin; instrumented_stdin.m_psi= NULL; /* not yet instrumented */ mysql_stdin= & instrumented_stdin; if (my_thread_global_init()) return 1; #if defined(SAFE_MUTEX) safe_mutex_global_init(); /* Must be called early */ #endif #if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) fastmutex_global_init(); /* Must be called early */ #endif #if defined(HAVE_PTHREAD_INIT) pthread_init(); /* Must be called before DBUG_ENTER */ #endif /* $HOME is needed early to parse configuration files located in ~/ */ if ((home_dir= getenv("HOME")) != 0) home_dir= intern_filename(home_dir_buff, home_dir); { DBUG_ENTER("my_init"); DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown")); my_win_init(); DBUG_PRINT("exit", ("home: '%s'", home_dir)); #ifdef __WIN__ win32_init_tcp_ip(); #endif DBUG_RETURN(0); } } /* my_init */
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 */
/** Initialize my_sys functions, resources and variables @return Initialization result @retval 0 Success @retval 1 Error. Couldn't initialize environment */ 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 */ my_global_flags= 0; /* 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); init_glob_errs(); instrumented_stdin.m_file= stdin; instrumented_stdin.m_psi= NULL; /* not yet instrumented */ mysql_stdin= & instrumented_stdin; my_progname_short= "unknown"; if (my_progname) my_progname_short= my_progname + dirname_length(my_progname); /* Initalize our mutex handling */ my_mutex_init(); if (my_thread_global_init()) return 1; /* $HOME is needed early to parse configuration files located in ~/ */ if ((home_dir= getenv("HOME")) != 0) home_dir= intern_filename(home_dir_buff, home_dir); { DBUG_ENTER("my_init"); DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown")); my_time_init(); my_win_init(); DBUG_PRINT("exit", ("home: '%s'", home_dir)); #ifdef __WIN__ win32_init_tcp_ip(); #endif DBUG_RETURN(0); } } /* my_init */
/* ============================================================ * * \brief pe_workers_init() * Initializes the worker thread pool. * * @param[] * none * * \return { void } * **/ void pe_workers_init() { static char mod[] = "pe_workers_init"; DBUG_PUSH("d:F:i:L:n:t"); DBUG_PROCESS("pe_workers"); DBUG_ENTER(mod); ring_buffer_init(); /* create the crew and put them to sleep on the ring buffer*/ pe_crew_create(); DBUG_LEAVE; }
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 */
int main(int argc, char **argv) { SHP *shp; GEOMETRY *geo; DBUG_ENTER("main"); DBUG_PROCESS(argv[0]); DBUG_PUSH("d:t"); if(argc != 2) { printf("usage %s <shapefile.shp>\n", argv[0]); DBUG_RETURN(-1); } if(!(shp = shp_init(0))) { printf("Couldn't init\n"); DBUG_RETURN(-2); } if(shp_open(shp, argv[1], 'r') < 0) { printf("Couldn't open\n"); DBUG_RETURN(-3); } shp_dump(shp); while((geo = shp_read_next(shp))) { geometry_dump(geo, 1); geometry_free(geo); } shp_close(shp); shp_free(shp); DBUG_RETURN(0); }
my_bool my_init(void) { if (my_init_done) return 0; my_init_done= 1; if (my_basic_init()) return 1; if (my_thread_global_init()) return 1; { DBUG_ENTER("my_init"); DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown")); my_win_init(); DBUG_PRINT("exit", ("home: '%s'", home_dir)); #ifdef __WIN__ win32_init_tcp_ip(); #endif DBUG_RETURN(0); } } /* my_init */
int main(int argc, char **argv) { SHAPEFILE *sha; SHAPEFILE_RECORD *rec; PROJECTION *proj; int rc; int i, max; DBUG_ENTER("main"); DBUG_PROCESS(argv[0]); DBUG_PUSH("d:t"); if(argc != 2) { printf("usage %s <shapefile>\n", argv[0]); DBUG_RETURN(-1); } if(!(sha = shapefile_init(0))) { printf("Couldn't init\n"); DBUG_RETURN(-2); } if((rc= shapefile_open(sha, argv[1], 'r')) < 0) { printf("Couldn't open\n"); DBUG_RETURN(-3); } proj = projection_init(); if(sha->flags & SHAPEFILE_HAS_PRJ) { projection_set(proj, sha->prj->proj4_def, "+proj=latlong"); shapefile_set_projection(sha, proj); } shapefile_dump(sha); max = sha->dbf->numrecords < 100 ? sha->dbf->numrecords : 100; for(i=1; i<max; i+=10) { shapefile_seek_record(sha, i); if((rec = shapefile_read_next(sha))) { shapefile_record_dump(rec); shapefile_record_free(rec); } else { printf("Error reading record\n"); return 4; } printf("\n\n\n"); } shapefile_close(sha); shapefile_free(sha); DBUG_RETURN(0); }
static int setup_child(pid_t *pid, const char *term, const char *attr, char *const *argv) { int master; char ttyname[20]; DBUG_ENTER("setup_child"); switch ((*pid = pty_fork(&master, ttyname, 0, 0))) { case -1: DBUG_PRINT("startup", ("forkpty: failed")); DBUG_RETURN(-errno); /*NOTREACHED*/ case 0: { const char *shell; DBUG_PROCESS("child"); DBUG_PRINT("info", ("TERM=%s", term)); if (term) setenv("TERM", term, 1); DBUG_PRINT("info", ("attributes=%s", attr)); if (attr) init_pty(0, attr); if (!(shell = argv[0])) { char *s0; uid_t uid; struct passwd *pw; shell = "/bin/bash"; s0 = "-bash"; /* get user's login shell */ if (!(pw = getpwuid(uid = getuid()))) { DBUG_PRINT("error", ("getpwuid(%ld) failed: %s", uid, strerror(errno))); } else if (!(shell = pw->pw_shell) || *shell != '/') { DBUG_PRINT("error", ("bad shell for user id %ld", uid)); } else { DBUG_PRINT("info", ("got shell %s", shell)); s0 = strrchr(shell, '/'); s0 = str_dup(s0); assert(s0 != 0); s0[0] = '-'; } DBUG_PRINT("info", ("startup %s (%s)", shell, s0)); execl(shell, s0, (char *)0); } else { DBUG_PRINT("info", ("startup %s", *argv)); execvp(*argv, argv); } DBUG_PRINT("error", ("exec* failed: %s", strerror(errno))); perror(shell); exit(111); /*NOTREACHED*/ } default: { // Parent process. fcntl(master, F_SETFL, O_NONBLOCK); char *dev = ptsname(master); if (dev) { struct utmp ut; memset(&ut, 0, sizeof ut); if (!strncmp(dev, "/dev/", 5)) dev += 5; strlcpy(ut.ut_line, dev, sizeof ut.ut_line); if (dev[1] == 't' && dev[2] == 'y') dev += 3; if (!strncmp(dev, "pts/", 4)) dev += 4; strncpy(ut.ut_id, dev, sizeof ut.ut_id); ut.ut_type = USER_PROCESS; ut.ut_pid = (long int)*pid; ut.ut_time = time(0); strlcpy(ut.ut_user, getlogin() ?: "?", sizeof ut.ut_user); gethostname(ut.ut_host, sizeof ut.ut_host); login(&ut); } } } DBUG_PRINT("startup", ("forkpty:pid=%ld:master=%d:ttyname=%s", (long int)*pid, master, ttyname)); DBUG_RETURN(master); }
int main(int argc, char** argv) { char* server_key = 0, *server_cert = 0; char* client_key = 0, *client_cert = 0; char* ca_file = 0, *ca_path = 0; char* cipher=0; int child_pid,sv[2]; my_bool unused; struct st_VioSSLFd* ssl_acceptor= 0; struct st_VioSSLFd* ssl_connector= 0; Vio* client_vio=0, *server_vio=0; enum enum_ssl_init_error ssl_init_error; unsigned long ssl_error; MY_INIT(argv[0]); DBUG_PROCESS(argv[0]); DBUG_PUSH(default_dbug_option); if (argc<5) { print_usage(); return 1; } server_key = argv[1]; server_cert = argv[2]; client_key = argv[3]; client_cert = argv[4]; if (argc>5) ca_file = argv[5]; if (argc>6) ca_path = argv[6]; printf("Server key/cert : %s/%s\n", server_key, server_cert); printf("Client key/cert : %s/%s\n", client_key, client_cert); if (ca_file!=0) printf("CAfile : %s\n", ca_file); if (ca_path!=0) printf("CApath : %s\n", ca_path); if (socketpair(PF_UNIX, SOCK_STREAM, IPPROTO_IP, sv)==-1) fatal_error("socketpair"); ssl_acceptor = new_VioSSLAcceptorFd(server_key, server_cert, ca_file, ca_path, cipher); ssl_connector = new_VioSSLConnectorFd(client_key, client_cert, ca_file, ca_path, cipher, &ssl_init_error); client_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0)); client_vio->sd = sv[0]; client_vio->vioblocking(client_vio, 0, &unused); sslconnect(ssl_connector,client_vio,60L,&ssl_error); server_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0)); server_vio->sd = sv[1]; server_vio->vioblocking(client_vio, 0, &unused); sslaccept(ssl_acceptor,server_vio,60L, &ssl_error); printf("Socketpair: %d , %d\n", client_vio->sd, server_vio->sd); child_pid = fork(); if (child_pid==-1) { my_free(ssl_acceptor); my_free(ssl_connector); fatal_error("fork"); } if (child_pid==0) { /* child, therefore, client */ char xbuf[100]; int r = vio_read(client_vio,xbuf, sizeof(xbuf)); if (r<=0) { my_free(ssl_acceptor); my_free(ssl_connector); fatal_error("client:SSL_read"); } xbuf[r] = 0; printf("client:got %s\n", xbuf); my_free(client_vio); my_free(ssl_acceptor); my_free(ssl_connector); } else { const char* s = "Huhuhuh"; int r = vio_write(server_vio,(uchar*)s, strlen(s)); if (r<=0) { my_free(ssl_acceptor); my_free(ssl_connector); fatal_error("server:SSL_write"); } my_free(server_vio); my_free(ssl_acceptor); my_free(ssl_connector); } return 0; }
int main(int argc __attribute__((unused)), char** argv) { char server_key[] = "../SSL/server-key.pem", server_cert[] = "../SSL/server-cert.pem"; char ca_file[] = "../SSL/cacert.pem", *ca_path = 0, *cipher = 0; struct st_VioSSLFd* ssl_acceptor; pthread_t th; TH_ARGS th_args; struct sockaddr_in sa_serv; struct sockaddr_in sa_cli; int listen_sd; int err; size_socket client_len; int reuseaddr = 1; /* better testing, uh? */ MY_INIT(argv[0]); DBUG_PROCESS(argv[0]); DBUG_PUSH(default_dbug_option); printf("Server key/cert : %s/%s\n", server_key, server_cert); if (ca_file!=0) printf("CAfile : %s\n", ca_file); if (ca_path!=0) printf("CApath : %s\n", ca_path); th_args.ssl_acceptor = ssl_acceptor = new_VioSSLAcceptorFd(server_key, server_cert, ca_file, ca_path,cipher); /* ----------------------------------------------- */ /* Prepare TCP socket for receiving connections */ listen_sd = socket (AF_INET, SOCK_STREAM, 0); setsockopt(listen_sd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(&reuseaddr)); memset (&sa_serv, '\0', sizeof(sa_serv)); sa_serv.sin_family = AF_INET; sa_serv.sin_addr.s_addr = INADDR_ANY; sa_serv.sin_port = htons (1111); /* Server Port number */ err = bind(listen_sd, (struct sockaddr*) &sa_serv, sizeof (sa_serv)); /* Receive a TCP connection. */ err = listen (listen_sd, 5); client_len = sizeof(sa_cli); th_args.sd = accept (listen_sd, (struct sockaddr*) &sa_cli, &client_len); close (listen_sd); printf ("Connection from %lx, port %x\n", (long)sa_cli.sin_addr.s_addr, sa_cli.sin_port); /* ----------------------------------------------- */ /* TCP connection is ready. Do server side SSL. */ err = pthread_create(&th, NULL, client_thread, (void*)&th_args); DBUG_PRINT("info", ("pthread_create: %d", err)); pthread_join(th, NULL); #if 0 if (err<=0) { my_free(ssl_acceptor); fatal_error("server:SSL_write"); } #endif /* 0 */ my_free(ssl_acceptor); return 0; }
main(int argc, char **argv) { INIT_EXCEPTIONS(); set_new_handler ( FreeStoreException ); int ret = 1; const char *progname = argv[0]; int compressed = 0; #ifdef FISH_DEBUG DBUG_PROCESS(argv[0]); if(getenv("FISH_DBUG")) DBUG_PUSH(getenv("FISH_DBUG")); #endif argv++; argc--; while(argc > 0 && argv[0][0] == '-'){ const char *opt = argv[0]; argv++; argc--; if(strcmp(opt, "-compressed") == 0){ compressed = 1; } else{ usage(progname); } } if(argc == 2){ char *bookcaseDir = argv[0]; char *infobaseDir = argv[1]; try{ BookCaseDB db(bookcaseDir); const char *infolibDir; const char *bcname; split_path(infobaseDir, infolibDir, bcname); OLIAS_DB mmdb_handle; info_lib *mmdb = mmdb_handle.openInfoLib(infolibDir, bcname); // 30 will be enough for now #define COMPRESSED_AGENT_SIZE 30 char comp_agent[ COMPRESSED_AGENT_SIZE ]; if ( compressed ) { for ( int i = 0; i < COMPRESSED_AGENT_SIZE; i++ ) { comp_agent[i] = 0; } ostrstream str_buf( comp_agent, COMPRESSED_AGENT_SIZE ); info_base *bcptr = mmdb->get_info_base(bcname); handler *x = (bcptr->get_obj_dict()).get_handler( form("%s.%s", bcname, "ps.dict")); x->its_oid().asciiOut(str_buf); } hashTable<CC_String, BTCollectable> hd(hash_func); locator_table( db, hd); /* throw exception if duplicate locator is found */ DBTable *nodeMeta = db.table(BookCaseDB::NodeMeta, DB::READ); DBCursor node_cursor( *nodeMeta ); writeCCF(db, mmdb, bcname); writeBooks(db, mmdb, bcname, &node_cursor, compressed, comp_agent, hd); writeLCF(db, mmdb, bcname, hd); hd.clearAndDestroy(); ret = 0; } catch(PosixError&, pe){ fprintf(stderr, "%s: error on %s: %s\n", progname, bookcaseDir, pe.msg()); } catch(Unexpected&, pe) {
//--------------------------------------------------------------------- int main(int argc, char **argv) { INIT_EXCEPTIONS(); /* can't seem to get C++ initialization stuff to do this... */ OLAF::init(); set_new_handler( FreeStoreException ); int ret = 1; #ifdef FISH_DEBUG DBUG_PROCESS(argv[0]); if(getenv("FISH_DBUG")) DBUG_PUSH(getenv("FISH_DBUG")); #endif if(argc == 4){ const char *toc_option = argv[1]; const char *infolib = argv[2]; const char *srcdir = argv[3]; Dispatch::tmpdir = infolib; Dispatch::srcdir = srcdir; if ( !strcmp(toc_option, "toc") ) { Dispatch::tocgen_only = 1; } else if ( !strcmp(toc_option, "all") ) { Dispatch::tocgen_only = 0; } else { fprintf(stderr, "usage: NodeParse [ tocgen_only | all ] <database-dir> <source-dir>\n"); exit(1); } /* * Add the . directory as a default if the file is not found in scrdir */ SearchPath *sptable = new SearchPath( srcdir, ".", 0 ); Dispatch::search_path_table = sptable; Task *t = new BookCaseTask( infolib ); Stack<int> *istack = new Stack<int>; Dispatch::setRoot(t, istack); mtry{ extern int yylex(); yylex(); ret = 0; } mcatch(Unexpected&, u) { mtry { Dispatch::tok->reportError(Token::User, Token::Fatal, "markup error: %s", u.msg()); } mcatch(ErrorReported&, e) { if ( e.f_severity == Token::Fatal ) { exit(1); } }end_try; } mcatch(PosixError&, pe) { fprintf(stderr, "(ERROR) %s\n", pe.msg() ); exit(1); }