struct pipeline *pipelineOpenFd(char ***cmds, unsigned opts, int otherEndFd, int stderrFd) /* Create a pipeline from an array of commands. See pipeline.h for * full documentation. */ { struct pipeline *pl; checkOpts(opts); pl = pipelineNew(cmds, opts); if (opts & pipelineRead) pipelineStartRead(pl, otherEndFd, stderrFd, NULL, 0); else pipelineStartWrite(pl, otherEndFd, stderrFd); return pl; }
struct pipeline *pipelineOpenMem(char ***cmds, unsigned opts, void *otherEndBuf, size_t otherEndBufSize, int stderrFd) /* Create a pipeline from an array of commands, with the pipeline input/output * in a memory buffer. See pipeline.h for full documentation. Currently only * input to a read pipeline is supported */ { struct pipeline *pl; checkOpts(opts); if (opts & pipelineWrite) errAbort("pipelineOpenMem only supports read pipelines at this time"); opts |= pipelineMemInput; pl = pipelineNew(cmds, opts); pipelineStartRead(pl, STDIN_FILENO, stderrFd, otherEndBuf, otherEndBufSize); return pl; }
struct pipeline *pipelineOpen(char ***cmds, unsigned opts, char *otherEndFile, char *stderrFile) /* Create a pipeline from an array of commands. See pipeline.h for * full documentation */ { int otherEndFd; int stderrFd = (stderrFile == NULL) ? STDERR_FILENO : openWrite(stderrFile); checkOpts(opts); if (opts & pipelineRead) otherEndFd = (otherEndFile == NULL) ? STDIN_FILENO : openRead(otherEndFile); else otherEndFd = (otherEndFile == NULL) ? STDOUT_FILENO : openWrite(otherEndFile); struct pipeline *pl = pipelineOpenFd(cmds, opts, otherEndFd, stderrFd); safeClose(&otherEndFd); if (stderrFile != NULL) safeClose(&stderrFd); return pl; }
void getOpts(int argc, char** argv) { int c; while (1) { int option_index = 0; static struct option long_options[] = { {"gz1", required_argument, 0, 0 }, {"gz2", required_argument, 0, 0 }, {"output", required_argument, 0, 0 }, {"callId", required_argument, 0, 0 }, {"row", required_argument, 0, 0 }, {"log", required_argument, 0, 0 }, {0, 0, 0, 0 } }; c = getopt_long(argc, argv, ":c", long_options, &option_index); if (c == -1) { break; } switch (c) { case 0: printf("option %s", long_options[option_index].name); if (optarg) printf(" with arg %s", optarg); printf("\n"); if (long_options[option_index].flag != 0) { cout << "break after flag test! \n"; break; } if (strcmp(long_options[option_index].name,"gz1") == 0) { gz1_path = optarg; cout << gz1_path << endl; } if (strcmp(long_options[option_index].name,"gz2") == 0) { if(optarg) { gz2_path = optarg; cout << gz2_path << endl; } } if (strcmp(long_options[option_index].name,"output") == 0) { output_path = optarg; cout << output_path << endl; } if (strcmp(long_options[option_index].name,"row") == 0) { row_num = atoi(optarg); cout << row_num << endl; } if (strcmp(long_options[option_index].name,"sample") == 0) { sample_name = optarg; cout << sample_name << endl; } if (strcmp(long_options[option_index].name,"log") == 0) { log_path = optarg; cout << log_path << endl; } if (strcmp(long_options[option_index].name,"callId") == 0) { call_id = optarg; cout << call_id << endl; } break; case 'c': is_compress = true; printf("compress the result\n"); break; default: printf("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf("non-option ARGV-elements: "); while (optind < argc) printf("%s ", argv[optind++]); printf("\n"); } // check options checkOpts(argv); // init log path initLogPath(); }