void DoQuery(char* fileName, char *query) { char **result; WordSet *set; /*load database into the set*/ set = LoadDatabase(set, fileName); if (!set) return; /*allocate memory for the result*/ result = AllocResult(fileName, result); if (result == NULL) return; /*if null parameter is passed, go to Interactive mode*/ if (query == NULL){ printf("Interactive Mode:\n"); InteractiveMode(set, result); } else { printf("Query Mode:\n"); QueryMode(set, result, query); } /*free memory*/ free(result); FreeSet(set); }
int main(int argc, char *argv[]) { int portnumber; char *hostname = 0; void *htmsocket; argc--; argv++; if (argc == 0) { goto usageerror; } if (argc >= 1 && (strncmp(*argv, "-notypetags", 2) == 0)) { useTypeTags = 0; argv++; argc--; } if (argc >= 2 && (strncmp(*argv, "-r", 2) == 0)) { hostname = getenv("REMOTE_ADDR"); if (hostname == NULL) { complain("sendSC -r: REMOTE_ADDR not in environment\n"); exit(4); } argv++; argc--; } if (argc >= 3 && (strncmp(*argv, "-h", 2) == 0)) { hostname = argv[1]; argv += 2; argc -= 2; } portnumber = atoi(*argv); argv++; argc--; htmsocket = OpenHTMSocket(hostname, portnumber); if (!htmsocket) { perror("Couldn't open socket: "); exit(3); } if (argc > 0) { printf("host %s, port %d, %s\n", hostname, portnumber, useTypeTags ? "use type tags" : "don't use type tags"); CommandLineMode(argc, argv, htmsocket); } else { printf("sendOSC version " VERSION "\n"); printf("by Matt Wright. Copyright (c) 1996, 1997 Regents of the University of California.\n"); printf("host %s, port %d, %s\n", hostname, portnumber, useTypeTags ? "use type tags" : "don't use type tags"); InteractiveMode(htmsocket); } CloseHTMSocket(htmsocket); exit(exitStatus); usageerror: complain("usage: %s [-notypetags] [-r] [-h target_host_name] port_number [message...]\n", argv[-1]); exit(4); }