int main(int argc, char **argv) { int firstarg; config.hostip = sdsnew("127.0.0.1"); config.hostport = 6379; config.hostsocket = NULL; config.repeat = 1; config.interval = 0; config.dbnum = 0; config.interactive = 0; config.shutdown = 0; config.monitor_mode = 0; config.pubsub_mode = 0; config.latency_mode = 0; config.stdinarg = 0; config.auth = NULL; config.raw_output = !isatty(fileno(stdout)) && (getenv("FAKETTY") == NULL); config.mb_delim = sdsnew("\n"); cliInitHelp(); #ifdef _WIN32 _fmode = _O_BINARY; _setmode(_fileno(stdin), _O_BINARY); _setmode(_fileno(stdout), _O_BINARY); _setmode(_fileno(stderr), _O_BINARY); if (!w32initWinSock()) { printf("Winsock init error %d", WSAGetLastError()); exit(1); }; atexit((void(*)(void)) WSACleanup); #endif firstarg = parseOptions(argc,argv); argc -= firstarg; argv += firstarg; /* Start in latency mode if appropriate */ if (config.latency_mode) { cliConnect(0); latencyMode(); } /* Start interactive mode when no command is provided */ if (argc == 0) { /* Note that in repl mode we don't abort on connection error. * A new attempt will be performed for every command send. */ cliConnect(0); repl(); } /* Otherwise, we have some arguments to execute */ if (cliConnect(0) != REDIS_OK) exit(1); return noninteractive(argc,convertToSds(argc,argv)); }
int main(int argc, char **argv) { int firstarg; config.hostip = sdsnew("127.0.0.1"); config.hostport = 6379; config.hostsocket = NULL; config.repeat = 1; config.interval = 0; config.dbnum = 0; config.interactive = 0; config.shutdown = 0; config.monitor_mode = 0; config.pubsub_mode = 0; config.latency_mode = 0; config.cluster_mode = 0; config.slave_mode = 0; config.pipe_mode = 0; config.bigkeys = 0; config.stdinarg = 0; config.auth = NULL; config.eval = NULL; if (!isatty(fileno(stdout)) && (getenv("FAKETTY") == NULL)) config.output = OUTPUT_RAW; else config.output = OUTPUT_STANDARD; config.mb_delim = sdsnew("\n"); cliInitHelp(); firstarg = parseOptions(argc,argv); argc -= firstarg; argv += firstarg; /* Latency mode */ if (config.latency_mode) { cliConnect(0); latencyMode(); } /* Slave mode */ if (config.slave_mode) { cliConnect(0); slaveMode(); } /* Pipe mode */ if (config.pipe_mode) { if (cliConnect(0) == REDIS_ERR) exit(1); pipeMode(); } /* Find big keys */ if (config.bigkeys) { cliConnect(0); findBigKeys(); } /* Start interactive mode when no command is provided */ if (argc == 0 && !config.eval) { /* Note that in repl mode we don't abort on connection error. * A new attempt will be performed for every command send. */ cliConnect(0); repl(); } /* Otherwise, we have some arguments to execute */ if (cliConnect(0) != REDIS_OK) exit(1); if (config.eval) { return evalMode(argc,argv); } else { return noninteractive(argc,convertToSds(argc,argv)); } }