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) { PAIRLIST *list; DBUG_PUSH("d:t"); if(!(list = pairlist_init(&compare_string_ci_eq, &compare_string_ci_eq))) { fprintf(stderr, "Couldn't init pairlist\n"); return 1; } pairlist_add(list, "name", "Jeremy Cole"); pairlist_add(list, "age", "23"); pairlist_add(list, "height", "6'1\""); printf("name=%s age=%s height=%s\n", pairlist_get_value(list, "name"), pairlist_get_value(list, "age"), pairlist_get_value(list, "height")); pairlist_dump(list); pairlist_free(list); return 0; }
int main(int argc, char **argv) { const char *the_set = NULL; int argcnt = 1; CHARSET_INFO *cs; if (getenv("SCRIPT_NAME")) { printf("Content-Type: text/html\r\n\r\n"); } my_init(); if (argc > argcnt && argv[argcnt][0] == '-' && argv[argcnt][1] == '#') DBUG_PUSH(argv[argcnt++]+2); if (argc > argcnt) the_set = argv[argcnt++]; if (argc > argcnt) charsets_dir = argv[argcnt++]; if (!the_set) { print_index(); return 0; } if (!(cs= get_charset_by_name(the_set, MYF(MY_WME)))) return 1; print_cs(cs); 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[]) { 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)); });
static int get_options(int argc, char **argv) { char *pos; while (--argc >0 && *(pos = *(++argv)) == '-' ) { switch(*++pos) { case 'B': /* Big file */ flag=1; break; case 'v': /* verbose */ verbose=1; break; case 'm': remove_ant=atoi(++pos); break; case 'V': printf("hp_test1 Ver 3.0 \n"); exit(0); case '#': DBUG_PUSH (++pos); break; } } return 0; } /* get options */
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); }
void libmysql_init(void) { if (libmysql_inited) return; libmysql_inited=1; my_init(); { DBUG_ENTER("libmysql_init"); #ifdef LOG_ALL DBUG_PUSH("d:t:S:O,c::\\tmp\\libmysql.log"); #else if (getenv("LIBMYSQL_LOG") != NULL) DBUG_PUSH(getenv("LIBMYSQL_LOG")); #endif DBUG_VOID_RETURN; } }
static my_bool get_one_option(int optid, const struct my_option *opt, char *argument) { my_bool add_option= TRUE; switch (optid) { case '?': printf("MySQL utility for upgrading database to MySQL version %s\n", MYSQL_SERVER_VERSION); my_print_help(my_long_options); exit(0); break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); add_option= FALSE; break; case 'p': tty_password= 1; add_option= FALSE; if (argument) { /* Add password to ds_args before overwriting the arg with x's */ add_one_option(&ds_args, opt, argument); while (*argument) *argument++= 'x'; /* Destroy argument */ tty_password= 0; } break; case 't': strnmov(opt_tmpdir, argument, sizeof(opt_tmpdir)); add_option= FALSE; break; case 'b': /* --basedir */ case 'v': /* --verbose */ case 'd': /* --datadir */ case 'f': /* --force */ add_option= FALSE; break; } if (add_option) { /* This is an option that is accpted by mysql_upgrade just so it can be passed on to "mysql" and "mysqlcheck" Save it in the ds_args string */ add_one_option(&ds_args, opt, argument); } return 0; }
int func1() { DBUG_ENTER("func1"); func2(); if (push1) { DBUG_PUSH(push1); fprintf(DBUG_FILE, "=> push1\n"); } DBUG_RETURN(10); }
/* ============================================================ * * \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; }
static void CheckEnableDbug( compiler_phase_t phase) { DBUG_ENTER("CheckEnableDbug"); if (global.my_dbug && (phase >= global.my_dbug_from) && !global.my_dbug_active) { DBUG_PUSH( global.my_dbug_str); global.my_dbug_active = TRUE; } DBUG_VOID_RETURN; }
static void get_options(int argc, char **argv) { char *pos,*progname; progname= argv[0]; while (--argc >0 && *(pos = *(++argv)) == '-' ) { switch(*++pos) { case 'l': use_log=1; break; case 'f': forks=atoi(++pos); break; case 't': tests=atoi(++pos); break; case 'K': /* Use key cacheing */ key_cacheing=1; break; case 'A': /* All flags */ use_log=key_cacheing=1; break; case '?': case 'I': case 'V': printf("%s Ver 1.0 for %s at %s\n",progname,SYSTEM_TYPE,MACHINE_TYPE); puts("By Monty, for your professional use\n"); puts("Test av locking with threads\n"); printf("Usage: %s [-?lKA] [-f#] [-t#]\n",progname); exit(0); case '#': DBUG_PUSH (++pos); break; default: printf("Illegal option: '%c'\n",*pos); break; } } return; }
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); }
static int get_options(int argc,char *argv[]) { char *pos,*progname; DEBUGGER_OFF; progname= argv[0]; while (--argc >0 && *(pos = *(++argv)) == '-' ) { switch(*++pos) { case 'B': /* Big file */ flag=1; break; case 'v': /* verbose */ verbose=1; break; case 'm': /* records */ recant=atoi(++pos); break; case 's': silent=1; break; case 't': testflag=atoi(++pos); /* testmod */ break; case 'V': case 'I': case '?': printf("%s Ver 1.1 for %s at %s\n",progname,SYSTEM_TYPE,MACHINE_TYPE); puts("TCX Datakonsult AB, by Monty, for your professional use\n"); printf("Usage: %s [-?ABIKLsWv] [-m#] [-t#]\n",progname); exit(0); case '#': DEBUGGER_ON; DBUG_PUSH (++pos); break; } } return 0; } /* get options */
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) {
static my_bool get_one_option(int optid, const struct my_option *opt, char *argument) { my_bool add_option= TRUE; switch (optid) { case '?': printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000")); puts("MariaDB utility for upgrading databases to new MariaDB versions."); print_defaults("my", load_default_groups); puts(""); my_print_help(my_long_options); my_print_variables(my_long_options); die(0); break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); add_option= FALSE; debug_check_flag= 1; break; case 'p': if (argument == disabled_my_option) argument= (char*) ""; /* Don't require password */ tty_password= 1; add_option= FALSE; if (argument) { /* Add password to ds_args before overwriting the arg with x's */ add_one_option(&ds_args, opt, argument); while (*argument) *argument++= 'x'; /* Destroy argument */ tty_password= 0; } break; case 't': strnmov(opt_tmpdir, argument, sizeof(opt_tmpdir)); add_option= FALSE; break; case 'b': /* --basedir */ case 'd': /* --datadir */ fprintf(stderr, "%s: the '--%s' option is always ignored\n", my_progname, optid == 'b' ? "basedir" : "datadir"); /* FALLTHROUGH */ case 'k': /* --version-check */ case 'v': /* --verbose */ opt_verbose++; if (argument == disabled_my_option) { opt_verbose= 0; opt_silent= 1; } add_option= 0; break; case 'V': printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); die(0); break; case OPT_SILENT: opt_verbose= 0; add_option= 0; break; case 'f': /* --force */ case 's': /* --upgrade-system-tables */ case OPT_WRITE_BINLOG: /* --write-binlog */ add_option= FALSE; break; case 'h': /* --host */ case 'W': /* --pipe */ case 'P': /* --port */ case 'S': /* --socket */ case OPT_MYSQL_PROTOCOL: /* --protocol */ case OPT_SHARED_MEMORY_BASE_NAME: /* --shared-memory-base-name */ case OPT_PLUGIN_DIR: /* --plugin-dir */ case OPT_DEFAULT_AUTH: /* --default-auth */ add_one_option(&conn_args, opt, argument); break; } if (add_option) { /* This is an option that is accpted by mysql_upgrade just so it can be passed on to "mysql" and "mysqlcheck" Save it in the ds_args string */ add_one_option(&ds_args, opt, argument); } return 0; }
static void get_options(int argc, char *argv[]) { int c , option_index = 0; while ((c = getopt_long(argc, argv, "abBcCd:i:k:KmPR:SspNu:UvVw#:", long_options, &option_index)) != EOF) { switch (c) { case 'a': key_type = HA_KEYTYPE_TEXT; break; case 'c': create_flag |= HA_CREATE_CHECKSUM; break; case 'C': opt_unique = 1; break; case 'R': /* Length of record pointer */ rec_pointer_size = atoi(optarg); if (rec_pointer_size > 3) rec_pointer_size = 0; break; case 'P': pack_keys = HA_PACK_KEY; /* Use prefix * compression */ break; case 'B': pack_keys = HA_BINARY_PACK_KEY; /* Use binary * compression */ break; case 'S': if (key_field == FIELD_VARCHAR) { create_flag = 0; /* Static sized varchar */ } else if (key_field != FIELD_BLOB) { key_field = FIELD_NORMAL; /* static-size record */ extra_field = FIELD_NORMAL; } break; case 'p': pack_keys = HA_PACK_KEY; /* Use prefix + space * packing */ pack_seg = HA_SPACE_PACK; key_type = HA_KEYTYPE_TEXT; break; case 'N': null_fields = 1; /* First key part may be null */ break; case 'v': /* verbose */ verbose = 1; break; case 'd': remove_count = atoi(optarg); break; case 'i': insert_count = atoi(optarg); break; case 'u': update_count = atoi(optarg); break; case 'U': skip_update = 1; break; case 'm': unique_key = 0; break; case 'b': key_field = FIELD_BLOB; /* blob key */ extra_field = FIELD_BLOB; pack_seg |= HA_BLOB_PART; key_type = HA_KEYTYPE_VARTEXT; break; case 'k': key_length = atoi(optarg); if (key_length < 4 || key_length > MI_MAX_KEY_LENGTH) { fprintf(stderr, "Wrong key length\n"); exit(1); } break; case 's': silent = 1; break; case 'w': key_field = FIELD_VARCHAR; /* varchar keys */ extra_field = FIELD_VARCHAR; key_type = HA_KEYTYPE_VARTEXT; pack_seg |= HA_VAR_LENGTH; create_flag |= HA_PACK_RECORD; break; case 'K': /* Use key cacheing */ key_cacheing = 1; break; case 'V': printf("test1 Ver 1.0 \n"); exit(0); case '#': DEBUGGER_ON; DBUG_PUSH(optarg); break; } } return; } /* get options */
int main(int argc, char** argv) { if (argc < 3) { std::cout << "Arguments are <connect_string cluster> <timeout> [m(merge events)|d(debug)].\n"; exit(-1); } const char *connectstring = argv[1]; int timeout = atoi(argv[2]); ndb_init(); bool merge_events = argc > 3 && strchr(argv[3], 'm') != 0; #ifdef VM_TRACE bool dbug = argc > 3 && strchr(argv[3], 'd') != 0; if (dbug) DBUG_PUSH("d:t:"); if (dbug) putenv("API_SIGNAL_LOG=-"); #endif Ndb_cluster_connection *cluster_connection= new Ndb_cluster_connection(connectstring); // Object representing the cluster int r= cluster_connection->connect(5 /* retries */, 3 /* delay between retries */, 1 /* verbose */); if (r > 0) { std::cout << "Cluster connect failed, possibly resolved with more retries.\n"; exit(-1); } else if (r < 0) { std::cout << "Cluster connect failed.\n"; exit(-1); } if (cluster_connection->wait_until_ready(30,30)) { std::cout << "Cluster was not ready within 30 secs." << std::endl; exit(-1); } Ndb* myNdb= new Ndb(cluster_connection, "TEST_DB"); // Object representing the database if (myNdb->init() == -1) APIERROR(myNdb->getNdbError()); const char *eventName= "CHNG_IN_t0"; const char *eventTableName= "t0"; const int noEventColumnName= 5; const char *eventColumnName[noEventColumnName]= {"c0", "c1", "c2", "c3", "c4" }; // Create events myCreateEvent(myNdb, eventName, eventTableName, eventColumnName, noEventColumnName, merge_events); // Normal values and blobs are unfortunately handled differently.. typedef union { NdbRecAttr* ra; NdbBlob* bh; } RA_BH; int i, j, k, l; j = 0; while (j < timeout) { // Start "transaction" for handling events NdbEventOperation* op; printf("create EventOperation\n"); if ((op = myNdb->createEventOperation(eventName)) == NULL) APIERROR(myNdb->getNdbError()); op->mergeEvents(merge_events); printf("get values\n"); RA_BH recAttr[noEventColumnName]; RA_BH recAttrPre[noEventColumnName]; // primary keys should always be a part of the result for (i = 0; i < noEventColumnName; i++) { if (i < 4) { recAttr[i].ra = op->getValue(eventColumnName[i]); recAttrPre[i].ra = op->getPreValue(eventColumnName[i]); } else if (merge_events) { recAttr[i].bh = op->getBlobHandle(eventColumnName[i]); recAttrPre[i].bh = op->getPreBlobHandle(eventColumnName[i]); } } // set up the callbacks printf("execute\n"); // This starts changes to "start flowing" if (op->execute()) APIERROR(op->getNdbError()); NdbEventOperation* the_op = op; i= 0; while (i < timeout) { // printf("now waiting for event...\n"); int r = myNdb->pollEvents(1000); // wait for event or 1000 ms if (r > 0) { // printf("got data! %d\n", r); while ((op= myNdb->nextEvent())) { assert(the_op == op); i++; switch (op->getEventType()) { case NdbDictionary::Event::TE_INSERT: printf("%u INSERT", i); break; case NdbDictionary::Event::TE_DELETE: printf("%u DELETE", i); break; case NdbDictionary::Event::TE_UPDATE: printf("%u UPDATE", i); break; default: abort(); // should not happen } printf(" gci=%d\n", (int)op->getGCI()); for (k = 0; k <= 1; k++) { printf(k == 0 ? "post: " : "pre : "); for (l = 0; l < noEventColumnName; l++) { if (l < 4) { NdbRecAttr* ra = k == 0 ? recAttr[l].ra : recAttrPre[l].ra; if (ra->isNULL() >= 0) { // we have a value if (ra->isNULL() == 0) { // we have a non-null value if (l < 2) printf("%-5u", ra->u_32_value()); else printf("%-5.4s", ra->aRef()); } else printf("%-5s", "NULL"); } else printf("%-5s", "-"); // no value } else if (merge_events) { int isNull; NdbBlob* bh = k == 0 ? recAttr[l].bh : recAttrPre[l].bh; bh->getDefined(isNull); if (isNull >= 0) { // we have a value if (! isNull) { // we have a non-null value Uint64 length = 0; bh->getLength(length); // read into buffer unsigned char* buf = new unsigned char [length]; memset(buf, 'X', length); Uint32 n = length; bh->readData(buf, n); // n is in/out assert(n == length); // pretty-print bool first = true; Uint32 i = 0; while (i < n) { unsigned char c = buf[i++]; Uint32 m = 1; while (i < n && buf[i] == c) i++, m++; if (! first) printf("+"); printf("%u%c", m, c); first = false; } printf("[%u]", n); delete [] buf; } else printf("%-5s", "NULL"); } else printf("%-5s", "-"); // no value } } printf("\n"); } } } else printf("timed out (%i)\n", timeout); } // don't want to listen to events anymore if (myNdb->dropEventOperation(the_op)) APIERROR(myNdb->getNdbError()); the_op = 0; j++; } { NdbDictionary::Dictionary *myDict = myNdb->getDictionary(); if (!myDict) APIERROR(myNdb->getNdbError()); // remove event from database if (myDict->dropEvent(eventName)) APIERROR(myDict->getNdbError()); } delete myNdb; delete cluster_connection; ndb_end(0); return 0; }
static void get_options( int argc, char *argv[]) { char *pos,*progname; DEBUGGER_OFF; progname= argv[0]; while (--argc >0 && *(pos = *(++argv)) == '-' ) { switch(*++pos) { case 'b': if (*++pos) nisam_block_size= MY_ALIGN(atoi(pos),512); set_if_bigger(nisam_block_size,8192); /* Max block size */ set_if_smaller(nisam_block_size,1024); break; case 'B': use_blob=1; break; case 'K': /* Use key cacheing */ key_cacheing=1; break; case 'W': /* Use write cacheing */ write_cacheing=1; if (*++pos) my_default_record_cache_size=atoi(pos); break; case 'i': if (*++pos) srand(atoi(pos)); break; case 'l': use_log=1; break; case 'L': locking=1; break; case 'A': /* use asyncron io */ async_io=1; if (*++pos) my_default_record_cache_size=atoi(pos); break; case 'v': /* verbose */ verbose=1; break; case 'm': /* records */ recant=atoi(++pos); break; case 'f': if ((first_key=atoi(++pos)) <0 || first_key >= NISAM_KEYS) first_key=0; break; case 'k': if ((keys=(uint) atoi(++pos)) < 1 || keys > (uint) (NISAM_KEYS-first_key)) keys=NISAM_KEYS-first_key; break; case 'P': pack_type=0; /* Don't use DIFF_LENGTH */ break; case 'R': /* Length of record pointer */ rec_pointer_size=atoi(++pos); if (rec_pointer_size > 3) rec_pointer_size=0; break; case 'S': pack_fields=0; /* Static-length-records */ break; case 't': testflag=atoi(++pos); /* testmod */ break; case '?': case 'I': case 'V': printf("%s Ver 1.4 for %s at %s\n",progname,SYSTEM_TYPE,MACHINE_TYPE); puts("TCX Datakonsult AB, by Monty, for your professional use\n"); printf("Usage: %s [-?ABIKLPRSVWltv] [-b#] [-k#] [-f#] [-m#] [-t#]\n",progname); exit(0); case '#': DEBUGGER_ON; DBUG_PUSH (++pos); break; default: printf("Illegal option: '%c'\n",*pos); break; } } return; } /* get options */
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; }
static void get_options(register int *argc, register char ***argv) { int help,version; const char *pos,*usage; char option; help=0; usage="Usage: %s [-?iruvDIV] [-c #] [-f #] [-F filepath/] [-o #] [-R file recordpos] [-w write_file] [log-filename [table ...]] \n"; pos=""; while (--*argc > 0 && *(pos = *(++*argv)) == '-' ) { while (*++pos) { version=0; switch((option=*pos)) { case '#': DBUG_PUSH (++pos); pos=" "; /* Skipp rest of arg */ break; case 'c': if (! *++pos) { if (!--*argc) goto err; else pos= *(++*argv); } number_of_commands=(ulong) atol(pos); pos=" "; break; case 'u': update=1; break; case 'f': if (! *++pos) { if (!--*argc) goto err; else pos= *(++*argv); } max_files=(uint) atoi(pos); pos=" "; break; case 'i': test_info=1; break; case 'o': if (! *++pos) { if (!--*argc) goto err; else pos= *(++*argv); } start_offset=(my_off_t) strtoll(pos,NULL,10); pos=" "; break; case 'p': if (! *++pos) { if (!--*argc) goto err; else pos= *(++*argv); } prefix_remove=atoi(pos); break; case 'r': update=1; recover++; break; case 'D': opt_myisam_with_debug=1; break; case 'P': opt_processes=1; break; case 'R': if (! *++pos) { if (!--*argc) goto err; else pos= *(++*argv); } record_pos_file=(char*) pos; if (!--*argc) goto err; record_pos=(my_off_t) strtoll(*(++*argv),NULL,10); pos=" "; break; case 'v': verbose++; break; case 'w': if (! *++pos) { if (!--*argc) goto err; else pos= *(++*argv); } write_filename=(char*) pos; pos=" "; break; case 'F': if (! *++pos) { if (!--*argc) goto err; else pos= *(++*argv); } filepath= (char*) pos; pos=" "; break; case 'V': version=1; /* Fall through */ case 'I': case '?': printf("%s Ver 1.4 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE); puts("By Monty, for your professional use\n"); if (version) break; puts("Write info about whats in a MyISAM log file."); printf("If no file name is given %s is used\n",log_filename); puts(""); printf(usage,my_progname); puts(""); puts("Options: -? or -I \"Info\" -V \"version\" -c \"do only # commands\""); puts(" -f \"max open files\" -F \"filepath\" -i \"extra info\""); puts(" -o \"offset\" -p # \"remove # components from path\""); puts(" -r \"recover\" -R \"file recordposition\""); puts(" -u \"update\" -v \"verbose\" -w \"write file\""); puts(" -D \"myisam compiled with DBUG\" -P \"processes\""); puts("\nOne can give a second and a third '-v' for more verbose."); puts("Normaly one does a update (-u)."); puts("If a recover is done all writes and all possibly updates and deletes is done\nand errors are only counted."); puts("If one gives table names as arguments only these tables will be updated\n"); help=1; break; default: printf("illegal option: \"-%c\"\n",*pos); break; } } } if (! *argc) { if (help) exit(0); (*argv)++; } if (*argc >= 1) { log_filename=(char*) pos; (*argc)--; (*argv)++; } return; err: VOID(fprintf(stderr,"option \"%c\" used without or with wrong argument\n", option)); exit(1); }
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; }
static my_bool get_one_option(int optid, const struct my_option *opt, char *argument) { my_bool add_option= TRUE; switch (optid) { case '?': printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); puts("MySQL utility for upgrading databases to new MySQL versions.\n"); my_print_help(my_long_options); exit(0); break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); add_option= FALSE; debug_check_flag= 1; break; case 'p': if (argument == disabled_my_option) argument= (char*) ""; /* Don't require password */ tty_password= 1; add_option= FALSE; if (argument) { /* Add password to ds_args before overwriting the arg with x's */ add_one_option(&ds_args, opt, argument); while (*argument) *argument++= 'x'; /* Destroy argument */ tty_password= 0; } break; case 't': strnmov(opt_tmpdir, argument, sizeof(opt_tmpdir)); add_option= FALSE; break; case 'b': /* --basedir */ case 'd': /* --datadir */ fprintf(stderr, "%s: the '--%s' option is always ignored\n", my_progname, optid == 'b' ? "basedir" : "datadir"); /* FALLTHROUGH */ case 'v': /* --verbose */ case 'f': /* --force */ add_option= FALSE; break; case 'h': /* --host */ case 'W': /* --pipe */ case 'P': /* --port */ case 'S': /* --socket */ case OPT_MYSQL_PROTOCOL: /* --protocol */ case OPT_SHARED_MEMORY_BASE_NAME: /* --shared-memory-base-name */ add_one_option(&conn_args, opt, argument); break; } if (add_option) { /* This is an option that is accpted by mysql_upgrade just so it can be passed on to "mysql" and "mysqlcheck" Save it in the ds_args string */ add_one_option(&ds_args, opt, argument); } return 0; }
//--------------------------------------------------------------------- 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); }
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); }