int main () { a = New aiod (1); a->open ("blah", O_CREAT | O_TRUNC | O_RDWR, 0666, wrap (file_open)); amain (); }
int main(int argc, char *argv[]) { if(argc != 5) fatal("Usage: filestore sockname -[fls] filename_or_hash" " num_RPCs_in_flight\n"); dhash = New dhashclient(argv[1]); chordID ID; char *cmd = argv[2]; char *name = argv[3]; maxinflight = atoi(argv[4]); if(!strcmp(cmd, "-s")) { // store store(name); } else if(!strcmp(cmd, "-l")) { // list str2chordID(name, ID); dhash->retrieve(ID, wrap(&list_cb)); } else if(!strcmp(cmd, "-f")) { // retrieve str2chordID(name, ID); dhash->retrieve(ID, wrap(&gotinode_cb)); warnx << "retrieve " << ID << "\n"; } else { fatal("Usage: filestore sockname -[fls] filename_or_hash" " num_RPCs_in_flight\n"); } amain(); return 0; }
int main (int argc, char *argv[]) { oksrvc_t *oksrvc = New oksrvc_sha_t (argc, argv); oksrvc->launch (); amain (); }
int main (int argc, char **argv) { setprogname (argv[0]); sfsconst_init (); agent_setsock (); int expires = 0; int ch; while ((ch = getopt (argc, argv, "e:")) != -1) switch (ch) { case 'e': expires = atoi (optarg); break; default: usage (argv[0]); } if (optind >= argc) usage (argv[0]); str user, host; if (!parse_userhost (argv[optind], &user, &host)) fatal << "not of form [user@]hostname\n"; sfsproac proac (expires, argv[optind], user, host); if (!proac.connect ()) exit (1); proac.register_with_agent (); amain (); }
int main (int argc, char *argv[]) { sigcb (SIGALRM, wrap (timer_event)); set_timer (); amain (); }
static PyObject * Core_amain (PyObject *self, PyObject *args) { // of course, does not return amain (); Py_INCREF (Py_None); return Py_None; }
int main (int argc, char *argv[]) { int port; if (argc != 3 || !convertint (argv[2], &port)) fatal << "usage: ex2 <hostname> <port>\n"; dostuff (argv[1], port, wrap (finish)); amain (); }
int main (int argc, char **argv) { setprogname (argv[0]); xputenv ("POSIXLY_CORRECT=1"); // Prevents Linux from reordering options sfsconst_init (); srp_base::minprimsize = sfs_mindlogsize; int ch; while ((ch = getopt (argc, argv, "S:p:vqV")) != -1) switch (ch) { case 'S': agentsock = optarg; break; case 'V': sfskey_version (); break; case 'p': { int fd; if (!convertint (optarg, &fd)) usage (); opt_pwd_fd = true; close_on_exec (fd); // Paranoia pwd_fds.push_back (fd); break; } case 'v': opt_verbose = true; break; case 'q': opt_quiet = true; break; default: usage (); break; } if (optind >= argc) usage (); const modevec *mp; for (mp = modes; mp->name; mp++) if (!strcmp (argv[optind], mp->name)) break; if (!mp->name) usage (); sfskey_mode = mp; optind++; mp->fn (argc, argv); amain (); }
int main (int argc, char** argv) { setprogname (argv[0]); random_init (); setup (); str host = "not set"; unsigned short port = 0; errfd = 1; int ch; while ((ch = getopt (argc, argv, "h:j:a:l:f:is:")) != -1) { switch (ch) { case 'j': { char *bs_port = strchr(optarg, ':'); if (!bs_port) usage (); *bs_port = 0; bs_port++; if (inet_addr (optarg) == INADDR_NONE) { //yep, this blocks struct hostent *h = gethostbyname (optarg); if (!h) { warn << "Invalid address or hostname: " << optarg << "\n"; usage (); } struct in_addr *ptr = (struct in_addr *)h->h_addr; host = inet_ntoa (*ptr); } else host = optarg; port = atoi (bs_port); break; } }; } if (host == "not set") usage (); wellknown_ID = make_chordID (host, port, 0); chord_node wellknown_node; wellknown_node.x = wellknown_ID; wellknown_node.r.hostname = host; wellknown_node.r.port = port; wellknown_node.vnode_num = 0; getsucc (wellknown_node); amain (); }
int main (int argc, char *argv[]) { setprogname (argv[0]); #ifdef HAVE_MYSQL start_server (argc, argv); amain (); #else warn << "No MySQL support; test failed!\n"; exit (1); #endif return 0; }
int main (int argc, char **argv) { setprogname (argv[0]); timetest::ctr++; for (int i = 0; i < 256; i++) New timetest (); if (!--timetest::ctr) return 0; signal (SIGALRM, timeout); alarm (15); amain (); }
int main (int argc, char **argv) { setprogname (argv[0]); char *dir = getcwd (NULL, PATH_MAX); str aiodpath (strbuf ("%s/../async/aiod", dir)); free (dir); for (int i = x; i-- > 0;) { aiod *a = New aiod (1, 0x10000, 0x10000, false, aiodpath); New refcounted<aiotst> (a); } amain (); }
int main (int argc, char **argv) { bool opt_nodaemon = false; setprogname (argv[0]); int ch; while ((ch = getopt (argc, argv, "df:S:")) != -1) switch (ch) { case 'd': opt_nodaemon = true; break; case 'f': if (configfile) usage (); configfile = optarg; break; case 'S': { str sfsconf (strbuf ("SFS_CONFIG=%s", optarg)); xputenv (const_cast<char*>(sfsconf.cstr())); } case '?': default: usage (); } argc -= optind; argv += optind; if (argc > 1) usage (); sfsconst_init (); if (!configfile) configfile = sfsconst_etcfile_required ("sfssd_config"); parseconfig (); if (!revocationdir) revocationdir = sfsdir << "srvrevoke"; if (!opt_nodaemon && !builddir) { daemonize (); sigcb (SIGINT, wrap (termsig, SIGINT)); sigcb (SIGTERM, wrap (termsig, SIGTERM)); } warn ("version %s, pid %d\n", VERSION, int (getpid ())); sigcb (SIGHUP, wrap (restart)); launchservers (); amain (); }
int main (int argc, char *argv[]) { int ch; while ((ch = getopt (argc, argv, "rm")) != -1) switch (ch) { case 'r': do_reverse_lookup = true; break; case 'm': do_accordion = true; break; default: fatal << usage; break; } argc -= optind; argv += optind; if (argc != 3) fatal << usage; chord_node dst; if (inet_addr (argv[0]) == INADDR_NONE) { // yep, this still blocks. struct hostent *h = gethostbyname (argv[0]); if (!h) fatal << "Invalid address or hostname: " << argv[0] << "\n"; struct in_addr *ptr = (struct in_addr *) h->h_addr; dst.r.hostname = inet_ntoa (*ptr); } else { dst.r.hostname = argv[0]; } dst.r.port = atoi (argv[1]); dst.vnode_num = atoi (argv[2]); dst.x = make_chordID (dst.r.hostname, dst.r.port, dst.vnode_num); print_predecessors (dst); print_successors (dst); print_fingers (dst); amain (); }
int main (int argc, char **argv) { mp_set_memory_functions (NULL, simple_realloc, NULL); str lsdsock = "/tmp/lsdctl-sock"; char ch; setprogname (argv[0]); random_init (); dbdir = "/tmp/"; while ((ch = getopt (argc, argv, "C:L:td:"))!=-1) switch (ch) { case 'C': lsdsock = optarg; break; case 'L': logfname = optarg; break; case 't': modlogger::setmaxprio (modlogger::TRACE); break; case 'd': dbdir = optarg; break; default: usage (); break; } start_logs (); sigcb(SIGHUP, wrap (&start_logs)); sigcb(SIGINT, wrap (&halt)); sigcb(SIGTERM, wrap (&halt)); ptr<aclnt> c = lsdctl_connect (lsdsock); ptr<lsdctl_lsdparameters> p = New refcounted<lsdctl_lsdparameters> (); c->timedcall (5, LSDCTL_GETLSDPARAMETERS, NULL, p, wrap (&start, p)); amain (); }
int main (int argc, char **argv) { pid_t child; int an; vec<const char *> av; char *fname = NULL; char *basename; enum { BAD, HEADER, CFILE, PYTHON, PYL, PYH, PYS } mode = BAD; void (*fn) (str) = NULL; int len; av.push_back (PATH_CPP); av.push_back ("-DRPCC"); av.push_back (NULL); for (an = 1; an < argc; an++) { char *arg = argv[an]; int arglen = strlen (arg); if (arg[0] == '-' && (arg[1] == 'D' || arg[1] == 'I')) av.push_back (arg); else if (!fname && arglen > 2 && arg[0] != '-' && arg[arglen-1] == 'x' && arg[arglen-2] == '.') fname = arg; else if (!strcmp (arg, "-h") && mode == BAD) mode = HEADER; else if (!strcmp (arg, "-c") && mode == BAD) mode = CFILE; else if (!strcmp (arg, "-python") && mode == BAD) mode = PYTHON; else if (!strcmp (arg, "-pyl") && mode == BAD) mode = PYL; else if (!strcmp (arg, "-pyh") && mode == BAD) mode = PYH; else if (!strcmp (arg, "-pys") && mode == BAD) mode = PYS; else if (!strcmp (arg, "-o") && !outfile && ++an < argc) outfile = argv[an]; else if (!strncmp (arg, "-o", 2) && !outfile && arg[2]) outfile = arg + 2; else if (!strcmp (arg, "-P") && !idprefix && ++an < argc) idprefix = argv[an]; else if (!strncmp (arg, "-P", 2) && !idprefix && arg[2]) idprefix = arg + 2; else if (!strcmp (arg, "-n") && !python_module_name && ++an < argc) python_module_name = argv[an]; else if (!strncmp (arg, "-n", 2) && !python_module_name && arg[2]) python_module_name = arg + 2; else usage (); } if (python_module_name && !(mode == PYL || mode == PYS)) { warn << "-n parameter only valid with -pyl or -pys\n"; usage (); } if (!fname) usage (); if (idprefix) idprefix = idprefix << "_"; av.push_back (fname); av.push_back (NULL); if ((basename = strrchr (fname, '/'))) basename++; else basename = fname; len = strlen (basename); switch (mode) { case HEADER: av[2] = "-DRPCC_H"; fn = genheader; if (!outfile) outfile = strbuf ("%.*sh", len - 1, basename); break; case CFILE: av[2] = "-DRPCC_C"; fn = gencfile; if (!outfile) outfile = strbuf ("%.*sC", len - 1, basename); break; case PYTHON: av[2] = "-DRPCC_P"; fn = genpython; if (!outfile) outfile = strbuf ("%.*spy", len - 1, basename); break; case PYL: av[2] = "-DRPCC_PYL"; fn = genpyc_lib; // foo.x -> foo_lib.C if (!outfile) outfile = strbuf ("%.*s_lib.C", len - 2, basename); break; case PYH: av[2] = "-DRPCC_PYH"; fn = genpyh; if (!outfile) outfile = strbuf ("%.*sh", len -1, basename); break; case PYS: av[2] = "-DRPCC_PYS"; fn = genpyc_so; // foo.x -> foo_so.C if (!outfile) outfile = strbuf ("%.*s_so.C", len -2, basename); break; default: usage (); break; } child = runcpp (av.base ()); if (outfile != "-") { if (outfile[0] != '|') atexit (cleanup); setstdout (); } make_sync (0); yyparse (); checkliterals (); if (outfile != "-" && outfile[0] != '|') fn (outfile); else fn (fname); #if 0 chldcb (child, wrap (reapcpp)); amain (); #else int status; if (waitpid (child, &status, 0) < 0) fatal ("waitpid: %m\n"); reapcpp (status); #endif return 0; }
int main (int argc, char *argv[]) { timeout = 120; noisy = false; zippity = false; srandom(time(0)); setprogname (argv[0]); int ch; int n = 1000; nconcur = 500; bool delay = false; timespec startat; startat.tv_nsec = 0; startat.tv_sec = 0; exited = false; hclient_id = 1; use_latencies = false; num_services = 1; tpt_sample_period_secs = 1; tpt_sample_period_nsecs = 0; int lat_stddv = 25; int lat_mean = 75; lose_patience_after = 0; id_cycler_t *svc_cycler = NULL; id_cycler_t *req_cycler = NULL; mode = NONE; bool no_pub = false; int tmp = 0; static rxx lose_patience_rxx ("(\\d+),(\\d+)"); while ((ch = getopt (argc, argv, "c:dlm:n:pr:t:v:zM:P:S:R:T:V:")) != -1) { switch (ch) { case 'c': if (!convertint (optarg, &nconcur)) usage (); if (noisy) warn << "Concurrency factor: " << nconcur << "\n"; break; case 'd': noisy = true; break; case 'l': use_latencies = true; if (noisy) warn << "Using Latencies\n"; break; case 'm': { switch (optarg[0]) { case 's': case 'S': mode = SEDA; if (noisy) warn << "In SEDA mode\n"; break; case 'o': case 'O': mode = OKWS; if (noisy) warn << "In OKWS mode\n"; break; case 'P': case 'p': mode = PHP; if (noisy) warn << "In PHP mode\n"; break; case 'f': case 'F': mode = FLASH; if (noisy) warn << "In FLASH mode\n"; break; default: usage (); break; } break; } case 'n': if (!convertint (optarg, &n)) usage (); if (noisy) warn << "Number of requests: " << n << "\n"; break; case 'p': no_pub = true; break; case 'r': if (!convertint (optarg, &tmp)) usage (); req_cycler = New id_cycler_t (true, tmp, 1); if (noisy) warn << "Ranging ids from 1 to " << tmp << " (randomly)\n"; break; case 't': { if (!convertint (optarg, &startat.tv_sec)) usage (); delay = true; if (noisy) warn << "Delaying start until time=" << startat.tv_sec << "\n"; time_t mytm = time (NULL); tmp = startat.tv_sec - mytm; if (tmp < 0) { warn << "time stamp alreached (it's " << mytm << " right now)!\n"; usage (); } if (noisy) { warn << "Starting in T minus " << tmp << " seconds\n"; } break; } case 'v': if (!convertint (optarg, &tmp)) usage (); svc_cycler = New id_cycler_t (true, tmp, 1); if (noisy) warn << "Randing services from 1 to " << tmp << " (randomly)\n"; break; case 'z': zippity = true; break; case 'M': if (!convertint (optarg, &lat_mean)) usage (); if (noisy) warn << "Mean of latencies: " << lat_mean << "\n"; break; case 'P': if (!convertint (optarg, &tmp)) usage (); tpt_sample_period_secs = tmp / THOUSAND; tpt_sample_period_nsecs = (tmp % THOUSAND) * MILLION; if (noisy) warn ("Sample throughput period=%d.%03d secs\n", tpt_sample_period_secs, tpt_sample_period_nsecs / MILLION); break; case 'R': req_cycler = New id_cycler_t (); if (!req_cycler->init (optarg)) usage (); break; case 'S': if (!convertint (optarg, &lat_stddv)) usage (); if (noisy) warn << "Standard dev. of latency: " << lat_stddv << "\n"; break; case 'T': if (!lose_patience_rxx.match (optarg) || !convertint (lose_patience_rxx[1], &n_still_patient) || !convertint (lose_patience_rxx[2], &lose_patience_after)) usage (); break; case 'V': svc_cycler = New id_cycler_t (); if (!svc_cycler->init (optarg)) usage (); break; default: usage (); } } argc -= optind; argv += optind; if (argc == 0) usage (); str dest = argv[0]; argc --; argv ++; // make the appropriate cyclers... if (argc > 0) { // in this case, the user supplied extra arguments after the hostname // and port; therefore, they're going to be making their own URL // by alternating static parts and cyclers. if (req_cycler) { warn << "Don't provide -r if you're going to make your own URI\n"; usage (); } if (svc_cycler) { warn << "Don't provide -v if you're going to make your own URI\n"; usage (); } for (int i = 0; i < argc; i++) { if (i % 2 == 0) { uri_parts.push_back (argv[i]); } else { id_cycler_t *tmp = New id_cycler_t (); if (!tmp->init (argv[i])) { warn << "Cannot parse ID cycler: " << argv[i] << "\n"; usage (); } id_cyclers.push_back (tmp); } } } else if (mode != NONE) { // no manual URL building required; just specify some defaults // though if none were specified if (!req_cycler) // roughly a million, but this way all reqs will have the same // number of digits req_cycler = New id_cycler_t (true, 900000, 100000); if (!svc_cycler) // don't cycle --- just always return 1 svc_cycler = New id_cycler_t (false, 1, 1); id_cyclers.push_back (svc_cycler); id_cyclers.push_back (req_cycler); switch (mode) { case SEDA: uri_parts.push_back ("mt"); uri_parts.push_back ("?id="); break; case OKWS: { uri_parts.push_back ("mt"); strbuf b ("?"); if (no_pub) b << "nopub=1&"; b << "id="; uri_parts.push_back (b); break; } case PHP: uri_parts.push_back ("mt"); uri_parts.push_back (".php?id="); break; case FLASH: uri_parts.push_back ("cgi-bin/mt"); uri_parts.push_back ("?"); break; default: break; } } // normdist (mean, std-dev, "precision") if (use_latencies) dist = New normdist_t (200,25); if (!hostport.match (dest)) usage (); host = hostport[1]; str port_s = hostport[3]; if (port_s) { if (!convertint (port_s, &port)) usage (); } else { port = 80; } struct timespec tsnow = sfs_get_tsnow (); // unless we don this, shit won't be initialized, and i'll // starting ripping my hair out as to why all of the timestamps // are negative clock_gettime (CLOCK_REALTIME, &tsnow); nrunning = 0; sdflag = true; nreq = n; nreq_fixed = n; tpt_last_nreq = nreq; if (delay) { timecb (startat, wrap (main2, n)); } else { main2 (n); } amain (); }
int main (int argc, char** argv) { setprogname (argv[0]); str host = "not set"; unsigned short port (0); unsigned int maxtime (0); int ch; while ((ch = getopt (argc, argv, "j:rt:v")) != -1) { switch (ch) { case 'j': { char *bs_port = strchr(optarg, ':'); if (!bs_port) usage (); *bs_port = 0; bs_port++; if (inet_addr (optarg) == INADDR_NONE) { //yep, this blocks struct hostent *h = gethostbyname (optarg); if (!h) { warn << "Invalid address or hostname: " << optarg << "\n"; usage (); } struct in_addr *ptr = (struct in_addr *)h->h_addr; host = inet_ntoa (*ptr); } else host = optarg; port = atoi (bs_port); break; } case 't': maxtime = atoi (optarg); break; case 'v': verify = true; break; case 'r': succproc = CHORDPROC_GETPRED_EXT; break; default: usage (); break; } } if (host == "not set") usage (); wellknown_ID = make_chordID (host, port, 0); chord_node wellknown_node; wellknown_node.x = wellknown_ID; wellknown_node.r.hostname = host; wellknown_node.r.port = port; wellknown_node.vnode_num = 0; sequential.push_back (wellknown_node); getsucc (wellknown_node); if (maxtime > 0) delaycb (maxtime, wrap (&timedout, maxtime)); amain (); }