Beispiel #1
0
static FILE *scanargs (int argc, char **argv, char **fname)
	{ FILE *input;
	  int ix;
	  char *name = NULL;
	  for (ix = 1; ix < argc; ix++)
	     { char *arg = argv[ix];
	       if (arg[0] == '-') scan_option (arg+1, &ix, argc, argv);
	       else if (name == NULL) name = arg;
	       else syntax_error ("too many input files specified");
	     };
	  if (name == NULL) input = stdin;
	  else if (!(input = fopen (name, "r")))
	     syntax_error ("could not open input file");
	  *fname = name;
	  return (input);
	};
Beispiel #2
0
void GetOptionFlags(int argc, char *argv[], Options &o) 
{
   //get all the options
   char currentSymbol[2048];
   scan_option(argc, argv, "-sym %s", currentSymbol);
   o.gSymbol = currentSymbol;

   o.isOption = scan_option(argc, argv, "-o") != 0;

   o.isFutures = scan_option(argc, argv, "-futures") != 0;
   o.useDB = scan_option(argc, argv, "-nodb") == 0;
   //3 options, either interval, ticks or numdays
   o.useInterval = scan_option(argc, argv, "-int %d", &o.interval) != 0;
   //if use interval, then specify something other than 1 second interval
   o.onlyTables = scan_option(argc, argv, "-onlyTables") != 0;

   //specify start and end dates
   memset(o.startDate, 0, sizeof(o.startDate));
   memset(o.endDate, 0, sizeof(o.endDate));

   char tempStartDate[64], tempEndDate[64];
   o.useDates = scan_option(argc, argv, "-d1 %s", tempStartDate) != 0;
   scan_option(argc, argv, "-d2 %s", tempEndDate);

   if (o.useDates == true) 
   {
      //convert from YYYY-mm-dd to YYYYmmdd
      int year, month, day;
      sscanf(tempStartDate, "%d-%d-%d", &year, &month, &day);
      sprintf(o.startDate, "%d%02d%02d", year, month, day);

      sscanf(tempEndDate, "%d-%d-%d", &year, &month, &day);
      sprintf(o.endDate, "%d%02d%02d", year, month, day);
   }

   o.useTicks = scan_option(argc, argv, "-tick") != 0;
   o.useDaily = scan_option(argc, argv, "-daily") != 0;

   if (o.useTicks == true && o.useDaily == true)
   {
      WriteLog("Cannot set both -tick and -daily");
      throw DataException(__FILE__, __LINE__);
   }
   else if (o.useTicks == true && o.useInterval == true)
   {
      WriteLog("Cannot set both -tick and -int");
      throw DataException(__FILE__, __LINE__);
   }
   else if (o.useInterval == true && o.useDaily == true)
   {
      WriteLog("Cannot set both -int and -daily");
      throw DataException(__FILE__, __LINE__);
   }

   o.useNumDays = scan_option(argc, argv, "-numDays %d", &o.numDays) != 0;

   o.useContract = scan_option(argc, argv, "-useContract") != 0;

   //set a single hardcoded table name so that I can dump it into something like correlate
   o.useHardcodedTable = scan_option(argc, argv, "-table %s", o.hardcodedTable) != 0;

   strcpy(o.username, defaultUsername);
   strcpy(o.password, defaultPassword);
   strcpy(o.serverName, defaultServer);
   o.specifyUsername = (scan_option(argc, argv, "-username %s", o.username) != 0);
   o.specifyPassword = (scan_option(argc, argv, "-password %s", o.password) != 0);
   scan_option(argc, argv, "-serverName %s", o.serverName);
}