/* ======================================================================== * usage() */ static void usage(int status) { printf("Spades -p-l -S \n"); exit(status); } static char * version = SPADES_NAME; int main(int argc, char **argv) { char * log_file = NULL; int debug = 0; char ch; /* Getopt variables. */ extern char *optarg; while ((ch = getopt(argc, argv, "S:p:l:dv?")) != (char)EOF) { switch (ch) { case 'd': debug++; break; case 'l': log_file = optarg; break; case 'v': printf("%s\n", version); break; case 'p': if (0 >= (Spades_port = atoi(optarg))) { printf("Illegal port '%s'.\n", optarg); usage(EINVAL); } break; case 'S': if (0 >= (score = atoi(optarg))) { printf("Illegal score '%s'.\n", optarg); usage(EINVAL); } break; case '?': usage(0); break; default: usage(EINVAL); break; } } Spades_init(SPADES_NAME); Spades_play(); Spades_done(); exit(0); }