Пример #1
0
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
0
/**
 * 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
0
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
0
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
0
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; 
}
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
0
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
0
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
0
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
0
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
0
/*
 *  Create the static procedure(s) declared above.
 */
static void
doUsageOpt(
    tOptions*   pOptions,
    tOptDesc*   pOptDesc )
{
    (void)pOptions;
    USAGE( EXIT_SUCCESS );
}
Пример #12
0
/**
 * 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);

}
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
0
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
0
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;
}
Пример #16
0
int main(int argc, char **argv) {
	if(argc<=2) USAGE();
	std::string out = argv[1];

	mkdir((const std::string&)argv[argc-1]);
	for(int i=1; i<argc-1; i++) index_file(argv[i], argv[argc-1]);

	return 0;
}
Пример #17
0
int
unrrdu_spliceMain(int argc, char **argv, char *me, hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout, *nslice;
  unsigned int axis;
  int pret;
  long int _pos[2];
  size_t pos;
  airArray *mop;

  OPT_ADD_AXIS(axis, "axis to splice along");
  hestOptAdd(&opt, "p,position", "pos", airTypeOther, 1, 1, _pos, NULL,
             "position to splice at:\n "
             "\b\bo <int> gives 0-based index\n "
             "\b\bo M-<int> give index relative "
             "to the last sample on the axis (M == #samples-1).",
             NULL, NULL, &unrrduHestPosCB);
  hestOptAdd(&opt, "s,slice", "nslice", airTypeOther, 1, 1, &(nslice), NULL,
             "slice nrrd.  This the slice to be inserted in \"nin\"",
             NULL, NULL, nrrdHestNrrd);
  OPT_ADD_NIN(nin, "input nrrd.  This the nrrd into which the slice will "
              "be inserted");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_spliceInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
  if (!( axis < nin->dim )) {
    fprintf(stderr, "%s: axis %u not in range [0,%u]\n", me, axis, nin->dim-1);
    return 1;
  }
  if (_pos[0] == -1) {
    fprintf(stderr, "%s: m+<int> specification format meaningless here\n", me);
    return 1;
  }
  pos = _pos[0]*(nin->axis[axis].size-1) + _pos[1];

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdSplice(nout, nin, nslice, axis, pos)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error splicing nrrd:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #18
0
int
limnpu_rastMain(int argc, const char **argv, const char *me,
                hestParm *hparm) {
  hestOpt *hopt = NULL;
  char *err, *perr;
  airArray *mop;
  int pret;

  limnPolyData *pld;
  double min[3], max[3];
  Nrrd *nout;
  char *out;
  int type;
  size_t size[NRRD_DIM_MAX];

  hestOptAdd(&hopt, "min", "min", airTypeDouble, 3, 3, min, NULL,
             "bottom corner");
  hestOptAdd(&hopt, "max", "max", airTypeDouble, 3, 3, max, NULL,
             "top corner");
  hestOptAdd(&hopt, "s", "size", airTypeSize_t, 3, 3, size, NULL,
             "number of samples along each axis");
  hestOptAdd(&hopt, "t", "type", airTypeEnum, 1, 1, &type, "uchar",
             "type of output nrrd",
             NULL, nrrdType);
  hestOptAdd(&hopt, NULL, "input", airTypeOther, 1, 1, &pld, NULL,
             "input polydata filename",
             NULL, NULL, limnHestPolyDataLMPD);
  hestOptAdd(&hopt, NULL, "output", airTypeString, 1, 1, &out, NULL,
             "output nrrd filename");

  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);

  USAGE(myinfo);
  PARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (limnPolyDataRasterize(nout, pld, min, max, size, type)) {
    airMopAdd(mop, err = biffGetDone(LIMN), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble:%s", me, err);
    airMopError(mop);
    return 1;
  }
  if (nrrdSave(out, nout, NULL)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble:%s", me, err);
    airMopError(mop);
    return 1;
  }

  airMopOkay(mop);
  return 0;
}
Пример #19
0
int
tend_anplotMain(int argc, const char **argv, const char *me,
                hestParm *hparm) {
  int pret;
  hestOpt *hopt = NULL;
  char *perr, *err;
  airArray *mop;

  int res, aniso, whole, nanout, hflip;
  Nrrd *nout;
  char *outS;

  hestOptAdd(&hopt, "r", "res", airTypeInt, 1, 1, &res, "256",
             "resolution of anisotropy plot");
  hestOptAdd(&hopt, "w", NULL, airTypeInt, 0, 0, &whole, NULL,
             "sample the whole triangle of constant trace, "
             "instead of just the "
             "sixth of it in which the eigenvalues have the "
             "traditional sorted order. ");
  hestOptAdd(&hopt, "hflip", NULL, airTypeInt, 0, 0, &hflip, NULL,
             "flip the two bottom corners (swapping the place of "
             "linear and planar)");
  hestOptAdd(&hopt, "nan", NULL, airTypeInt, 0, 0, &nanout, NULL,
             "set the pixel values outside the triangle to be NaN, "
             "instead of 0");
  hestOptAdd(&hopt, "a", "aniso", airTypeEnum, 1, 1, &aniso, NULL,
             "Which anisotropy metric to plot.  " TEN_ANISO_DESC,
             NULL, tenAniso);
  hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
             "output image (floating point)");

  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
  USAGE(_tend_anplotInfoL);
  JUSTPARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
  if (tenAnisoPlot(nout, aniso, res, hflip, whole, nanout)) {
    airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble making plot:\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;
}
Пример #20
0
int
unrrdu_histaxMain(int argc, char **argv, char *me, hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  int type, bins, pret, blind8BitRange;
  unsigned int axis;
  double min, max;
  airArray *mop;
  NrrdRange *range;

  OPT_ADD_AXIS(axis, "axis to histogram along");
  hestOptAdd(&opt, "b,bin", "bins", airTypeInt, 1, 1, &bins, NULL,
             "# of bins in histogram");
  OPT_ADD_TYPE(type, "output type", "uchar");
  hestOptAdd(&opt, "min,minimum", "value", airTypeDouble, 1, 1, &min, "nan",
             "Value at low end of histogram. Defaults to lowest value "
             "found in input nrrd.");
  hestOptAdd(&opt, "max,maximum", "value", airTypeDouble, 1, 1, &max, "nan",
             "Value at high end of histogram. Defaults to highest value "
             "found in input nrrd.");
  hestOptAdd(&opt, "blind8", "bool", airTypeBool, 1, 1, &blind8BitRange,
             nrrdStateBlind8BitRange ? "true" : "false",
             "Whether to know the range of 8-bit data blindly "
             "(uchar is always [0,255], signed char is [-128,127]).");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_histaxInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  range = nrrdRangeNew(min, max);
  airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways);
  nrrdRangeSafeSet(range, nin, blind8BitRange);
  if (nrrdHistoAxis(nout, nin, range, axis, bins, type)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error doing axis histogramming:\n%s", me, err);
    airMopError(mop);
    return 1;
  }
  

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #21
0
int
unrrdu_dhistoMain(int argc, const char **argv, const char *me,
                  hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  int pret, nolog, notick;
  unsigned int size;
  airArray *mop;
  double max;

  hestOptAdd(&opt, "h,height", "height", airTypeUInt, 1, 1, &size, NULL,
             "height of output image (horizontal size is determined by "
             "number of bins in input histogram).");
  hestOptAdd(&opt, "nolog", NULL, airTypeInt, 0, 0, &nolog, NULL,
             "do not show the log-scaled histogram with decade tick-marks");
  hestOptAdd(&opt, "notick", NULL, airTypeInt, 0, 0, &notick, NULL,
             "do not draw the log decade tick marks");
  hestOptAdd(&opt, "max,maximum", "max # hits", airTypeDouble, 1, 1,
             &max, "nan",
             "constrain the top of the drawn histogram to be at this "
             "number of hits.  This will either scale the drawn histogram "
             "downward or clip its top, depending on whether the given max "
             "is higher or lower than the actual maximum bin count.  By "
             "not using this option (the default), the actual maximum bin "
             "count is used");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_dhistoInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdHistoDraw(nout, nin, size,
                    nolog ? AIR_FALSE : (notick ? 2 : AIR_TRUE),
                    max)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error drawing histogram nrrd:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #22
0
int main(int argc, char **argv)
{
	int ret;

	if ((ret = gnutls_global_init()) < 0) {
		fprintf(stderr, "global_init: %s\n", gnutls_strerror(ret));
		exit(1);
	}

	optionProcess(&ocsptoolOptions, argc, argv);

	gnutls_global_set_log_function(tls_log_func);
	gnutls_global_set_log_level(OPT_VALUE_DEBUG);

	if (HAVE_OPT(OUTFILE)) {
		outfile = fopen(OPT_ARG(OUTFILE), "wb");
		if (outfile == NULL) {
			fprintf(stderr, "%s\n", OPT_ARG(OUTFILE));
			exit(1);
		}
	} else
		outfile = stdout;

	if (HAVE_OPT(INFILE)) {
		infile = fopen(OPT_ARG(INFILE), "rb");
		if (infile == NULL) {
			fprintf(stderr, "%s\n", OPT_ARG(INFILE));
			exit(1);
		}
	} else
		infile = stdin;

	if (ENABLED_OPT(INDER))
		encoding = GNUTLS_X509_FMT_DER;
	else
		encoding = GNUTLS_X509_FMT_PEM;

	if (HAVE_OPT(REQUEST_INFO))
		request_info();
	else if (HAVE_OPT(RESPONSE_INFO))
		response_info();
	else if (HAVE_OPT(GENERATE_REQUEST))
		generate_request(NULL);
	else if (HAVE_OPT(VERIFY_RESPONSE))
		verify_response(NULL);
	else if (HAVE_OPT(ASK))
		ask_server(OPT_ARG(ASK));
	else {
		USAGE(1);
	}

	return 0;
}
Пример #23
0
int
tend_anhistMain(int argc, char **argv, char *me, hestParm *hparm) {
  int pret;
  hestOpt *hopt = NULL;
  char *perr, *err;
  airArray *mop;

  int version, res, right;
  Nrrd *nin, *nout, *nwght;
  char *outS;

  hestOptAdd(&hopt, "v", "westin version", airTypeInt, 1, 1, &version, "1",
             "Which version of Westin's anisotropy metric triple "
             "to use, either \"1\" or \"2\"");
  hestOptAdd(&hopt, "w", "nweight", airTypeOther, 1, 1, &nwght, "",
             "how to weigh contributions to histogram.  By default "
             "(not using this option), the increment is one bin count per "
             "sample, but by giving a nrrd, the value in the nrrd at the "
             "corresponding location will be the bin count increment ",
             NULL, NULL, nrrdHestNrrd);
  hestOptAdd(&hopt, "r", "res", airTypeInt, 1, 1, &res, NULL,
             "resolution of anisotropy plot");
  hestOptAdd(&hopt, "right", NULL, airTypeInt, 0, 0, &right, NULL,
             "sample a right-triangle-shaped region, instead of "
             "a roughly equilateral triangle. ");
  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)");

  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
  USAGE(_tend_anhistInfoL);
  PARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (tenAnisoHistogram(nout, nin, nwght, right, version, res)) {
    airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble making histogram:\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;
}
Пример #24
0
int
unrrdu_axmergeMain(int argc, const char **argv, const char *me,
                   hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout[2];
  int *axes, pret, ni;
  unsigned int ii, jj, axesLen;
  airArray *mop;

  hestOptAdd(&opt, "a,axis", "ax0", airTypeInt, 1, -1, &axes, NULL,
             "axis (or axes) to merge.  Each axis index identified is the "
             "lower of the pair of axes that will be merged.  Saying \"-a 2\" "
             "means to merge axis 2 and axis 3 into axis 2.  If multiple "
             "merges are to be done, the indices listed here are for "
             "the axes prior to any merging.", &axesLen);
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_axmergeInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  airMopAdd(mop, nout[0]=nrrdNew(), (airMopper)nrrdNuke, airMopAlways);
  airMopAdd(mop, nout[1]=nrrdNew(), (airMopper)nrrdNuke, airMopAlways);

  if (axesLen > 1) {
    /* sort merge axes into ascending order */
    qsort(axes, axesLen, sizeof(*axes), nrrdValCompare[nrrdTypeInt]);
  }

  ni = 0;
  for (ii=0; ii<axesLen; ii++) {
    if (nrrdAxesMerge(nout[ni], !ii ? nin : nout[1-ni], axes[ii])) {
      airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
      fprintf(stderr, "%s: error merging axes:\n%s", me, err);
      airMopError(mop);
      return 1;
    }
    for (jj=ii+1; jj<axesLen; jj++) {
      axes[jj] -= 1;
    }
    ni = 1-ni;
  }

  SAVE(out, nout[1-ni], NULL);

  airMopOkay(mop);
  return 0;
}
Пример #25
0
int
unrrdu_distMain(int argc, char **argv, char *me, hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  int pret;

  int E, typeOut, invert, sign;
  double thresh;
  airArray *mop;

  hestOptAdd(&opt, "th,thresh", "val", airTypeDouble, 1, 1, &thresh, NULL,
             "threshold value to separate inside from outside");
  hestOptAdd(&opt, "t,type", "type", airTypeEnum, 1, 1, &typeOut, "float",
             "type to save output in", NULL, nrrdType);
  hestOptAdd(&opt, "sgn", NULL, airTypeInt, 0, 0, &sign, NULL,
             "also compute signed (negative) distances inside objects, "
             "instead of leaving them as zero");
  hestOptAdd(&opt, "inv", NULL, airTypeInt, 0, 0, &invert, NULL,
             "values *below* threshold are considered interior to object. "
             "By default (not using this option), values above threshold "
             "are considered interior. ");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_distInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (sign) {
    E = nrrdDistanceL2Signed(nout, nin, typeOut, NULL, thresh, !invert);
  } else {
    E = nrrdDistanceL2(nout, nin, typeOut, NULL, thresh, !invert);
  }
  if (E) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error doing distance transform:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #26
0
int
tend_evqMain(int argc, char **argv, char *me, hestParm *hparm) {
  int pret;
  hestOpt *hopt = NULL;
  char *perr, *err;
  airArray *mop;

  int which, aniso, dontScaleByAniso;
  Nrrd *nin, *nout;
  char *outS;

  hestOptAdd(&hopt, "c", "evec index", airTypeInt, 1, 1, &which, "0",
             "Which eigenvector should be quantized: \"0\" for the "
             "direction of fastest diffusion (eigenvector associated "
             "with largest eigenvalue), \"1\" or \"2\" for other two "
             "eigenvectors (associated with middle and smallest eigenvalue)");
  hestOptAdd(&hopt, "a", "aniso", airTypeEnum, 1, 1, &aniso, NULL,
             "Which anisotropy metric to scale the eigenvector "
             "with.  " TEN_ANISO_DESC,
             NULL, tenAniso);
  hestOptAdd(&hopt, "ns", NULL, airTypeInt, 0, 0, &dontScaleByAniso, NULL,
             "Don't attenuate the color by anisotropy.  By default (not "
             "using this option), regions with low or no anisotropy are "
             "very dark colors or black");
  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)");

  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
  USAGE(_tend_evqInfoL);
  PARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
  if (tenEvqVolume(nout, nin, which, aniso, !dontScaleByAniso)) {
    airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble quantizing eigenvectors:\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;
}
Пример #27
0
int
unrrdu_gammaMain(int argc, const char **argv, const char *me,
                 hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  double min, max, gamma;
  airArray *mop;
  int pret, blind8BitRange;
  NrrdRange *range;

  hestOptAdd(&opt, "g,gamma", "gamma", airTypeDouble, 1, 1, &gamma, NULL,
             "gamma > 1.0 brightens; gamma < 1.0 darkens. "
             "Negative gammas invert values (like in xv). ");
  hestOptAdd(&opt, "min,minimum", "value", airTypeDouble, 1, 1, &min, "nan",
             "Value to implicitly map to 0.0 prior to calling pow(). "
             "Defaults to lowest value found in input nrrd.");
  hestOptAdd(&opt, "max,maximum", "value", airTypeDouble, 1, 1, &max, "nan",
             "Value to implicitly map to 1.0 prior to calling pow(). "
             "Defaults to highest value found in input nrrd.");
  hestOptAdd(&opt, "blind8", "bool", airTypeBool, 1, 1, &blind8BitRange,
             nrrdStateBlind8BitRange ? "true" : "false",
             "Whether to know the range of 8-bit data blindly "
             "(uchar is always [0,255], signed char is [-128,127]).");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_gammaInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  range = nrrdRangeNew(min, max);
  airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways);
  nrrdRangeSafeSet(range, nin, blind8BitRange);
  if (nrrdArithGamma(nout, nin, range, gamma)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error doing gamma:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #28
0
int
main(int argc, char *argv[])
{
	const char *path;
	int opt;

	Myname = argv[0];
	while ((opt = getopt(argc, argv, "FMd")) != -1) {
		switch (opt) {
		case 'F':
			pmem_fit_mode();
			break;

		case 'M':
			pmem_msync_mode();
			break;

		case 'd':
			Debug++;
			break;

		default:
			USAGE(NULL);
		}
	}

	if (optind >= argc)
		USAGE("No path given");
	path = argv[optind++];

	if (optind < argc)
		USAGE(NULL);

	tree_init(path, 0);

	tree_walk();

	exit(0);
}
Пример #29
0
UINT CLaunchUploadDlg::Launch(StartupParameters* parameters)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

//	UpdateManager u;
//	u.StartUpdate();

	HWND parent = 0;
	try
	{
		parent = parameters->hParentWindow;

#ifndef DEBUG
	//	MessageBox(parent, _T("Detta är en betaversion.\r\nOm den slutar fungera kan det vara för att den är så gammal att servern inte känner igen den.\r\n\r\nDu får inte sprida programmet!\r\n\r\nKlagomål eller förslag tas mer än gärna emot."), _T("Minakort.com - betatest"), MB_ICONINFORMATION|MB_OK);
#endif

		USAGE("Launch");

		CUploadDialog ctrl(CWnd::FromHandle(parameters->hParentWindow));
		ctrl.instanceName = parameters->commandLine;
		if(parameters->doDelete)
			delete parameters;
		theDlg = &ctrl;

		try 
		{
			ctrl.DoModal();
		} 
		catch(...)
		{
			theDlg = NULL;
			UploadManager::Instance().WaitStop();
			throw;
		}

		theDlg = NULL;
		UploadManager::Instance().WaitStop();
	
		return 0;
	}
	catch(CException* exc)
	{
		exc->Delete();
	}
	catch(...)
	{
	}
	MessageBox(parent, R2T(IDS_ERROROCCURED), R2T(IDS_ERROROCCURED_CAPTION), MB_ICONERROR);
	return 1;
}
Пример #30
0
int
baneGkms_miteMain(int argc, const char **argv, const char *me,
                  hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *perr;
  Nrrd *nin, *nout;
  airArray *mop;
  int pret, E;

  hestOptAdd(&opt, "i", "opacIn", airTypeOther, 1, 1, &nin, NULL,
             "input opacity function (1 or 2 dimensional), from "
             "\"gkms opac\"",
             NULL, NULL, nrrdHestNrrd);
  hestOptAdd(&opt, "o", "opacOut", airTypeString, 1, 1, &out, NULL,
             "output opacity function filename");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
  USAGE(_baneGkms_miteInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  if (1 == nin->axis[0].size && nin->axis[0].label &&
      !strcmp("A", nin->axis[0].label)) {
    fprintf(stderr, "%s: already\n", me);
    nout = nin;
  } else {
    nout = nrrdNew();
    airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
    E = 0;
    if (!E) E |= nrrdAxesInsert(nout, nin, 0);
    if (!E) E |= !(nout->axis[0].label = airStrdup("A"));
    if (!E) E |= !(nout->axis[1].label = airStrdup("gage(v)"));
    if (3 == nout->dim) {
      if (!E) E |= !(nout->axis[2].label = airStrdup("gage(gm)"));
    }
    if (E) {
      biffMovef(BANE, NRRD,
                "%s: trouble modifying opacity function nrrd", me);
      airMopError(mop); return 1;
    }
  }
  if (nrrdSave(out, nout, NULL)) {
    biffMovef(BANE, NRRD, "%s: trouble saving opacity function", me);
    airMopError(mop); return 1;
  }

  airMopOkay(mop);
  return 0;
}