예제 #1
0
//TODO webserver_mode,              webserver_index_function,
//     webserver_whitelist_address, webserver_whitelist_netmask,
//     sqlslaveof
//     lua_output_start lua_output_cnames lua_output_row rest_api_mode
void DXDB_configGetCommand(redisClient *c, char *pattern, int *matches) {
    if (stringmatch(pattern, "luacronfunc", 0)) {
        addReplyBulkCString(c, "luafronfunc");
        addReplyBulkCString(c, server.alc.LuaCronFunc);
        *matches = *matches + 1;
    }
    if (stringmatch(pattern, "outputmode", 0)) {
        addReplyBulkCString(c, "outputmode");
        if      (EREDIS) addReplyBulkCString(c, "embedded");
        else if (OREDIS) addReplyBulkCString(c, "pure_redis");
        else if (LREDIS) addReplyBulkCString(c, "lua");
        else             addReplyBulkCString(c, "normal");
        *matches = *matches + 1;
    }
}
예제 #2
0
boolean parser(char *s) /* Obey command s */
{  myuint i;
   char c[maxlen];
   spacesplit(s,c);
   i=stringmatch(c,commands,nocomms);
   if(i)return (*comfuncs[i-1])(s) ;
   printf("\n Bad command (%s)",c);
   return false;
}
예제 #3
0
파일: txtelite-1.4.c 프로젝트: qial/galaxy
boolean dobuy(char *s) /* Buy ammount S(2) of good S(1) */
{	uint i,a,t;
  char s2[maxlen];
  spacesplit(s,s2);
	a=(uint)atoi(s);
  if (a==0) a=1;
	i=stringmatch(s2,tradnames,lasttrade+1);
  if(i==0) { printf("\nUnknown trade good"); return false; } 
  i-=1;

  t=gamebuy(i,a);
	if(t==0) printf("Cannot buy any ");
  else
  { printf("\nBuying %i",t);
    printf(unitnames[commodities[i].units]);
    printf(" of ");
  }
  printf(tradnames[i]);
  return true;
}
예제 #4
0
/*
 * match all entries in the directory variable path points to
 * against the key.
 * This function sets the global variable nomanfilefound
 */
