static char *ptymopen(int *master) { char *slave=0; # if _lib__getpty return(_getpty(master,O_RDWR,MODE_666,0)); # else # if defined(_pty_clone) *master = open(_pty_clone,O_RDWR|O_CREAT,MODE_666); if(*master>=0) slave = ptsname(*master); # else int fdm; char *name=0; while(name=master_name(name)) { fdm = open(name,O_RDWR|O_CREAT,MODE_666); if(fdm >= 0) { *master = fdm; # if _lib_ptsname slave = ptsname(fdm); # else slave = slavename(name); # endif break; } } # endif # endif return(slave); }
int main(int argc, char* argv[]) { int ch, conn_timeout = 10, rw_timeout = 10; acl::string addr("127.0.0.1:26379"), cmd("master"); acl::string master_name("mymaster"); while ((ch = getopt(argc, argv, "hs:n:C:T:a:")) > 0) { switch (ch) { case 'h': usage(argv[0]); return 0; case 's': addr = optarg; break; case 'C': conn_timeout = atoi(optarg); break; case 'T': rw_timeout = atoi(optarg); break; case 'a': cmd = optarg; break; default: break; } } acl::acl_cpp_init(); acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); acl::redis_sentinel sentinel(&client); if (cmd == "master") sentinel_master(sentinel, master_name); else if (cmd == "masters") sentinel_masters(sentinel); else printf("unknown cmd=%s\r\n", cmd.c_str()); #ifdef WIN32 printf("enter any key to exit\r\n"); getchar(); #endif return 0; }