本文整理汇总了C++中USAGE函数的典型用法代码示例。如果您正苦于以下问题:C++ USAGE函数的具体用法?C++ USAGE怎么用?C++ USAGE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USAGE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
if (argc != 2) {
USAGE(argv[0]);
return EXIT_FAILURE;
}
pid_t adbd_pid = get_pid(ADBD_CMDLINE);
uid_t adbd_uid = get_uid(adbd_pid);
if (strcmp(argv[1], ARG_ROOT) == 0) {
if (adbd_uid == ROOT_UID) {
fprintf(stderr, "Already rooted...\n");
return EXIT_FAILURE;
}
return root() == ROOT_UID ? EXIT_SUCCESS : EXIT_FAILURE;
} else if (strcmp(argv[1], ARG_UNROOT) == 0) {
if (adbd_uid != ROOT_UID) {
fprintf(stderr, "Already unrooted...\n");
return EXIT_FAILURE;
}
kill(adbd_pid, SIGKILL);
return EXIT_SUCCESS;
} else {
USAGE(argv[0]);
return EXIT_FAILURE;
}
}
示例2: sim_setoptions
/**
* Parses command-line options and sets global variables as appropriate.
*
* @param argc Number of arguments from the command line.
* @param argv Array of strings containing the command line arguments.
*/
void sim_setoptions(int argc, char **argv) {
int c;
progname = argv[0];
while ((c = getopt(argc, argv, "p:m:t:j:h")) != -1) {
switch (c) {
case 'p':
if (optarg == NULL || atoi(optarg) > 16 || atoi(optarg) < 1) {
ERROR("invalid page size -- must be between 1 and 16!");
exit(EXIT_FAILURE);
}
page_size = 1<<atoi(optarg);
break;
case 'm':
if (optarg == NULL || atoi(optarg) > 20 || atoi(optarg) < 1) {
ERROR("invalid memory size -- must be between 1 and 20!");
exit(EXIT_FAILURE);
}
mem_size = 1<<atoi(optarg);
break;
case 't':
if (optarg == NULL || atoi(optarg) > 255 || atoi(optarg) < 0) {
ERROR("invalid TLB size -- must be between 0 and 65536!");
exit(EXIT_FAILURE);
}
tlb_size = atoi(optarg);
break;
case 'j':
if (optarg == NULL || atoi(optarg) > 32 || atoi(optarg) < 0) {
ERROR("invalid max number of jobs -- must be between 0 and 32!");
exit(EXIT_FAILURE);
}
max_jobs = atoi(optarg);
break;
case 'h':
default:
USAGE();
exit(EXIT_FAILURE);
}
}
if (optind >= argc) {
ERROR("no references filename specified");
USAGE();
exit(EXIT_FAILURE);
} else {
filename = argv[optind];
}
if (page_size > mem_size) {
ERROR("page size cannot be larger than physical memory!");
exit(EXIT_FAILURE);
}
printf("page_size = %u bytes\n", page_size);
printf("mem_size = %u bytes\n", mem_size);
printf("tlb_size = %u entries\n", tlb_size);
printf("max_jobs = %u jobs\n", max_jobs);
printf("filename = %s\n\n", filename);
}
示例3: cmd_cpu
int cmd_cpu(int again, char **argv) {
int n;
uword val;
char *endptr;
cpu_flags flags;
if(!argv[1]) {
flags=cpu_read_flags();
for(int j=0; j<4; j++) {
for(int i=0; i<16; i+=4) {
printf(" %3s: %04X", regname[i+j], (unsigned)cpu_read_reg(i+j));
}
if(j==0)printf(" pc: %04X", (unsigned)cpu_read_pc());
if(j==1)printf(" flags: %c%c%c%c", flags.c?'C':'-', flags.z?'Z':'-',
flags.n?'N':'-', flags.v?'V':'-');
putchar('\n');
}
return 0;
}
++argv;
another:
if(!argv[1] || strcmp(argv[1], "=") || !argv[2])USAGE()
val=strtoul(argv[2], &endptr, 0);
if(*endptr)USAGE()
for(n=0; n<16; ++n)
if(!strcmp(regname[n], *argv))break;
if(n<16) // Set GPR
cpu_write_reg(n, val);
else if(!strcmp(*argv, "pc")) // Set PC
cpu_write_pc(val);
else if(!strcmp(*argv, "flags")) { // Set flag register
printf("set flags\n");
// ***
}
else if((strlen(*argv)==1) && strchr("cznv", **argv)) { // Set flag
printf("set flag %s\n", *argv);
// ***
}
else {
printf("Unkown register or flag \"%s\"\n", *argv);
return 1;
}
argv+=3;
if(*argv)goto another;
return 0;
}
示例4: main
int main(int argc, char **argv)
{
USAGE(sizeof(struct PSCOM_con));
#ifndef OFED
USAGE(sizeof(psoib_con_info_t));
USAGE(sizeof(struct PSCOM_con) + sizeof(psoib_con_info_t));
#else
USAGE(sizeof(psofed_con_info_t));
USAGE(sizeof(struct PSCOM_con) + sizeof(psofed_con_info_t));
#endif
return 0;
}
示例5: main
int
main(int argc, char *argv[])
{
int i;
opts.minlen = 4;
for (i=1; i<argc; i++) {
char *t, *s = argv[i];
t=0; /* shut up warnings */
if (s[0] != '-' || s[1] == 0)
break;
if (s[1] == '-' && s[2] == 0) {
++i;
break;
}
while (*++s) switch (*s) {
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
s--;
/* FALLTHROUGH */
case 'n':
opts.minlen = atoi(ARG());
if (opts.minlen == 0)
USAGE();
break;
case 'f':
opts.pr_fn++;
break;
case '?':
default:
USAGE();
break;
}
}
if ((seq_hold = malloc(opts.minlen*sizeof(char))) == NULL) {
perror("malloc"); exit(2);
}
if (i == argc) {
strings(0);
} else {
for (; i<argc; i++) {
char *s = argv[i];
strings(s);
}
}
free(seq_hold);
return 0;
}
示例6: USAGE_PAGE
uint8_t * USBGameController::reportDesc() {
static uint8_t reportDescriptor[] = {
USAGE_PAGE(1), 0x01, // Generic Desktop
LOGICAL_MINIMUM(1), 0x00, // Logical_Minimum (0)
USAGE(1), 0x04, // Usage (Joystick)
COLLECTION(1), 0x01, // Application
USAGE_PAGE(1), 0x01, // Generic Desktop
USAGE(1), 0x01, // Usage (Pointer)
COLLECTION(1), 0x00, // Physical
USAGE(1), 0x30, // X, wheel angle
USAGE(1), 0x31, // Y, always 0
//pedals etc
USAGE(1), 0x32, // Z
USAGE(1), 0x33, // Rx
USAGE(1), 0x34, // Ry
USAGE(1), 0x35, // Rz
USAGE(1), 0x36, // Rz
USAGE(1), 0x37, // Rz
// 16 bit values
LOGICAL_MINIMUM(2), 0x01, 0x80, // -32767
LOGICAL_MAXIMUM(2), 0xff, 0x7f, // 32767
REPORT_SIZE(1), 0x10,
REPORT_COUNT(1), 0x08,
INPUT(1), 0x02, // Data, Variable, Absolute
END_COLLECTION(0),
USAGE_PAGE(1), 0x09, // Buttons
USAGE_MINIMUM(1), 0x01, // 1
USAGE_MAXIMUM(1), 0x20, // 32
LOGICAL_MINIMUM(1), 0x00, // 0
LOGICAL_MAXIMUM(1), 0x01, // 1
REPORT_SIZE(1), 0x01,
REPORT_COUNT(1), 0x20,
UNIT_EXPONENT(1), 0x00, // Unit_Exponent (0)
UNIT(1), 0x00, // Unit (None)
INPUT(1), 0x02, // Data, Variable, Absolute
END_COLLECTION(0)
};
reportLength = sizeof(reportDescriptor);
return reportDescriptor;
}
示例7: main
int main(int argc, char **argv)
{
// if (argc < 3)
// {
// USAGE(argv[0]);
// return EXIT_FAILURE;
// }
// // check if we should set broker ip file(s)
// if (argc > 3)
// setFile(BROKERTXT, argv[3]);
// if (argc > 4)
// setFile(BROKER2TXT, argv[4]);
// char *phpScript = argv[1];
int numProcesses = atoi(argv[1]);
if (numProcesses > MAX || numProcesses <= 0)
{
USAGE(argv[0]);
return EXIT_FAILURE;
}
executeScripts(RECEIVER_GET, numProcesses);
executeScripts(RECEIVER_MODIFY, numProcesses);
executeScripts(RECEIVER_RENAME, numProcesses);
executeScripts(RECEIVER_SEARCH, numProcesses);
return EXIT_SUCCESS;
}
示例8: unrrdu_flipMain
int
unrrdu_flipMain(int argc, char **argv, char *me, hestParm *hparm) {
hestOpt *opt = NULL;
char *out, *err;
Nrrd *nin, *nout;
int pret;
unsigned int axis;
airArray *mop;
OPT_ADD_AXIS(axis, "axis to flip along");
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
USAGE(_unrrdu_flipInfoL);
PARSE();
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
if (nrrdFlip(nout, nin, axis)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error flipping nrrd:\n%s", me, err);
airMopError(mop);
return 1;
}
SAVE(out, nout, NULL);
airMopOkay(mop);
return 0;
}
示例9: unrrdu_shuffleMain
int
unrrdu_shuffleMain(int argc, const char **argv, const char *me,
hestParm *hparm) {
hestOpt *opt = NULL;
char *out, *err;
Nrrd *nin, *nout;
unsigned int di, axis, permLen, *perm, *iperm, *whichperm;
size_t *realperm;
int inverse, pret;
airArray *mop;
/* so that long permutations can be read from file */
hparm->respFileEnable = AIR_TRUE;
hestOptAdd(&opt, "p,permute", "slc0 slc1", airTypeUInt, 1, -1, &perm, NULL,
"new slice ordering", &permLen);
hestOptAdd(&opt, "inv,inverse", NULL, airTypeInt, 0, 0, &inverse, NULL,
"use inverse of given permutation");
OPT_ADD_AXIS(axis, "axis to shuffle along");
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
USAGE(_unrrdu_shuffleInfoL);
PARSE();
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
/* we have to do error checking on axis in order to do error
checking on length of permutation */
if (!( axis < nin->dim )) {
fprintf(stderr, "%s: axis %d not in valid range [0,%d]\n",
me, axis, nin->dim-1);
airMopError(mop);
return 1;
}
if (!( permLen == nin->axis[axis].size )) {
char stmp[AIR_STRLEN_SMALL];
fprintf(stderr, "%s: permutation length (%u) != axis %d's size (%s)\n",
me, permLen, axis,
airSprintSize_t(stmp, nin->axis[axis].size));
airMopError(mop);
return 1;
}
if (inverse) {
iperm = AIR_CALLOC(permLen, unsigned int);
airMopAdd(mop, iperm, airFree, airMopAlways);
if (nrrdInvertPerm(iperm, perm, permLen)) {
fprintf(stderr,
"%s: couldn't compute inverse of given permutation\n", me);
airMopError(mop);
return 1;
}
whichperm = iperm;
} else {
示例10: unrrdu_axdeleteMain
int
unrrdu_axdeleteMain(int argc, char **argv, char *me, hestParm *hparm) {
hestOpt *opt = NULL;
char *out, *err;
Nrrd *nin, *nout, *ntmp;
int pret, _axis;
unsigned axis;
airArray *mop;
hestOptAdd(&opt, "a,axis", "axis", airTypeInt, 1, 1, &_axis, NULL,
"dimension (axis index) of the axis to remove");
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
USAGE(_unrrdu_axdeleteInfoL);
PARSE();
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
if (-1 == _axis) {
ntmp = nrrdNew();
airMopAdd(mop, ntmp, (airMopper)nrrdNuke, airMopAlways);
if (nrrdCopy(nout, nin)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error copying axis:\n%s", me, err);
airMopError(mop); return 1;
}
for (axis=0;
axis<nout->dim && nout->axis[axis].size > 1;
axis++);
while (axis<nout->dim) {
if (nrrdAxesDelete(ntmp, nout, axis)
|| nrrdCopy(nout, ntmp)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error deleting axis:\n%s", me, err);
airMopError(mop); return 1;
}
for (axis=0;
axis<nout->dim && nout->axis[axis].size > 1;
axis++);
}
} else {
if (nrrdAxesDelete(nout, nin, _axis)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error deleting axis:\n%s", me, err);
airMopError(mop); return 1;
}
}
SAVE(out, nout, NULL);
airMopOkay(mop);
return 0;
}
示例11: doUsageOpt
/*
* Create the static procedure(s) declared above.
*/
static void
doUsageOpt(
tOptions* pOptions,
tOptDesc* pOptDesc )
{
(void)pOptions;
USAGE( EXIT_SUCCESS );
}
示例12: doOptInraw
/**
* Code to handle the inraw option.
*
* @param pOptions the danetool options data structure
* @param pOptDesc the option descriptor for this option.
*/
static void
doOptInraw(tOptions* pOptions, tOptDesc* pOptDesc)
{
int res = optionAlias(pOptions, pOptDesc, INDEX_OPT_INDER);
if ((res != 0) && ((pOptions->fOptSet & OPTPROC_ERRSTOP) != 0))
USAGE(DANETOOL_EXIT_FAILURE);
}
示例13: tend_evecrgbMain
int
tend_evecrgbMain(int argc, char **argv, char *me, hestParm *hparm) {
int pret;
hestOpt *hopt = NULL;
char *perr, *err;
airArray *mop;
tenEvecRGBParm *rgbp;
Nrrd *nin, *nout;
char *outS;
mop = airMopNew();
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
rgbp = tenEvecRGBParmNew();
airMopAdd(mop, rgbp, AIR_CAST(airMopper, tenEvecRGBParmNix), airMopAlways);
hestOptAdd(&hopt, "c", "evec index", airTypeUInt, 1, 1, &(rgbp->which), NULL,
"which eigenvector will be colored. \"0\" for the "
"principal, \"1\" for the middle, \"2\" for the minor");
hestOptAdd(&hopt, "a", "aniso", airTypeEnum, 1, 1, &(rgbp->aniso), NULL,
"Which anisotropy to use for modulating the saturation "
"of the colors. " TEN_ANISO_DESC,
NULL, tenAniso);
hestOptAdd(&hopt, "t", "thresh", airTypeDouble, 1, 1, &(rgbp->confThresh),
"0.5", "confidence threshold");
hestOptAdd(&hopt, "bg", "background", airTypeDouble, 1, 1, &(rgbp->bgGray),
"0", "gray level to use for voxels who's confidence is zero ");
hestOptAdd(&hopt, "gr", "gray", airTypeDouble, 1, 1, &(rgbp->isoGray), "0",
"the gray level to desaturate towards as anisotropy "
"decreases (while confidence remains 1.0)");
hestOptAdd(&hopt, "gam", "gamma", airTypeDouble, 1, 1, &(rgbp->gamma), "1",
"gamma to use on color components");
hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-",
"input diffusion tensor volume", NULL, NULL, nrrdHestNrrd);
hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
"output image (floating point)");
USAGE(_tend_evecrgbInfoL);
PARSE();
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
if (tenEvecRGB(nout, nin, rgbp)) {
airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
fprintf(stderr, "%s: trouble doing colormapping:\n%s\n", me, err);
airMopError(mop); return 1;
}
if (nrrdSave(outS, nout, NULL)) {
airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble writing:\n%s\n", me, err);
airMopError(mop); return 1;
}
airMopOkay(mop);
return 0;
}
示例14: unrrdu_dataMain
int
unrrdu_dataMain(int argc, const char **argv, const char *me,
hestParm *hparm) {
hestOpt *opt = NULL;
char *err, *inS=NULL;
Nrrd *nin;
NrrdIoState *nio;
airArray *mop;
int car, pret;
mop = airMopNew();
hestOptAdd(&opt, NULL, "nin", airTypeString, 1, 1, &inS, NULL,
"input nrrd");
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
USAGE(_unrrdu_dataInfoL);
PARSE();
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
nio = nrrdIoStateNew();
airMopAdd(mop, nio, (airMopper)nrrdIoStateNix, airMopAlways);
nio->skipData = AIR_TRUE;
nio->keepNrrdDataFileOpen = AIR_TRUE;
nin = nrrdNew();
airMopAdd(mop, nin, (airMopper)nrrdNuke, airMopAlways);
if (nrrdLoad(nin, inS, nio)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error reading header:\n%s", me, err);
airMopError(mop);
return 1;
}
if (_nrrdDataFNNumber(nio) > 1) {
fprintf(stderr, "%s: sorry, currently can't operate with multiple "
"detached datafiles\n", me);
airMopError(mop);
return 1;
}
if (!( nrrdFormatNRRD == nio->format )) {
fprintf(stderr, "%s: can only print data of NRRD format files\n", me);
airMopError(mop); return 1;
}
car = fgetc(nio->dataFile);
#ifdef _MSC_VER
/* needed because otherwise printing a carraige return will
automatically also produce a newline */
_setmode(_fileno(stdout), _O_BINARY);
#endif
while (EOF != car) {
fputc(car, stdout);
car = fgetc(nio->dataFile);
}
airFclose(nio->dataFile);
airMopOkay(mop);
return 0;
}
示例15: unrrdu_ccfindMain
int
unrrdu_ccfindMain(int argc, char **argv, char *me, hestParm *hparm) {
hestOpt *opt = NULL;
char *out, *err, *valS;
Nrrd *nin, *nout, *nval=NULL;
airArray *mop;
int type, pret;
unsigned int conny;
hestOptAdd(&opt, "v,values", "filename", airTypeString, 1, 1, &valS, "",
"Giving a filename here allows you to save out the values "
"associated with each connect component. This can be used "
"later with \"ccmerge -d\". By default, no record of the "
"original CC values is kept.");
hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default",
"type to use for output, to store the CC ID values. By default "
"(not using this option), the type used will be the smallest of "
"uchar, ushort, or int, that can represent all the CC ID values. "
"Using this option allows one to specify the integral type to "
"be used.",
NULL, NULL, &unrrduHestMaybeTypeCB);
hestOptAdd(&opt, "c,connect", "connectivity", airTypeUInt, 1, 1,
&conny, NULL,
"what kind of connectivity to use: the number of coordinates "
"that vary in order to traverse the neighborhood of a given "
"sample. In 2D: \"1\": 4-connected, \"2\": 8-connected");
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
USAGE(_unrrdu_ccfindInfoL);
PARSE();
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
if (nrrdCCFind(nout, airStrlen(valS) ? &nval : NULL, nin, type, conny)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error doing connected components:\n%s", me, err);
airMopError(mop);
return 1;
}
if (nval) {
airMopAdd(mop, nval, (airMopper)nrrdNuke, airMopAlways);
}
if (airStrlen(valS)) {
SAVE(valS, nval, NULL);
}
SAVE(out, nout, NULL);
airMopOkay(mop);
return 0;
}