void matchfilename(char *path, char *key)
{
        char *manname;
        int d;
	DIR *dp;
	struct dirent *entry;
	if ((dp = opendir(path)) != NULL) {
                while ((entry = readdir(dp)) != NULL) {
                        /*ignore . or .. or .file: */
                        if (*(entry->d_name) == '.') continue; 
                        /* xxxxx.1.gz ->xxxxx :*/
                        manname=removemanextesions(entry->d_name); 
                        d=stringmatch(manname,key);
                        if (d != -1){
                                if (printdist) printf("%03d ",d);
                                printf("%s/%s\n", path, entry->d_name);
                                nomanfilefound = 0;
                        }
                }
                closedir(dp);
        }
}
예제 #5
0
boolean dosell(char *s) /* Sell amount S(2) of good S(1) */
{	myuint i,a,t;
  char s2[maxlen];
  spacesplit(s,s2);
  a=(myuint)atoi(s);
  if (a==0) {a=1;}
  i=stringmatch(s2,tradnames,lasttrade+1);
  if(i==0) { printf("\nUnknown trade good"); return false; } 
  i-=1;
 
  t=gamesell(i,a);

  if(t==0) { printf("Cannot sell any "); }
  else
  {	printf("\nSelling %i",t);
    printf("%s",unitnames[commodities[i].units]);
    printf(" of ");
  }
    printf("%s",tradnames[i]);

    return true;

}
예제 #6
0
/*---------------------------------------------------------------*/
int main(int argc, char **argv) {
  void *pVal;
  IMAFILEINFO *ifi;
  int nargs;

  /* rkt: check for and handle version tag */
  nargs = handle_version_option (argc, argv, "$Id: mri_probe_ima.c,v 1.13 2011/03/02 00:04:24 nicks Exp $", "$Name:  $");
  if (nargs && argc - nargs == 1)
    exit (0);
  argc -= nargs;

  tmpstr[0] = 'a'; /* to stop compiler warning */

  Progname = argv[0] ;
  argc --;
  argv++;
  ErrorInit(NULL, NULL, NULL) ;
  DiagInit(NULL, NULL, NULL) ;

  if (argc == 0) usage_exit();

  parse_commandline(argc, argv);
  check_options();

  if (getattr) {
    if (stringmatch(attrname,"isima")) {
      printf("%d\n",imaIsSiemensIMA(imafile));
      return(0);
      exit(0);
    }
  }

  if (! imaIsSiemensIMA(imafile) ) {
    printf("WARNING: %s does not seem to be a Siemens IMA file\n",imafile);
  }

  MkImaDictionary();

  if (dumpfileinfo) {
    ifi = imaLoadFileInfo(imafile);
    imaDumpFileInfo(stdout,ifi);
    return(0);
    exit(0);
  }

  if (getattr) {
    ifi = imaLoadFileInfo(imafile);
    if (stringmatch(attrname,"studydate")) {
      printf("%s\n",ifi->StudyDate);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"studytime")) {
      printf("%s\n",ifi->StudyTime);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"voldim")) {
      printf("%d %d %d\n",ifi->VolDim[0],ifi->VolDim[1],ifi->VolDim[2]);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"volres")) {
      printf("%g %g %g\n",ifi->VolRes[0],ifi->VolRes[1],ifi->VolRes[2]);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"nframes")) {
      printf("%d\n",ifi->NFrames);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"tr")) {
      printf("%g\n",ifi->RepetitionTime);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"pulseseq")) {
      printf("%s\n",ifi->PulseSequence);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"patname")) {
      printf("%s\n",ifi->PatientName);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"patdob")) {
      printf("%s\n",ifi->PatientDOB);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"patgender")) {
      printf("%s\n",ifi->PatientGender);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"ismosaic")) {
      printf("%d\n",ifi->IsMosaic);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"nfilesact")) {
      printf("%d\n",ifi->NFilesInSeries);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"nfilesexp")) {
      printf("%d\n",ifi->NFilesInSeriesExp);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"nfilesperframe")) {
      printf("%d\n",ifi->NFilesPerFrame);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"error")) {
      printf("%d\n",ifi->ErrorFlag);
      return(0);
      exit(0);
    }
    if (stringmatch(attrname,"pixeldata")) {
      npixels = ifi->NImageRows * ifi->NImageCols;
      pixeldata = imaReadPixelData(ifi,NULL);
      if (pixeldata == NULL) {
        printf("ERROR: could not read pixel data\n");
        exit(1);
      }

      sprintf(tmpstr,"%s_000.bshort",bstem);
      fp = fopen(tmpstr,"w");
      if (fp == NULL) {
        printf("ERROR: cannot open %s for writing\n",tmpstr);
        exit(1);
      }
      fwrite(pixeldata, sizeof(short), npixels, fp);
      fclose(fp);

      sprintf(tmpstr,"%s_000.hdr",bstem);
      fp = fopen(tmpstr,"w");
      if (fp == NULL) {
        printf("ERROR: cannot open %s for writing\n",tmpstr);
        exit(1);
      }
      fprintf(fp,"%d %d 1 %d\n",ifi->NImageRows,ifi->NImageCols,Arch486());
      fclose(fp);

      return(0);
      exit(0);
    }


    printf("ERROR: attribute %s not recognized\n",attrname);
    return(1);
    exit(1);
  }

  fp = fopen(imafile,"r");
  if (fp == NULL) {
    printf("ERROR: could not open %s\n",imafile);
    exit(1);
  }

  if (keyno > -1) key = ImaDictionary[keyno].key;
  if (key != NULL) {
    pVal = imaLoadValFromKey(fp,key,NULL);
    type = imaTypeFromKey(key);
    imaPrintVal(stdout, type, pVal);
    return(0);
    exit(0);
  }

  if (offset > -1) {
    type = imaTypeFromString(typestring);
    typesize = imaTypeSize[type];
    if (debug)
      printf("type = %s (%d), offset = %d\n",typestring,type,offset);
    pVal = imaLoadVal(fp,offset,typesize,stringlen,NULL);
    imaPrintVal(stdout, type, pVal);
    printf("\n");
    return(0);
    exit(0);
  }

  DumpImaDictionaryVal(stdout, imafile);

  fclose(fp);
  return(0);

}