int main(int argc, const char **argv) { struct ptbf *ret; int debugging = 0; xmlNodePtr root_node; xmlDocPtr doc; xmlNodePtr comment; xmlNodePtr fonts; xmlDtdPtr dtd; int c, i, musicxml = 0; int version = 0; const char *input = NULL; char *output = NULL; poptContext pc; int quiet = 0; int format_output = 1; struct poptOption options[] = { POPT_AUTOHELP {"debug", 'd', POPT_ARG_NONE, &debugging, 0, "Turn on debugging output" }, {"outputfile", 'o', POPT_ARG_STRING, &output, 0, "Write to specified file", "FILE" }, {"musicxml", 'm', POPT_ARG_NONE, &musicxml, 'm', "Output MusicXML" }, {"no-format", 'f', POPT_ARG_NONE, &format_output, 0, "Don't format output" }, {"quiet", 'q', POPT_ARG_NONE, &quiet, 1, "Be quiet (no output to stderr)" }, {"version", 'v', POPT_ARG_NONE, &version, 'v', "Show version information" }, POPT_TABLEEND }; pc = poptGetContext(argv[0], argc, argv, options, 0); poptSetOtherOptionHelp(pc, "file.ptb"); while((c = poptGetNextOpt(pc)) >= 0) { switch(c) { case 'v': printf("ptb2xml Version "PACKAGE_VERSION"\n"); printf("(C) 2004-2006 Jelmer Vernooij <*****@*****.**>\n"); exit(0); break; } } ptb_set_debug(debugging); if(!poptPeekArg(pc)) { poptPrintUsage(pc, stderr, 0); return -1; } input = poptGetArg(pc); if (!quiet) fprintf(stderr, "Parsing %s...\n", input); ret = ptb_read_file(input); if(!ret) { perror("Read error: "); return -1; } if(!output) { int baselength = strlen(input); if (!strcmp(input + strlen(input) - 4, ".ptb")) { baselength -= 4; } output = malloc(baselength + 6); strncpy(output, input, baselength); strcpy(output + baselength, ".xml"); } if (!quiet) fprintf(stderr, "Building DOM tree...\n"); doc = xmlNewDoc(BAD_CAST "1.0"); root_node = xmlNewNode(NULL, BAD_CAST "powertab"); dtd = xmlCreateIntSubset(doc, "powertab", NULL, DTD_URL); xmlDocSetRootElement(doc, root_node); comment = xmlNewComment("\nGenerated by ptb2xml, part of ptabtools. \n" "(C) 2004-2006 by Jelmer Vernooij <*****@*****.**>\n" "See http://jelmer.vernstok.nl/oss/ptabtools/ for details\n"); xmlAddChild(root_node, comment); xmlAddChild(root_node, xml_write_header(&ret->hdr)); for(i = 0; i < 2; i++) { xmlAddChild(root_node, xml_write_instrument(ret, i)); } fonts = xmlNewNode( NULL, "fonts"); xmlAddChild(root_node, fonts); xmlAddChild(fonts, xml_write_font("default_font", &ret->default_font)); xmlAddChild(fonts, xml_write_font("chord_name_font", &ret->chord_name_font)); xmlAddChild(fonts, xml_write_font("tablature_font", &ret->tablature_font)); if (musicxml) { if (!quiet) fprintf(stderr, "Converting to MusicXML...\n"); #ifdef HAVE_XSLT xsltStylesheetPtr stylesheet = xsltParseStylesheetFile(MUSICXMLSTYLESHEET); doc = xsltApplyStylesheet(stylesheet, doc, NULL); xsltFreeStylesheet(stylesheet); #else fprintf(stderr, "Conversion to MusicXML not possible in this version: libxslt not compiled in\n"); return -1; #endif } if (!quiet) fprintf(stderr, "Writing output to %s...\n", output); if (xmlSaveFormatFile(output, doc, format_output) < 0) { return -1; } xmlFreeDoc(doc); xmlCleanupParser(); return 0; }
/** * Program entry point * * @param argc Number of argv elements * @param argv Program name and arguments * @param envp Program environment * @return <i>0</i> Success * @return <br><i>254</i> Initialization failed */ int main(int argc, char **argv, char **envp) { bk_s B = NULL; /* Baka general structure */ BK_ENTRY_MAIN(B, __FUNCTION__, __FILE__, "SIMPLE"); int c; int getopterr = 0; int debug_level = 0; char i18n_localepath[_POSIX_PATH_MAX]; char *i18n_locale; struct program_config Pconfig, *pc = NULL; poptContext optCon = NULL; struct poptOption optionsTable[] = { {"debug", 'd', POPT_ARG_NONE, NULL, 'd', N_("Turn on debugging"), NULL }, {"verbose", 'v', POPT_ARG_NONE, NULL, 'v', N_("Turn on verbose message"), NULL }, {"no-seatbelts", 0, POPT_ARG_NONE, NULL, 0x1000, N_("Sealtbelts off & speed up"), NULL }, {"seatbelts", 0, POPT_ARG_NONE, NULL, 0x1001, N_("Enable function tracing"), NULL }, {"profiling", 0, POPT_ARG_STRING, NULL, 0x1002, N_("Enable and write profiling data"), N_("filename") }, {"source", 0, POPT_ARG_INT, NULL, 0x100, N_("Source fake data to remote side"), N_("number of i/o buffers") }, {"sink", 0, POPT_ARG_NONE, NULL, 0x101, N_("Sink/discard data from remote side"), NULL }, {"write", 'w', POPT_ARG_NONE, NULL, 'w', N_("Write side of cat (otherwise is read side)"), NULL }, {"rendezvous", 'r', POPT_ARG_STRING, NULL, 'r', N_("Shared memory rendezvous name"), N_("name") }, {"timeout", 't', POPT_ARG_INT, NULL, 't', N_("Timeout"), N_("microseconds") }, {"poll", 'p', POPT_ARG_INT, NULL, 'p', N_("How often to check for activity"), N_("microseconds") }, {"length", 'l', POPT_ARG_INT, NULL, 'l', N_("Size of shared memory buffer"), N_("bytes") }, {"size", 's', POPT_ARG_INT, NULL, 's', N_("Size of i/o memory buffer"), N_("bytes") }, POPT_AUTOHELP POPT_TABLEEND }; if (!(B=bk_general_init(argc, &argv, &envp, BK_ENV_GWD(NULL, "BK_ENV_CONF_APP", BK_APP_CONF), NULL, ERRORQUEUE_DEPTH, LOG_LOCAL0, 0))) { fprintf(stderr,"Could not perform basic initialization\n"); exit(254); } bk_fun_reentry(B); // Enable error output bk_error_config(B, BK_GENERAL_ERROR(B), ERRORQUEUE_DEPTH, stderr, BK_ERR_ERR, BK_ERR_ERR, BK_ERROR_CONFIG_FH | BK_ERROR_CONFIG_SYSLOGTHRESHOLD | BK_ERROR_CONFIG_HILO_PIVOT); // i18n stuff setlocale(LC_ALL, ""); if (!(i18n_locale = BK_GWD(B, STD_LOCALEDIR_KEY, NULL))) { i18n_locale = i18n_localepath; snprintf(i18n_localepath, sizeof(i18n_localepath), "%s/%s", BK_ENV_GWD(B, STD_LOCALEDIR_ENV,STD_LOCALEDIR_DEF), STD_LOCALEDIR_SUB); } bindtextdomain(BK_GENERAL_PROGRAM(B), i18n_locale); textdomain(BK_GENERAL_PROGRAM(B)); for (c = 0; optionsTable[c].longName || optionsTable[c].shortName; c++) { if (optionsTable[c].descrip) (*((char **)&(optionsTable[c].descrip)))=_(optionsTable[c].descrip); if (optionsTable[c].argDescrip) (*((char **)&(optionsTable[c].argDescrip)))=_(optionsTable[c].argDescrip); } pc = &Pconfig; memset(pc, 0, sizeof(*pc)); pc->pc_size = 4096; BK_FLAG_SET(pc->pc_flags, PC_RDONLY); if (!(optCon = poptGetContext(NULL, argc, (const char **)argv, optionsTable, 0))) { bk_error_printf(B, BK_ERR_ERR, "Could not initialize options processing\n"); bk_exit(B, 254); } while ((c = poptGetNextOpt(optCon)) >= 0) { switch (c) { case 'd': // debug if (!debug_level) { // Set up debugging, from config file bk_general_debug_config(B, stderr, BK_ERR_NONE, 0); bk_debug_printf(B, "Debugging on\n"); debug_level++; } else if (debug_level == 1) { /* * Enable output of error and higher error logs (this can be * annoying so require -dd) */ bk_error_config(B, BK_GENERAL_ERROR(B), 0, stderr, BK_ERR_NONE, BK_ERR_ERR, BK_ERROR_CONFIG_FH | BK_ERROR_CONFIG_HILO_PIVOT | BK_ERROR_CONFIG_SYSLOGTHRESHOLD); bk_debug_printf(B, "Extra debugging on\n"); debug_level++; } else if (debug_level == 2) { /* * Enable output of all levels of bk_error logs (this can be * very annoying so require -ddd) */ bk_error_config(B, BK_GENERAL_ERROR(B), 0, stderr, BK_ERR_NONE, BK_ERR_DEBUG, BK_ERROR_CONFIG_FH | BK_ERROR_CONFIG_HILO_PIVOT | BK_ERROR_CONFIG_SYSLOGTHRESHOLD); bk_debug_printf(B, "Super-extra debugging on\n"); debug_level++; } break; case 'v': // verbose BK_FLAG_SET(pc->pc_flags, PC_VERBOSE); bk_error_config(B, BK_GENERAL_ERROR(B), ERRORQUEUE_DEPTH, stderr, BK_ERR_NONE, BK_ERR_ERR, 0); break; case 0x1000: // no-seatbelts BK_FLAG_CLEAR(BK_GENERAL_FLAGS(B), BK_BGFLAGS_FUNON); break; case 0x1001: // seatbelts BK_FLAG_SET(BK_GENERAL_FLAGS(B), BK_BGFLAGS_FUNON); break; case 0x1002: // profiling bk_general_funstat_init(B, (char *)poptGetOptArg(optCon), 0); break; default: getopterr++; break; case 0x100: // source pc->pc_sourcebufs = bk_string_demagnify(B, poptGetOptArg(optCon), 0); break; case 0x101: // sink BK_FLAG_SET(pc->pc_flags, PC_SINK); break; case 'w': // write-side BK_FLAG_CLEAR(pc->pc_flags, PC_RDONLY); break; case 'r': // rendezvous name pc->pc_filename = poptGetOptArg(optCon); break; case 't': // timeout usec pc->pc_timeout = bk_string_demagnify(B, poptGetOptArg(optCon), 0); break; case 'p': // poll usec pc->pc_poll = bk_string_demagnify(B, poptGetOptArg(optCon), 0); break; case 'l': // shmem length pc->pc_length = bk_string_demagnify(B, poptGetOptArg(optCon), 0); break; case 's': // i/o size pc->pc_size = bk_string_demagnify(B, poptGetOptArg(optCon), 0); break; } } /* * Reprocess so that argc and argv contain the remaining command * line arguments (note argv[0] is an argument, not the program * name). argc remains the number of elements in the argv array. */ argv = (char **)poptGetArgs(optCon); argc = 0; if (argv) for (; argv[argc]; argc++) ; // Void if (c < -1 || getopterr || !pc->pc_filename) { if (c < -1) { fprintf(stderr, "%s\n", poptStrerror(c)); } poptPrintUsage(optCon, stderr, 0); bk_exit(B, 254); } if (proginit(B, pc) < 0) { bk_die(B, 254, stderr, _("Could not perform program initialization\n"), BK_FLAG_ISSET(pc->pc_flags, PC_VERBOSE)?BK_WARNDIE_WANTDETAILS:0); } if (progrun(B, pc) < 0) { bk_die(B, 254, stderr, _("Could not run\n"), BK_FLAG_ISSET(pc->pc_flags, PC_VERBOSE)?BK_WARNDIE_WANTDETAILS:0); } poptFreeContext(optCon); bk_exit(B, 0); return(255); // Stupid INSIGHT stuff. }
int main(int argc, const char *argv[]) { int ret; int opt; poptContext pc; int number_failed; tests_set_cwd(); struct poptOption long_options[] = { POPT_AUTOHELP SSSD_MAIN_OPTS POPT_TABLEEND }; /* Set debug level to invalid value so we can deside if -d 0 was used. */ debug_level = SSSDBG_INVALID; pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { default: fprintf(stderr, "\nInvalid option %s: %s\n\n", poptBadOption(pc, 0), poptStrerror(opt)); poptPrintUsage(pc, stderr, 0); return 1; } } poptFreeContext(pc); CONVERT_AND_SET_DEBUG_LEVEL(debug_level); ret = mkdir(TESTS_PATH, 0775); if (ret != EOK) { fprintf(stderr, "Could not create empty directory [%s]. ", TESTS_PATH); if (errno == EEXIST) { fprintf(stderr, "Please remove [%s].\n", TESTS_PATH); } else { fprintf(stderr, "[%d][%s].\n", errno, strerror(errno)); } return 1; } Suite *s = krb5_utils_suite (); SRunner *sr = srunner_create (s); /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */ srunner_run_all(sr, CK_ENV); number_failed = srunner_ntests_failed (sr); srunner_free (sr); if (number_failed == 0) { ret = rmdir(TESTS_PATH); if (ret != EOK) { fprintf(stderr, "Cannot remove [%s]: [%d][%s].\n", TESTS_PATH, errno, strerror(errno)); return EXIT_FAILURE; } return EXIT_SUCCESS; } return EXIT_FAILURE; }
int main(int argc, const char ** argv) /*@globals pass2, fileSystem, internalState @*/ /*@modifies pass2, fileSystem, internalState @*/ { int rc; int ec = 0; poptContext optCon; const char ** rest; int help = 0; int usage = 0; #if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE) /*@-moduncon -noeffectuncon@*/ mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */ /*@=moduncon =noeffectuncon@*/ #endif /*@-modobserver@*/ resetVars(); /*@=modobserver@*/ /*@-temptrans@*/ optCon = poptGetContext("test1", argc, argv, options, 0); /*@=temptrans@*/ (void) poptReadConfigFile(optCon, "./test-poptrc"); (void) poptReadDefaultConfig(optCon, 1); poptSetExecPath(optCon, ".", 1); #if 1 while ((rc = poptGetNextOpt(optCon)) > 0) /* Read all the options ... */ {}; poptResetContext(optCon); /* ... and then start over. */ /*@-modobserver@*/ resetVars(); /*@=modobserver@*/ #endif pass2 = 1; if ((rc = poptGetNextOpt(optCon)) < -1) { fprintf(stderr, "test1: bad argument %s: %s\n", poptBadOption(optCon, POPT_BADOPTION_NOALIAS), poptStrerror(rc)); ec = 2; goto exit; } if (help) { poptPrintHelp(optCon, stdout, 0); goto exit; } if (usage) { poptPrintUsage(optCon, stdout, 0); goto exit; } fprintf(stdout, "arg1: %d arg2: %s", arg1, arg2); if (arg3) fprintf(stdout, " arg3: %d", arg3); if (inc) fprintf(stdout, " inc: %d", inc); if (shortopt) fprintf(stdout, " short: %d", shortopt); if (aVal != bVal) fprintf(stdout, " aVal: %d", aVal); if (aFlag != bFlag) fprintf(stdout, " aFlag: 0x%x", aFlag); if (aShort != bShort) fprintf(stdout, " aShort: %hd", aShort); if (aInt != bInt) fprintf(stdout, " aInt: %d", aInt); if (aLong != bLong) fprintf(stdout, " aLong: %ld", aLong); if (aLongLong != bLongLong) fprintf(stdout, " aLongLong: %lld", aLongLong); /*@-realcompare@*/ if (aFloat != bFloat) fprintf(stdout, " aFloat: %g", (double)aFloat); if (aDouble != bDouble) fprintf(stdout, " aDouble: %g", aDouble); /*@=realcompare@*/ if (aArgv != NULL) { const char **av = aArgv; const char * arg; fprintf(stdout, " aArgv:"); while ((arg = *av++) != NULL) fprintf(stdout, " %s", arg); } if (aBits) { const char * separator = " "; size_t i; fprintf(stdout, " aBits:"); for (i = 0; i < nattributes; i++) { if (!poptBitsChk(aBits, attributes[i])) continue; fprintf(stdout, "%s%s", separator, attributes[i]); separator = ","; } } /*@-nullpass@*/ if (oStr != (char *)-1) fprintf(stdout, " oStr: %s", (oStr ? oStr : "(none)")); /*@=nullpass@*/ if (singleDash) fprintf(stdout, " -"); if (poptPeekArg(optCon) != NULL) { rest = poptGetArgs(optCon); if (rest) { fprintf(stdout, " rest:"); while (*rest) { fprintf(stdout, " %s", *rest); rest++; } } } fprintf(stdout, "\n"); exit: optCon = poptFreeContext(optCon); #if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE) /*@-moduncon -noeffectuncon@*/ muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */ /*@=moduncon =noeffectuncon@*/ #endif return ec; }
/* Read the command line arguments, and do the inital parsing of the parameter file. */ static mwbool readParameters(const int argc, const char* argv[], NBodyFlags* nbf) { int argRead; poptContext context; const char** rest = NULL; /* Leftover arguments */ mwbool failed = FALSE; unsigned int numParams = 0, params = 0; /* FIXME: There's a small leak of the inputFile from use of poptGetNextOpt(). Some mailing list post suggestst that this is some kind of semi-intended bug to work around something or other */ const struct poptOption options[] = { { "input-file", 'f', POPT_ARG_STRING, &nbf->inputFile, 0, "Input Lua file to read", NULL }, { "histoout-file", 'z', POPT_ARG_STRING, &nbf->histoutFileName, 0, "Output histogram file", NULL }, { "histogram-file", 'h', POPT_ARG_STRING, &nbf->histogramFileName, 0, "Histogram file", NULL }, { "output-file", 'o', POPT_ARG_STRING, &nbf->outFileName, 0, "Output file", NULL }, { "output-cartesian", 'x', POPT_ARG_NONE, &nbf->outputCartesian, 0, "Output Cartesian coordinates instead of lbR", NULL }, { "timing", 't', POPT_ARG_NONE, &nbf->printTiming, 0, "Print timing of actual run", NULL }, { "verify-file", 'v', POPT_ARG_NONE, &nbf->verifyOnly, 0, "Check that the input file is valid only; perform no calculation.", NULL }, { "checkpoint", 'c', POPT_ARG_STRING, &nbf->checkpointFileName, 0, "Checkpoint file to use", NULL }, { "clean-checkpoint", 'k', POPT_ARG_NONE, &nbf->cleanCheckpoint, 0, "Cleanup checkpoint after finishing run", NULL }, { "checkpoint-interval", 'w', POPT_ARG_INT, &nbf->checkpointPeriod, 0, "Period (in seconds) to checkpoint. -1 to disable", NULL }, { "debug-boinc", 'g', POPT_ARG_NONE, &nbf->debugBOINC, 0, "Init BOINC with debugging. No effect if not built with BOINC_APPLICATION", NULL }, { "lua-debug-libraries", 'a', POPT_ARG_NONE, &nbf->debugLuaLibs, 0, "Load extra Lua libraries not normally allowed (e.g. io) ", NULL }, { "visualizer", 'u', POPT_ARG_NONE, &nbf->visualizer, 0, "Try to run N-body visualization", NULL }, { "visualizer-args", '\0', POPT_ARG_STRING, &nbf->visArgs, 0, "Command line to pass on to visualizer", NULL }, { "ignore-checkpoint", 'i', POPT_ARG_NONE, &nbf->ignoreCheckpoint, 0, "Ignore the checkpoint file", NULL }, { "print-bodies", 'b', POPT_ARG_NONE, &nbf->printBodies, 0, "Print bodies", NULL }, { "print-histogram", 'm', POPT_ARG_NONE, &nbf->printHistogram, 0, "Print histogram", NULL }, #ifdef _OPENMP { "nthreads", 'n', POPT_ARG_INT, &nbf->numThreads, 0, "BOINC argument for number of threads", NULL }, #endif /* _OPENMP */ { "p", 'p', POPT_ARG_NONE, ¶ms, 0, "Unused dummy argument to satisfy primitive arguments the server sends", NULL }, { "np", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &numParams, 0, "Unused dummy argument to satisfy primitive arguments the server sends", NULL }, { "seed", 'e', POPT_ARG_INT, &nbf->setSeed, 'e', "seed for PRNG", NULL }, POPT_AUTOHELP POPT_TABLEEND }; context = poptGetContext(argv[0], argc, argv, options, 0); if (argc < 2) { poptPrintUsage(context, stderr, 0); poptFreeContext(context); return TRUE; } /* Check for invalid options, and must have the input file or a * checkpoint to resume from */ argRead = mwReadArguments(context); if (argRead < 0 || (!nbf->inputFile && !nbf->checkpointFileName)) { poptPrintHelp(context, stderr, 0); failed = TRUE; } rest = poptGetArgs(context); if ((params || numParams) && !rest) { warn("Expected arguments to follow, got 0\n"); failed = TRUE; } else { setForwardedArguments(nbf, rest); } poptFreeContext(context); return failed; }
static int seed_init(TALLOC_CTX *mem_ctx, const int argc, const char **argv, struct seed_ctx **_sctx) { TALLOC_CTX *tmp_ctx = NULL; int pc_debug = SSSDBG_DEFAULT; const char *pc_domain = NULL; const char *pc_name = NULL; uid_t pc_uid = 0; gid_t pc_gid = 0; const char *pc_gecos = NULL; const char *pc_home = NULL; const char *pc_shell = NULL; const char *pc_password_file = NULL; struct seed_ctx *sctx = NULL; int ret = EOK; poptContext pc = NULL; struct poptOption options[] = { POPT_AUTOHELP { "debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, &pc_debug, 0, _("The debug level to run with"), NULL }, { "domain", 'D', POPT_ARG_STRING, &pc_domain, 0, _("Domain"), NULL }, { "username", 'n', POPT_ARG_STRING, &pc_name, 0, _("Username"), NULL}, { "uid", 'u', POPT_ARG_INT, &pc_uid, 0, _("User UID"), NULL }, { "gid", 'g', POPT_ARG_INT, &pc_gid, 0, _("User GID"), NULL }, { "gecos", 'c', POPT_ARG_STRING, &pc_gecos, 0, _("Comment string"), NULL}, { "home", 'h', POPT_ARG_STRING, &pc_home, 0, _("Home directory"), NULL }, { "shell", 's', POPT_ARG_STRING, &pc_shell, 0, _("Login Shell"), NULL }, { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', _("Use interactive mode to enter user data"), NULL }, { "password-file", 'p', POPT_ARG_STRING, &pc_password_file, 0, _("File from which user's password is read " "(default is to prompt for password)"),NULL }, POPT_TABLEEND }; /* init contexts */ tmp_ctx = talloc_new(NULL); if (tmp_ctx == NULL) { ret = ENOMEM; goto fini; } sctx = talloc_zero(tmp_ctx, struct seed_ctx); if (sctx == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, ("Could not allocate tools context\n")); ret = ENOMEM; goto fini; } sctx->uctx = talloc_zero(sctx, struct user_ctx); if (sctx->uctx == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, ("Could not allocate user data context\n")); ret = ENOMEM; goto fini; } debug_prg_name = argv[0]; ret = set_locale(); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("set_locale failed (%d): %s\n", ret, strerror(ret))); ERROR("Error setting the locale\n"); ret = EINVAL; goto fini; } /* parse arguments */ pc = poptGetContext(NULL, argc, argv, options, 0); if (argc < 2) { poptPrintUsage(pc,stderr,0); ret = EINVAL; goto fini; } poptSetOtherOptionHelp(pc, "[OPTIONS] -D <domain> -n <username>"); while ((ret = poptGetNextOpt(pc)) > 0) { switch (ret) { case 'i': DEBUG(SSSDBG_TRACE_INTERNAL, ("Interactive mode selected\n")); sctx->interact = true; break; } } if (ret != -1) { BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } DEBUG_INIT(pc_debug); CHECK_ROOT(ret, argv[0]); /* check username provided */ if (pc_name == NULL) { BAD_POPT_PARAMS(pc, _("Username must be specified\n"), ret, fini); } sctx->uctx->name = talloc_strdup(sctx->uctx, pc_name); if (sctx->uctx->name == NULL) { ret = ENOMEM; goto fini; } /* check domain is provided */ if (pc_domain == NULL) { BAD_POPT_PARAMS(pc, _("Domain must be specified.\n"), ret, fini); } sctx->uctx->domain_name = talloc_strdup(sctx->uctx, pc_domain); if (sctx->uctx->domain_name == NULL) { ret = ENOMEM; goto fini; } poptFreeContext(pc); ret = EOK; /* copy all information provided from popt */ sctx->uctx->uid = pc_uid; sctx->uctx->gid = pc_gid; if (pc_gecos != NULL) { sctx->uctx->gecos = talloc_strdup(sctx->uctx, pc_gecos); if (sctx->uctx->gecos == NULL) { ret = ENOMEM; goto fini; } } if (pc_home != NULL) { sctx->uctx->home = talloc_strdup(sctx->uctx, pc_home); if (sctx->uctx->home == NULL) { ret = ENOMEM; goto fini; } } if (pc_shell != NULL) { sctx->uctx->shell = talloc_strdup(sctx->uctx, pc_shell); if (sctx->uctx->shell == NULL) { ret = ENOMEM; goto fini; } } /* check if password file provided */ if (pc_password_file != NULL) { sctx->password_file = talloc_strdup(sctx, pc_password_file); if (sctx->password_file == NULL) { ret = ENOMEM; goto fini; } sctx->password_method = PASS_FILE; } else { sctx->password_method = PASS_PROMPT; } *_sctx = talloc_steal(mem_ctx, sctx); fini: talloc_free(tmp_ctx); return ret; }
/** * Program entry point * * @param argc Number of argv elements * @param argv Program name and arguments * @param envp Program environment * @return <i>0</i> Success * @return <br><i>254</i> Initialization failed */ int main(int argc, char **argv, char **envp) { bk_s B = NULL; /* Baka general structure */ BK_ENTRY_MAIN(B, __FUNCTION__, __FILE__, "test-stats"); int c; int getopterr = 0; int debug_level = 0; char i18n_localepath[_POSIX_PATH_MAX]; char *i18n_locale; struct program_config Pconfig, *pc = NULL; poptContext optCon = NULL; struct poptOption optionsTable[] = { {"debug", 'd', POPT_ARG_NONE, NULL, 'd', N_("Turn on debugging"), NULL }, {"verbose", 'v', POPT_ARG_NONE, NULL, 'v', N_("Turn on verbose message"), NULL }, {"no-seatbelts", 0, POPT_ARG_NONE, NULL, 0x1000, N_("Sealtbelts off & speed up"), NULL }, {"seatbelts", 0, POPT_ARG_NONE, NULL, 0x1001, N_("Enable function tracing"), NULL }, {"profiling", 0, POPT_ARG_STRING, NULL, 0x1002, N_("Enable and write profiling data"), N_("filename") }, {"long-arg-only", 0, POPT_ARG_NONE, NULL, 1, N_("An example of a long argument without a shortcut"), NULL }, {NULL, 's', POPT_ARG_NONE, NULL, 2, N_("An example of a short argument without a longcut"), NULL }, POPT_AUTOHELP POPT_TABLEEND }; if (!(B=bk_general_init(argc, &argv, &envp, BK_ENV_GWD(NULL, "BK_ENV_CONF_APP", BK_APP_CONF), NULL, ERRORQUEUE_DEPTH, LOG_LOCAL0, 0))) { fprintf(stderr,"Could not perform basic initialization\n"); exit(254); } bk_fun_reentry(B); // Enable error output bk_error_config(B, BK_GENERAL_ERROR(B), ERRORQUEUE_DEPTH, stderr, BK_ERR_ERR, BK_ERR_ERR, BK_ERROR_CONFIG_FH | BK_ERROR_CONFIG_SYSLOGTHRESHOLD | BK_ERROR_CONFIG_HILO_PIVOT); // i18n stuff setlocale(LC_ALL, ""); if (!(i18n_locale = BK_GWD(B, STD_LOCALEDIR_KEY, NULL))) { i18n_locale = i18n_localepath; snprintf(i18n_localepath, sizeof(i18n_localepath), "%s/%s", BK_ENV_GWD(B, STD_LOCALEDIR_ENV,STD_LOCALEDIR_DEF), STD_LOCALEDIR_SUB); } bindtextdomain(BK_GENERAL_PROGRAM(B), i18n_locale); textdomain(BK_GENERAL_PROGRAM(B)); for (c = 0; optionsTable[c].longName || optionsTable[c].shortName; c++) { if (optionsTable[c].descrip) (*((char **)&(optionsTable[c].descrip)))=_(optionsTable[c].descrip); if (optionsTable[c].argDescrip) (*((char **)&(optionsTable[c].argDescrip)))=_(optionsTable[c].argDescrip); } pc = &Pconfig; memset(pc, 0, sizeof(*pc)); if (!(optCon = poptGetContext(NULL, argc, (const char **)argv, optionsTable, 0))) { bk_error_printf(B, BK_ERR_ERR, "Could not initialize options processing\n"); bk_exit(B, 254); } poptSetOtherOptionHelp(optCon, _("[NON-FLAG ARGUMENTS]")); while ((c = poptGetNextOpt(optCon)) >= 0) { switch (c) { case 'd': // debug if (!debug_level) { // Set up debugging, from config file bk_general_debug_config(B, stderr, BK_ERR_NONE, 0); bk_debug_printf(B, "Debugging on\n"); debug_level++; } else if (debug_level == 1) { /* * Enable output of error and higher error logs (this can be * annoying so require -dd) */ bk_error_config(B, BK_GENERAL_ERROR(B), 0, stderr, BK_ERR_NONE, BK_ERR_ERR, BK_ERROR_CONFIG_FH | BK_ERROR_CONFIG_HILO_PIVOT | BK_ERROR_CONFIG_SYSLOGTHRESHOLD); bk_debug_printf(B, "Extra debugging on\n"); debug_level++; } else if (debug_level == 2) { /* * Enable output of all levels of bk_error logs (this can be * very annoying so require -ddd) */ bk_error_config(B, BK_GENERAL_ERROR(B), 0, stderr, BK_ERR_NONE, BK_ERR_DEBUG, BK_ERROR_CONFIG_FH | BK_ERROR_CONFIG_HILO_PIVOT | BK_ERROR_CONFIG_SYSLOGTHRESHOLD); bk_debug_printf(B, "Super-extra debugging on\n"); debug_level++; } break; case 'v': // verbose BK_FLAG_SET(pc->pc_flags, PC_VERBOSE); bk_error_config(B, BK_GENERAL_ERROR(B), ERRORQUEUE_DEPTH, stderr, BK_ERR_NONE, BK_ERR_ERR, 0); break; case 0x1000: // no-seatbelts BK_FLAG_CLEAR(BK_GENERAL_FLAGS(B), BK_BGFLAGS_FUNON); break; case 0x1001: // seatbelts BK_FLAG_SET(BK_GENERAL_FLAGS(B), BK_BGFLAGS_FUNON); break; case 0x1002: // profiling bk_general_funstat_init(B, (char *)poptGetOptArg(optCon), 0); break; default: getopterr++; break; case 1: // long-arg-only printf("You specificed the long-arg-only option\n"); break; case 2: // s printf("You specificed the short only option\n"); break; } } /* * Reprocess so that argc and argv contain the remaining command * line arguments (note argv[0] is an argument, not the program * name). argc remains the number of elements in the argv array. */ argv = (char **)poptGetArgs(optCon); argc = 0; if (argv) for (; argv[argc]; argc++) ; // Void if (c < -1 || getopterr) { if (c < -1) { fprintf(stderr, "%s\n", poptStrerror(c)); } poptPrintUsage(optCon, stderr, 0); bk_exit(B, 254); } if (proginit(B, pc, argc, argv) < 0) { bk_die(B, 254, stderr, _("Could not perform program initialization\n"), BK_FLAG_ISSET(pc->pc_flags, PC_VERBOSE)?BK_WARNDIE_WANTDETAILS:0); } progrun(B, pc); poptFreeContext(optCon); bk_exit(B, 0); return(255); // Stupid INSIGHT stuff. }
int main(int argc, char *argv[]) { char * context =NULL; int c; const char * name; int val = 0; int token; long qmode = 0; int showprefix; poptContext optcon; #define QMODE_LIST (1 << 0) #define QMODE_SET (1 << 1) #define QMODE_REVERSE (1 << 2) #define QMODE_SHOWPREFIX (1 << 3) struct poptOption optionstable[] = { { "context", 'c', POPT_ARG_STRING, &context, 1, "Set context of search", "Context" }, { "list-context", 'l', POPT_BIT_SET, &qmode, QMODE_LIST, "list available table", "List" }, { "set", 's', POPT_BIT_SET, &qmode, QMODE_SET, "Show the value for all flag", NULL }, { "reverse", 'r', POPT_BIT_SET, &qmode, QMODE_REVERSE, "Make a reverse query", "Reverse" }, { "prefix", 'p', POPT_BIT_SET, &qmode, QMODE_SHOWPREFIX, "Show prefix on constant", "Prefix" }, POPT_AUTOHELP POPT_TABLEEND }; optcon = poptGetContext(NULL, argc, (const char **)argv, optionstable, 0); while ((c = poptGetNextOpt(optcon)) >= 0) {} if (!(qmode & QMODE_LIST) && poptPeekArg(optcon) == NULL) { poptPrintUsage(optcon, stderr, 0); exit(1); } if (qmode & QMODE_SHOWPREFIX) showprefix = PREFIXED_YES; else showprefix = PREFIXED_NO; if (qmode & QMODE_LIST) { rpmconst consti = rpmconstNew(); if (context) { if (rpmconstInitToContext(consti, context)) { while (rpmconstNextC(consti)) { printf("%s: %d\n", rpmconstName(consti, showprefix), rpmconstValue(consti)); } } else { printf("context '%s' not found\n", context); } } else { while (rpmconstNextL(consti)) { printf("%s\n", rpmconstContext(consti)); } } consti = rpmconstFree(consti); return 0; } while ((name = poptGetArg(optcon)) != NULL) { if (qmode & QMODE_REVERSE) { if(sscanf(name, "%d", &token)) { if (qmode & QMODE_SET) { int i = 0; printf("%d:", token); while ((val = rpmconstantFindMask(context, token, (void *) &name, showprefix))) { printf(" %s", name); token &= ~val; if (++i > 20) return 0; } printf("\n"); } else { if (rpmconstantFindValue(context, token, (void *) &name, showprefix)) printf("%d: %s\n", token, name); else printf("%d: Not found\n", token); } } else { printf("%s is not a integer value\n", name); } } else if(context) { if (rpmconstantFindName(context, name, &val, 0)) { if (~qmode & QMODE_SET) { printf("%s: %d\n", name, val); val = 0; /* resetting */ } } else printf("%s: Not found\n", name); } else { poptPrintUsage(optcon, stderr, 0); exit(1); } } if (qmode & QMODE_SET && !(qmode & QMODE_REVERSE)) printf("Value: %d\n", val); poptFreeContext(optcon); return 0; }
int main (int argc, char **argv) { int ret; LorsExnode *exnode; struct ibp_depot lbone_server = {"dsj.sinrg.cs.utk.edu", 6767}; socket_io_handler handle; IBP_depot lbs = NULL,*dp_list = NULL; char *s; char *lbonehost = NULL; char *output_filename = NULL; char *upload_dir_path = NULL; char *upload_dir_id = NULL; const char *filename = NULL; int same_name=0; char *s_data_blocksize = NULL; char *s_e2e_blocksize = NULL; char *s_max_buffersize = NULL; ulong_t offset=0; long length=-1; char * s_offset=NULL; char * s_length=NULL; char *s_timeout = "600s"; char *s_duration = "1d"; int encryption = 0; int v; int none=0; int depot_list = 0; int file_cnt = 0; XndRc xndrc; XndRc drc; int *e2e_order_tmp = NULL; int e2e_cnt = 0; int try1 = 0; int type_set = 0; int fragments=0; char *rcfile=NULL; char *report_host = NULL; uuid_t out; char session_id[33]; int i; unis_config config; poptContext optCon; /* context for parsing command-line options */ handle.status = CONN_WAITING; struct poptOption optionsTable[] = { { "samename", 'f', POPT_ARG_NONE, 0, SAME_OUTPUTNAME, "Specify the exNode filename by appending .xnd to the original filename.", NULL }, { "stdin", 'i', POPT_ARG_NONE, 0, READ_STDIN, "Read from standard input rather than a specified filename.", NULL }, { "outputfile", 'o', POPT_ARG_STRING, &output_filename, OUTPUTNAME, "Specify a specific name for the output exNode file. " "Default output format is Exnode. 1) If file extension is \".uef\" " "then output file format will be Unis Exnode Format (.uef) " "2) if ouputfile contain link then exnodes will posted" " to that link", NULL}, { "upload_dir", 'u', POPT_ARG_STRING, &upload_dir_path, UPLOAD_DIR, "Specifiy the upload directory path in Unis File System e.g. /user23/LSAT8/2015/1/15", NULL}, { "version", 'v', POPT_ARG_NONE, 0, LORS_VERSION, "Display Version information about this package.", NULL}, { "verbose", 'V', POPT_ARG_INT, &xndrc.verbose, VERBOSE, "Modify the level or mode of Verbosity in output messages.", "0"}, { "lbone-host", 'H', POPT_ARG_STRING, &lbonehost, LBONESERVER, "Specify an L-Bone Server for resource discover and proxmity resolution.", NULL}, { "lbone-port", 'P', POPT_ARG_INT, &lbone_server.port, LBONEPORT, "Specify the port number when using an L-Bone Server on a non standard port.", "6767"}, { "location", 'l', POPT_ARG_STRING, &xndrc.location, LOCATION_HINT, "Specify a location hint to pass the L-Bone Query.", "\"state= TN\""}, { "duration", 'd', POPT_ARG_STRING, &s_duration, DURATION, "Specify the amount of time to allocate storage. The available modifiers are " "'m' 'h' 'd' for 'minute' 'hour' and 'days' respectively. Default is seconds. " "(e.g. -d 1d or -d 1h)", NULL}, { "soft", 's', POPT_ARG_NONE, 0, STORAGE_TYPE_SOFT, "Specify SOFT storage for storage allocations.", NULL}, { "hard", 'h', POPT_ARG_NONE, 0, STORAGE_TYPE_HARD, "Specify HARD storage for storage allocations.", NULL}, { "maxdepots", 'm', POPT_ARG_INT, &xndrc.maxdepots, MAX_DEPOTS, "Specify the maximum number of depots returned by the 'location' hint.", "6"}, { "bs", 'b', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH, &s_data_blocksize, DATA_BLOCKSIZE, "Specify the logical data blocksize of input file.", "'5M'"}, { "copies", 'c', POPT_ARG_INT, &xndrc.copies, COPIES, "Specify the number of copies.", "1"}, { "fragments", 'F', POPT_ARG_INT, &fragments, NUM_FRAGMENTS, "Rather than specifying the logical data blocksize, specify the number of " "blocks into which the file should be divided.", "4" }, { "depot-list", 0, POPT_ARG_NONE, 0, DEPOT_LIST, "Only use depots specified in .xndrc file", NULL}, { "threads", 't', POPT_ARG_INT, &xndrc.threads, THREADS, "Specify the maximum number of threads to use to perform Upload.", NULL}, { "timeout", 'T', POPT_ARG_STRING, &s_timeout, TIMEOUT, "Specify the maximum time to allow for all operations.", "'3m'"}, { "buffersize", 'M', POPT_ARG_STRING, &s_max_buffersize, MAX_BUFFSIZE, "Specify the maximum internal buffer to use on operations.", NULL}, { "offset", 'O', POPT_ARG_STRING, &s_offset, FILE_OFFSET, "Specify an offset relative to the exNode from which download will begin",NULL}, { "length", 'L', POPT_ARG_STRING, &s_length, FILE_LENGTH, "Specify a length other than the logical extent of the exNode.", NULL}, { "none", 'n', POPT_ARG_NONE, 0, LORS_NO_E2E, "Turn off all e2e services.", NULL}, { "des", 'e', POPT_ARG_NONE|POPT_ARGFLAG_OR, &encryption, DES_ENCRYPTION, "Turn on des encryption.", NULL}, { "aes", 'a', POPT_ARG_NONE|POPT_ARGFLAG_OR, &encryption, AES_ENCRYPTION, "Turn on aes encryption.", NULL}, { "compress", 'z', POPT_ARG_NONE|POPT_ARGFLAG_OR, &encryption, ZLIB_COMPRESS, "Turn on zlib compression.", NULL}, { "xor", 'x', POPT_ARG_NONE|POPT_ARGFLAG_OR, &encryption, XOR_ENCRYPTION, "Turn on xor encryption.", NULL}, { "checksum", 'k', POPT_ARG_NONE|POPT_ARGFLAG_OR, &encryption, ADD_CHECKSUM, "Turn on checksum.", NULL}, { "e2e-blocksize", 'E', POPT_ARG_STRING, &s_e2e_blocksize, E2E_BLOCKSIZE, "When specifying e2e conditioning, select an e2e bocksize " "which will evenly fit into your chosen Mapping Blocksize.", NULL}, { "xndrc", 'x', POPT_ARG_STRING, &rcfile, RCFILE, "You may specify an alternate source for the upload DepotList.", "<filename>"}, { "demo", 'D', POPT_ARG_NONE, 0, LORS_ARG_DEMO, "Add the messages understood by the LoRS View visualization.", NULL}, { "visualize-progress", 'X', POPT_ARG_STRING, &report_host, VISUALIZE_PROGRESS, "Http link to visualizer with port e.g. http://dlt.incntre.iu.edu:8000 .", NULL}, POPT_AUTOHELP { NULL, 0, 0, NULL, 0 } }; memset(&drc, 0, sizeof(XndRc)); memset(&xndrc, 0, sizeof(XndRc)); parse_xndrc_files(&xndrc); lbs = &lbone_server; g_lors_demo = xndrc.demo; optCon = poptGetContext(NULL, argc, (const char **)argv, optionsTable, 0); poptSetOtherOptionHelp(optCon, "<filename>"); #ifndef _MINGW signal(SIGPIPE, sigpipe_handle); #endif /*signal(SIGINT, sigint_handle);*/ if ( argc < 2 ) { poptPrintUsage(optCon, stderr, 0); poptPrintHelp(optCon, stderr, 0); exit(EXIT_FAILURE); } while ( (v=poptGetNextOpt(optCon)) >= 0) { switch(v) { case DATA_BLOCKSIZE: if ( strtobytes(s_data_blocksize, &xndrc.data_blocksize) != 0 ) { fprintf(stderr, "The blocksize specified is too large for internal datatype.\n"); exit(EXIT_FAILURE); } if ( fragments != 0 ) { fprintf(stderr, "Specify either Fragments or Blocksize, not both.\n"); exit(EXIT_FAILURE); } break; case NUM_FRAGMENTS: if ( s_data_blocksize != NULL ) { fprintf(stderr, "Specify either Fragments or Blocksize, not both.\n"); exit(EXIT_FAILURE); } break; case MAX_BUFFSIZE: if ( strtobytes(s_max_buffersize, &xndrc.max_buffersize) != 0 ) { fprintf(stderr, "The blocksize specified is too large for " "internal datatype.\n"); exit(EXIT_FAILURE); } break; case AES_ENCRYPTION: fprintf(stderr, "AES: encryption\n"); xndrc.e2e_order[e2e_cnt] = AES_ENCRYPTION; e2e_cnt++; break; case DES_ENCRYPTION: xndrc.e2e_order[e2e_cnt] = DES_ENCRYPTION; e2e_cnt++; break; case XOR_ENCRYPTION: xndrc.e2e_order[e2e_cnt] = XOR_ENCRYPTION; e2e_cnt++; break; case ADD_CHECKSUM: xndrc.e2e_order[e2e_cnt] = ADD_CHECKSUM; e2e_cnt++; break; case ZLIB_COMPRESS: xndrc.e2e_order[e2e_cnt] = ZLIB_COMPRESS; e2e_cnt++; break; case LORS_NO_E2E: none = 1; break; case FILE_OFFSET: if ( strtobytes(s_offset, &offset) != 0 ) { fprintf(stderr, "The offset specified is too large for " "internal datatype.\n"); exit(EXIT_FAILURE); } break; case FILE_LENGTH: if ( strtobytes(s_length, &length) != 0 ) { fprintf(stderr, "The length specified is too large for " "internal datatype.\n"); exit(EXIT_FAILURE); } break; case E2E_BLOCKSIZE: if ( strtobytes(s_e2e_blocksize, &xndrc.e2e_blocksize) != 0 ) { fprintf(stderr, "The e2e blocksize specified is too large for " "internal datatype.\n"); exit(EXIT_FAILURE); } break; case DEPOT_LIST: depot_list = 1; break; case TIMEOUT: if ( strtotimeout(s_timeout, &xndrc.timeout) != 0 ) { fprintf(stderr, "Value too large for type.\n"); exit(EXIT_FAILURE); } break; case LBONESERVER: strncpy(lbone_server.host, lbonehost, 255); break; case STORAGE_TYPE_HARD: if ( type_set > 0 ) { fprintf(stderr, "Set one of either Hard or Soft storage.\n"); exit(EXIT_FAILURE); } xndrc.storage_type = IBP_HARD; type_set++; break; case STORAGE_TYPE_SOFT: if ( type_set > 0 ) { fprintf(stderr, "Set one of either Hard or Soft storage.\n"); exit(EXIT_FAILURE); } xndrc.storage_type = IBP_SOFT; type_set++; break; case DURATION: if ( strtotimeout(s_duration, &xndrc.duration) != 0 ) { fprintf(stderr, "Value too large for type.\n"); exit(EXIT_FAILURE); } break; case LORS_VERSION: { const char *package; double version; lorsGetLibraryVersion(&package, &version); fprintf(stderr, "Version: %s %f\n", package, version); exit(EXIT_FAILURE); break; } case LORS_ARG_DEMO: g_lors_demo = (!g_lors_demo); break; case READ_STDIN: filename = "-"; break; case SAME_OUTPUTNAME: same_name = 1; break; #if 0 default: fprintf(stderr, "Unsupported option: %d\n", v); #endif } } if ( rcfile != NULL ) { if ( read_xndrc_file(&drc, rcfile) != 0 ) { fprintf(stderr, "Unable to open specified rcfile\n"); exit(EXIT_FAILURE); } xndrc.depotList = drc.depotList; } g_db_level = xndrc.verbose; if ( v < -1 ) { fprintf(stderr, "error: %d\n", v); fprintf(stderr, "%s: %s\n", poptBadOption(optCon, POPT_BADOPTION_NOALIAS), poptStrerror(v)); } /*g_db_level = D_LORS_TERSE | D_LORS_VERBOSE | D_LORS_ERR_MSG ;*/ if ( depot_list == 1 ){ dp_list = xndrc.depotList; }else { dp_list = NULL; }; /* setup default e2e conditioning for upload */ if ( none > 0 ) { xndrc.e2e_order[0] = -1; e2e_cnt = 0; } else if ( e2e_cnt == 0 ) { for(; xndrc.e2e_order[e2e_cnt] != -1; e2e_cnt++); } /*check the upload directory */ if(output_filename != NULL && strstr(output_filename, "http://") != NULL ) { if(upload_dir_path == NULL){ fprintf(stderr, "Missing UNIS upload directory absolute path \n"); exit(EXIT_FAILURE); }else{ memset (&config, 0, sizeof(unis_config)); config.endpoint = output_filename; config.persistent = 1; ret = unis_create_directory(&config, upload_dir_path, &upload_dir_id); if(ret == 0){ fprintf(stderr, "Failed to get the upload directory id from UNIS \n"); exit(EXIT_FAILURE); } } } /*Generate session UUID*/ if(report_host != NULL) { uuid_generate(out); for(i = 0; i < 16; i++) sprintf(session_id + (i*2),"%02x", out[i]); handle.server_add = report_host; handle.session_id = session_id; if(socket_io_init(&handle) != SOCK_SUCCESS) { fprintf(stderr, "Socket IO Init failed \n"); } } if ( filename != NULL ) { goto in_while; } while ( (filename = poptGetArg(optCon)) != NULL ) { in_while: file_cnt++; if ( same_name == 1 ) { int len; char *s; s = strrchr (filename, '/'); if ( s == NULL ) s = filename; else s++; len = strlen(s) + strlen(".xnd") + 1; output_filename = malloc(sizeof(char)*len); snprintf(output_filename, len, "%s.xnd", s); } lorsDebugPrint(D_LORS_VERBOSE, "%s %ld %ld %ld %d %s %d %s %d %d %d %ld %d %d\n", filename, offset, length, xndrc.data_blocksize, xndrc.copies, lbone_server.host, lbone_server.port, xndrc.location, xndrc.maxdepots, xndrc.storage_type, xndrc.duration, xndrc.max_buffersize, xndrc.threads, xndrc.timeout); if ( e2e_cnt > 0 ) { xndrc.e2e_order[e2e_cnt] = -1; e2e_order_tmp = xndrc.e2e_order; } /* start from first lbone server in xndrc file */ if ( lbonehost == NULL ) { lbs = xndrc.lboneList[try1]; try1 = 1; } else { lbs = &lbone_server; try1 = 0; } do { /*fprintf(stderr, "e2e_blocksize: %ld\n", xndrc.e2e_blocksize);*/ ret = lorsUploadFile(filename, output_filename, offset, (longlong)length, xndrc.data_blocksize, xndrc.copies, fragments, xndrc.e2e_blocksize, e2e_order_tmp, lbs, dp_list, xndrc.location, xndrc.maxdepots, xndrc.storage_type, xndrc.duration, xndrc.max_buffersize, xndrc.resolution_file, xndrc.threads, xndrc.timeout, &handle, upload_dir_id, 0); if ( ret != LORS_SUCCESS && ret != LORS_PARTIAL ) { if ( ret == LORS_LBONE_FAILED && xndrc.lboneList[try1] != NULL ) { fprintf(stderr, "%s: %d\n", xndrc.lboneList[try1]->host, xndrc.lboneList[try1]->port); fprintf(stderr, "L-Bone failure: trying next server\n"); lbs = xndrc.lboneList[try1]; try1++; } else { fprintf(stderr, "LORS_ERROR: %d\n", ret); exit(EXIT_FAILURE); } } } while ( ret != LORS_SUCCESS && ret != LORS_PARTIAL ); free(output_filename); } if(report_host != NULL){ if(handle.status == CONN_CONNECTED){ socket_io_send_clear(&handle); } if(handle.status != CONN_WAITING){ socket_io_close(&handle); } } if ( file_cnt == 0 ) { fprintf(stderr, "Error. You must also provide a filename on " "which lors_upload operates.\n"); poptPrintHelp(optCon, stderr, 0); exit(EXIT_FAILURE); } free_xndrc(&xndrc); poptFreeContext(optCon); if ( ret == LORS_PARTIAL ) return 1; return 0; }
/* main server. */ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[]) { bool opt_daemon = false; bool opt_interactive = false; int opt; poptContext pc; #define _MODULE_PROTO(init) extern NTSTATUS init(void); STATIC_service_MODULES_PROTO; init_module_fn static_init[] = { STATIC_service_MODULES }; init_module_fn *shared_init; struct tevent_context *event_ctx; uint16_t stdin_event_flags; NTSTATUS status; const char *model = "standard"; int max_runtime = 0; struct stat st; enum { OPT_DAEMON = 1000, OPT_INTERACTIVE, OPT_PROCESS_MODEL, OPT_SHOW_BUILD }; struct poptOption long_options[] = { POPT_AUTOHELP {"daemon", 'D', POPT_ARG_NONE, NULL, OPT_DAEMON, "Become a daemon (default)", NULL }, {"interactive", 'i', POPT_ARG_NONE, NULL, OPT_INTERACTIVE, "Run interactive (not a daemon)", NULL}, {"model", 'M', POPT_ARG_STRING, NULL, OPT_PROCESS_MODEL, "Select process model", "MODEL"}, {"maximum-runtime",0, POPT_ARG_INT, &max_runtime, 0, "set maximum runtime of the server process, till autotermination", "seconds"}, {"show-build", 'b', POPT_ARG_NONE, NULL, OPT_SHOW_BUILD, "show build info", NULL }, POPT_COMMON_SAMBA POPT_COMMON_VERSION { NULL } }; pc = poptGetContext(binary_name, argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { case OPT_DAEMON: opt_daemon = true; break; case OPT_INTERACTIVE: opt_interactive = true; break; case OPT_PROCESS_MODEL: model = poptGetOptArg(pc); break; case OPT_SHOW_BUILD: show_build(); break; default: fprintf(stderr, "\nInvalid option %s: %s\n\n", poptBadOption(pc, 0), poptStrerror(opt)); poptPrintUsage(pc, stderr, 0); return 1; } } if (opt_daemon && opt_interactive) { fprintf(stderr,"\nERROR: " "Option -i|--interactive is not allowed together with -D|--daemon\n\n"); poptPrintUsage(pc, stderr, 0); return 1; } else if (!opt_interactive) { /* default is --daemon */ opt_daemon = true; } poptFreeContext(pc); setup_logging(binary_name, opt_interactive?DEBUG_STDOUT:DEBUG_FILE); setup_signals(); /* we want total control over the permissions on created files, so set our umask to 0 */ umask(0); DEBUG(0,("%s version %s started.\n", binary_name, SAMBA_VERSION_STRING)); DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2015\n")); if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4 || sizeof(uint64_t) < 8) { DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n")); DEBUGADD(0,("sizeof(uint16_t) = %u, sizeof(uint32_t) %u, sizeof(uint64_t) = %u\n", (unsigned int)sizeof(uint16_t), (unsigned int)sizeof(uint32_t), (unsigned int)sizeof(uint64_t))); return 1; } if (opt_daemon) { DEBUG(3,("Becoming a daemon.\n")); become_daemon(true, false, false); } cleanup_tmp_files(cmdline_lp_ctx); if (!directory_exist(lpcfg_lock_directory(cmdline_lp_ctx))) { mkdir(lpcfg_lock_directory(cmdline_lp_ctx), 0755); } pidfile_create(lpcfg_pid_directory(cmdline_lp_ctx), binary_name); /* Set up a database to hold a random seed, in case we don't * have /dev/urandom */ if (!randseed_init(talloc_autofree_context(), cmdline_lp_ctx)) { return 1; } if (lpcfg_server_role(cmdline_lp_ctx) == ROLE_ACTIVE_DIRECTORY_DC) { if (!open_schannel_session_store(talloc_autofree_context(), cmdline_lp_ctx)) { exit_daemon("Samba cannot open schannel store for secured NETLOGON operations.", EACCES); } } /* make sure we won't go through nss_winbind */ if (!winbind_off()) { exit_daemon("Samba failed to disable recusive winbindd calls.", EACCES); } gensec_init(); /* FIXME: */ ntptr_init(); /* FIXME: maybe run this in the initialization function of the spoolss RPC server instead? */ ntvfs_init(cmdline_lp_ctx); /* FIXME: maybe run this in the initialization functions of the SMB[,2] server instead? */ process_model_init(cmdline_lp_ctx); shared_init = load_samba_modules(NULL, "service"); run_init_functions(static_init); run_init_functions(shared_init); talloc_free(shared_init); /* the event context is the top level structure in smbd. Everything else should hang off that */ event_ctx = s4_event_context_init(talloc_autofree_context()); if (event_ctx == NULL) { exit_daemon("Initializing event context failed", EACCES); } if (opt_interactive) { /* terminate when stdin goes away */ stdin_event_flags = TEVENT_FD_READ; } else { /* stay alive forever */ stdin_event_flags = 0; } /* catch EOF on stdin */ #ifdef SIGTTIN signal(SIGTTIN, SIG_IGN); #endif if (fstat(0, &st) != 0) { exit_daemon("Samba failed to set standard input handler", ENOTTY); } if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { tevent_add_fd(event_ctx, event_ctx, 0, stdin_event_flags, server_stdin_handler, discard_const(binary_name)); } if (max_runtime) { DEBUG(0,("Called with maxruntime %d - current ts %llu\n", max_runtime, (unsigned long long) time(NULL))); tevent_add_timer(event_ctx, event_ctx, timeval_current_ofs(max_runtime, 0), max_runtime_handler, discard_const(binary_name)); } if (lpcfg_server_role(cmdline_lp_ctx) != ROLE_ACTIVE_DIRECTORY_DC && !lpcfg_parm_bool(cmdline_lp_ctx, NULL, "server role check", "inhibit", false) && !str_list_check_ci(lpcfg_server_services(cmdline_lp_ctx), "smb") && !str_list_check_ci(lpcfg_dcerpc_endpoint_servers(cmdline_lp_ctx), "remote") && !str_list_check_ci(lpcfg_dcerpc_endpoint_servers(cmdline_lp_ctx), "mapiproxy")) { DEBUG(0, ("At this time the 'samba' binary should only be used for either:\n")); DEBUGADD(0, ("'server role = active directory domain controller' or to access the ntvfs file server with 'server services = +smb' or the rpc proxy with 'dcerpc endpoint servers = remote'\n")); DEBUGADD(0, ("You should start smbd/nmbd/winbindd instead for domain member and standalone file server tasks\n")); exit_daemon("Samba detected misconfigured 'server role' and exited. Check logs for details", EINVAL); }; prime_ldb_databases(event_ctx); status = setup_parent_messaging(event_ctx, cmdline_lp_ctx); if (!NT_STATUS_IS_OK(status)) { exit_daemon("Samba failed to setup parent messaging", NT_STATUS_V(status)); } DEBUG(0,("%s: using '%s' process model\n", binary_name, model)); status = server_service_startup(event_ctx, cmdline_lp_ctx, model, lpcfg_server_services(cmdline_lp_ctx)); if (!NT_STATUS_IS_OK(status)) { exit_daemon("Samba failed to start services", NT_STATUS_V(status)); } if (opt_daemon) { daemon_ready("samba"); } /* wait for events - this is where smbd sits for most of its life */ tevent_loop_wait(event_ctx); /* as everything hangs off this event context, freeing it should initiate a clean shutdown of all services */ talloc_free(event_ctx); return 0; }
int main(int argc,const char *argv[]) { /* shall I run as a daemon */ bool is_daemon = false; bool interactive = false; bool Fork = true; bool no_process_group = false; bool log_stdout = false; char *ports = NULL; char *profile_level = NULL; int opt; poptContext pc; bool print_build_options = False; enum { OPT_DAEMON = 1000, OPT_INTERACTIVE, OPT_FORK, OPT_NO_PROCESS_GROUP, OPT_LOG_STDOUT }; struct poptOption long_options[] = { POPT_AUTOHELP {"daemon", 'D', POPT_ARG_NONE, NULL, OPT_DAEMON, "Become a daemon (default)" }, {"interactive", 'i', POPT_ARG_NONE, NULL, OPT_INTERACTIVE, "Run interactive (not a daemon)"}, {"foreground", 'F', POPT_ARG_NONE, NULL, OPT_FORK, "Run daemon in foreground (for daemontools, etc.)" }, {"no-process-group", '\0', POPT_ARG_NONE, NULL, OPT_NO_PROCESS_GROUP, "Don't create a new process group" }, {"log-stdout", 'S', POPT_ARG_NONE, NULL, OPT_LOG_STDOUT, "Log to stdout" }, {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" }, {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"}, {"profiling-level", 'P', POPT_ARG_STRING, &profile_level, 0, "Set profiling level","PROFILE_LEVEL"}, POPT_COMMON_SAMBA POPT_COMMON_DYNCONFIG POPT_TABLEEND }; struct smbd_parent_context *parent = NULL; TALLOC_CTX *frame; NTSTATUS status; uint64_t unique_id; struct tevent_context *ev_ctx; struct messaging_context *msg_ctx; struct tevent_signal *se; /* * Do this before any other talloc operation */ talloc_enable_null_tracking(); frame = talloc_stackframe(); setup_logging(argv[0], DEBUG_DEFAULT_STDOUT); load_case_tables(); smbd_init_globals(); TimeInit(); #ifdef HAVE_SET_AUTH_PARAMETERS set_auth_parameters(argc,argv); #endif pc = poptGetContext("smbd", argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_DAEMON: is_daemon = true; break; case OPT_INTERACTIVE: interactive = true; break; case OPT_FORK: Fork = false; break; case OPT_NO_PROCESS_GROUP: no_process_group = true; break; case OPT_LOG_STDOUT: log_stdout = true; break; case 'b': print_build_options = True; break; default: d_fprintf(stderr, "\nInvalid option %s: %s\n\n", poptBadOption(pc, 0), poptStrerror(opt)); poptPrintUsage(pc, stderr, 0); exit(1); } } poptFreeContext(pc); if (interactive) { Fork = False; log_stdout = True; } if (log_stdout) { setup_logging(argv[0], DEBUG_STDOUT); } else { setup_logging(argv[0], DEBUG_FILE); } if (print_build_options) { build_options(True); /* Display output to screen as well as debug */ exit(0); } #ifdef HAVE_SETLUID /* needed for SecureWare on SCO */ setluid(0); #endif set_remote_machine_name("smbd", False); if (interactive && (DEBUGLEVEL >= 9)) { talloc_enable_leak_report(); } if (log_stdout && Fork) { DEBUG(0,("ERROR: Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n")); exit(1); } /* we want to re-seed early to prevent time delays causing client problems at a later date. (tridge) */ generate_random_buffer(NULL, 0); /* get initial effective uid and gid */ sec_init(); /* make absolutely sure we run as root - to handle cases where people are crazy enough to have it setuid */ gain_root_privilege(); gain_root_group_privilege(); fault_setup(); dump_core_setup("smbd", lp_logfile()); /* we are never interested in SIGPIPE */ BlockSignals(True,SIGPIPE); #if defined(SIGFPE) /* we are never interested in SIGFPE */ BlockSignals(True,SIGFPE); #endif #if defined(SIGUSR2) /* We are no longer interested in USR2 */ BlockSignals(True,SIGUSR2); #endif /* POSIX demands that signals are inherited. If the invoking process has * these signals masked, we will have problems, as we won't recieve them. */ BlockSignals(False, SIGHUP); BlockSignals(False, SIGUSR1); BlockSignals(False, SIGTERM); /* Ensure we leave no zombies until we * correctly set up child handling below. */ CatchChild(); /* we want total control over the permissions on created files, so set our umask to 0 */ umask(0); reopen_logs(); DEBUG(0,("smbd version %s started.\n", samba_version_string())); DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE)); DEBUG(2,("uid=%d gid=%d euid=%d egid=%d\n", (int)getuid(),(int)getgid(),(int)geteuid(),(int)getegid())); /* Output the build options to the debug log */ build_options(False); if (sizeof(uint16) < 2 || sizeof(uint32) < 4) { DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n")); exit(1); } if (!lp_load_initial_only(get_dyn_CONFIGFILE())) { DEBUG(0, ("error opening config file '%s'\n", get_dyn_CONFIGFILE())); exit(1); } /* Init the security context and global current_user */ init_sec_ctx(); /* * Initialize the event context. The event context needs to be * initialized before the messaging context, cause the messaging * context holds an event context. * FIXME: This should be s3_tevent_context_init() */ ev_ctx = server_event_context(); if (ev_ctx == NULL) { exit(1); } /* * Init the messaging context * FIXME: This should only call messaging_init() */ msg_ctx = server_messaging_context(); if (msg_ctx == NULL) { exit(1); } /* * Reloading of the printers will not work here as we don't have a * server info and rpc services set up. It will be called later. */ if (!reload_services(NULL, NULL, false)) { exit(1); } /* ...NOTE... Log files are working from this point! */ DEBUG(3,("loaded services\n")); init_structs(); #ifdef WITH_PROFILE if (!profile_setup(msg_ctx, False)) { DEBUG(0,("ERROR: failed to setup profiling\n")); return -1; } if (profile_level != NULL) { int pl = atoi(profile_level); struct server_id src; DEBUG(1, ("setting profiling level: %s\n",profile_level)); src.pid = getpid(); set_profile_level(pl, src); } #endif if (!is_daemon && !is_a_socket(0)) { if (!interactive) DEBUG(0,("standard input is not a socket, assuming -D option\n")); /* * Setting is_daemon here prevents us from eventually calling * the open_sockets_inetd() */ is_daemon = True; } if (is_daemon && !interactive) { DEBUG( 3, ( "Becoming a daemon.\n" ) ); become_daemon(Fork, no_process_group, log_stdout); } generate_random_buffer((uint8_t *)&unique_id, sizeof(unique_id)); set_my_unique_id(unique_id); #if HAVE_SETPGID /* * If we're interactive we want to set our own process group for * signal management. */ if (interactive && !no_process_group) setpgid( (pid_t)0, (pid_t)0); #endif if (!directory_exist(lp_lockdir())) mkdir(lp_lockdir(), 0755); if (is_daemon) pidfile_create("smbd"); status = reinit_after_fork(msg_ctx, ev_ctx, false); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); exit(1); } smbd_server_conn->msg_ctx = msg_ctx; parent = talloc_zero(ev_ctx, struct smbd_parent_context); if (!parent) { exit_server("talloc(struct smbd_parent_context) failed"); } parent->interactive = interactive; parent->ev_ctx = ev_ctx; parent->msg_ctx = msg_ctx; am_parent = parent; se = tevent_add_signal(parent->ev_ctx, parent, SIGTERM, 0, smbd_parent_sig_term_handler, parent); if (!se) { exit_server("failed to setup SIGTERM handler"); } se = tevent_add_signal(parent->ev_ctx, parent, SIGHUP, 0, smbd_parent_sig_hup_handler, parent); if (!se) { exit_server("failed to setup SIGHUP handler"); } /* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */ if (smbd_memcache() == NULL) { exit(1); } memcache_set_global(smbd_memcache()); /* Initialise the password backed before the global_sam_sid to ensure that we fetch from ldap before we make a domain sid up */ if(!initialize_password_db(false, ev_ctx)) exit(1); if (!secrets_init()) { DEBUG(0, ("ERROR: smbd can not open secrets.tdb\n")); exit(1); } if (lp_server_role() == ROLE_DOMAIN_BDC || lp_server_role() == ROLE_DOMAIN_PDC) { struct loadparm_context *lp_ctx = loadparm_init_s3(NULL, loadparm_s3_context()); if (!open_schannel_session_store(NULL, lp_ctx)) { DEBUG(0,("ERROR: Samba cannot open schannel store for secured NETLOGON operations.\n")); exit(1); } TALLOC_FREE(lp_ctx); } if(!get_global_sam_sid()) { DEBUG(0,("ERROR: Samba cannot create a SAM SID.\n")); exit(1); } if (!sessionid_init()) { exit(1); } if (!connections_init(True)) exit(1); if (!locking_init()) exit(1); if (!messaging_tdb_parent_init(ev_ctx)) { exit(1); } if (!notify_internal_parent_init(ev_ctx)) { exit(1); } if (!serverid_parent_init(ev_ctx)) { exit(1); } if (!W_ERROR_IS_OK(registry_init_full())) exit(1); /* Open the share_info.tdb here, so we don't have to open after the fork on every single connection. This is a small performance improvment and reduces the total number of system fds used. */ if (!share_info_db_init()) { DEBUG(0,("ERROR: failed to load share info db.\n")); exit(1); } status = init_system_info(); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("ERROR: failed to setup system user info: %s.\n", nt_errstr(status))); return -1; } if (!init_guest_info()) { DEBUG(0,("ERROR: failed to setup guest info.\n")); return -1; } if (!file_init(smbd_server_conn)) { DEBUG(0, ("ERROR: file_init failed\n")); return -1; } /* This MUST be done before start_epmd() because otherwise * start_epmd() forks and races against dcesrv_ep_setup() to * call directory_create_or_exist() */ if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) { DEBUG(0, ("Failed to create pipe directory %s - %s\n", lp_ncalrpc_dir(), strerror(errno))); return -1; } if (is_daemon && !interactive) { if (rpc_epmapper_daemon() == RPC_DAEMON_FORK) { start_epmd(ev_ctx, msg_ctx); } } if (!dcesrv_ep_setup(ev_ctx, msg_ctx)) { exit(1); } /* only start other daemons if we are running as a daemon * -- bad things will happen if smbd is launched via inetd * and we fork a copy of ourselves here */ if (is_daemon && !interactive) { if (rpc_lsasd_daemon() == RPC_DAEMON_FORK) { start_lsasd(ev_ctx, msg_ctx); } if (!_lp_disable_spoolss() && (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) { bool bgq = lp_parm_bool(-1, "smbd", "backgroundqueue", true); if (!printing_subsystem_init(ev_ctx, msg_ctx, true, bgq)) { exit(1); } } } else if (!_lp_disable_spoolss() && (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) { if (!printing_subsystem_init(ev_ctx, msg_ctx, false, false)) { exit(1); } } if (!is_daemon) { /* inetd mode */ TALLOC_FREE(frame); /* Started from inetd. fd 0 is the socket. */ /* We will abort gracefully when the client or remote system goes away */ smbd_server_conn->sock = dup(0); /* close our standard file descriptors */ if (!debug_get_output_is_stdout()) { close_low_fds(False); /* Don't close stderr */ } #ifdef HAVE_ATEXIT atexit(killkids); #endif /* Stop zombies */ smbd_setup_sig_chld_handler(parent); smbd_process(ev_ctx, smbd_server_conn); exit_server_cleanly(NULL); return(0); } if (!open_sockets_smbd(parent, ev_ctx, msg_ctx, ports)) exit_server("open_sockets_smbd() failed"); /* do a printer update now that all messaging has been set up, * before we allow clients to start connecting */ printing_subsystem_update(ev_ctx, msg_ctx, false); TALLOC_FREE(frame); /* make sure we always have a valid stackframe */ frame = talloc_stackframe(); smbd_parent_loop(ev_ctx, parent); exit_server_cleanly(NULL); TALLOC_FREE(frame); return(0); }
int main(int argc, const char *argv[]) { int rv; poptContext pc; int opt; struct poptOption long_options[] = { POPT_AUTOHELP SSSD_DEBUG_OPTS POPT_TABLEEND }; const struct CMUnitTest tests[] = { /* user */ cmocka_unit_test_setup_teardown(test_ncache_nocache_user, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_local_user, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_domain_user, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_both_user, test_ncache_setup, test_ncache_teardown), /* uid */ cmocka_unit_test_setup_teardown(test_ncache_nocache_uid, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_local_uid, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_domain_uid, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_both_uid, test_ncache_setup, test_ncache_teardown), /* group */ cmocka_unit_test_setup_teardown(test_ncache_nocache_group, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_local_group, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_domain_group, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_both_group, test_ncache_setup, test_ncache_teardown), /* gid */ cmocka_unit_test_setup_teardown(test_ncache_nocache_gid, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_local_gid, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_domain_gid, test_ncache_setup, test_ncache_teardown), cmocka_unit_test_setup_teardown(test_ncache_both_gid, test_ncache_setup, test_ncache_teardown), }; /* Set debug level to invalid value so we can deside if -d 0 was used. */ debug_level = SSSDBG_INVALID; pc = poptGetContext(argv[0], argc, argv, long_options, 0); while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { default: fprintf(stderr, "\nInvalid option %s: %s\n\n", poptBadOption(pc, 0), poptStrerror(opt)); poptPrintUsage(pc, stderr, 0); return 1; } } poptFreeContext(pc); DEBUG_CLI_INIT(debug_level); tests_set_cwd(); test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME); rv = cmocka_run_group_tests(tests, NULL, NULL); return rv; }