/* Relay data from stdin (0) to master_fd. * Relay data from master_fd to stdout (1). */ static void run_relay(const int master_fd) { fd_set fds, tmp_fds; unsigned int n; FD_ZERO(&fds); FD_SET(0, &fds); FD_SET(master_fd, &fds); while (1) { tmp_fds = fds; if (select(master_fd + 1, &tmp_fds, NULL, NULL, NULL) == -1) break; if (FD_ISSET(0, &tmp_fds)) { if (!relay(0, master_fd, &n)) break; if (n == 0) { /* stdin was closed by the caller. Relay the closure to the * child. */ close(master_fd); break; } } if (FD_ISSET(master_fd, &tmp_fds)) if (!relay(master_fd, 1, NULL)) break; } exit(0); }
void tcp_relay(int s_src, int s_dst, const char *service) { syslog(LOG_INFO, "starting %s relay", service); child_lastactive = parent_lastactive = time(NULL); cpid = fork(); switch (cpid) { case -1: exit_failure("tcp_relay: can't fork grand child: %s", strerror(errno)); /* NOTREACHED */ case 0: /* child process: relay going traffic */ ppid = getppid(); /* this is child so reopen log */ closelog(); openlog(logname, LOG_PID | LOG_NOWAIT, LOG_DAEMON); relay(s_src, s_dst, service, 1); /* NOTREACHED */ default: /* parent process: relay coming traffic */ ppid = (pid_t)0; signal(SIGUSR1, sig_ctimeout); signal(SIGCHLD, sig_child); relay(s_dst, s_src, service, 0); /* NOTREACHED */ } }
int main() { int fd1,fd2; // 假设这里忘记将设备 tty1 以非阻塞的形式打开也没关系,因为推动状态机之前会重新设定文件描述符为非阻塞形式 fd1 = open(TTY1,O_RDWR); if(fd1 < 0) { perror("open()"); exit(1); } write(fd1,"TTY1\n",5); fd2 = open(TTY2,O_RDWR|O_NONBLOCK); if(fd2 < 0) { perror("open()"); exit(1); } write(fd2,"TTY2\n",5); relay(fd1,fd2); close(fd1); close(fd2); exit(0); }
int main() { int fd1,fd2; fd1 = open(TTY1,O_RDWR|O_NONBLOCK); if(fd1 < 0) { perror("open()"); exit(1); } write(fd1,"TTY1\n",5); fd2 = open(TTY2,O_RDWR); if(fd2 < 0) { perror("open()"); exit(1); } write(fd2,"TTY2\n",5); relay(fd1,fd2); close(fd1); close(fd2); exit(0); }
main(int argc, char **argv) { trace("main start"); char hostName[hostNameLength]; parseArgs(argc, argv, hostName); int sock = createConnection(hostName, port_number); relay(sock); close(sock); }
void Player::ladderChange(bool n) { if (!isLoggedIn()) return;//INV BEHAV if (state()[LadderEnabled] == n) { return; } state().setFlag(LadderEnabled, n); relay().notifyOptionsChange(id(), away(), n); }
int main(int argc, char ** argv) { //required to make sure protobuf will work correctly GOOGLE_PROTOBUF_VERIFY_VERSION; //init ros ros::init(argc, argv, "ROStoPBuffRelay"); Message1Relay relay(TOPIC); relay.initROStoPBuff(); return EXIT_SUCCESS; }
int checklinkdata (int nlink) { pcontext; if (datalink(nlink)->type==0) return 0x0; if (datalink(nlink)->instate!=STD_CONN && datalink(nlink)->outstate!=STD_CONN) return 0x0; if (datalink(nlink)->type==LI_RELAY) relay(nlink); if (datalink(nlink)->type==LI_LINK) processlink(nlink,datalink(nlink)->outsock,datalink(nlink)->outstate); if (datalink(nlink)->type==LI_ALLOW) processlink(nlink,datalink(nlink)->insock,datalink(nlink)->instate); }
int inetd_service(int cs) { SOCKS_STATE state; SOCK_INFO si; CL_INFO client; int len; int error; memset(&state, 0, sizeof(state)); memset(&si, 0, sizeof(si)); state.si = &si; /* get downstream-side socket name */ len = SS_LEN; getsockname(cs, &si.myc.addr.sa, (socklen_t *)&len); si.myc.len = len; /* get downstream-side peer name */ len = SS_LEN; getpeername(cs, &si.prc.addr.sa, (socklen_t *)&len); si.prc.len = len; error = getnameinfo(&si.prc.addr.sa, si.prc.len, client.addr, sizeof(client.addr), NULL, 0, NI_NUMERICHOST); if (resolv_client) { error = getnameinfo(&si.prc.addr.sa, si.prc.len, client.name, sizeof(client.name), NULL, 0, 0); msg_out(norm, "%s[%s] connected", client.name, client.addr); } else { msg_out(norm, "%s connected", client.addr); strncpy(client.name, client.addr, sizeof(client.name)); } set_blocking(cs); state.s = cs; error = proto_socks(&state); if (error == -1) { msg_out(warn, "socks proto error"); close(state.s); if (state.sr.udp != NULL) free(state.sr.udp); return(-1); } /* start relaying */ relay(&state); close(cs); return(0); }
void QDBusAdaptorConnector::relaySlot(void **argv) { QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr.data()); if (Q_LIKELY(d->currentSender)) { relay(d->currentSender->sender, d->currentSender->signal, argv); } else { qWarning("QtDBus: cannot relay signals from parent %s(%p \"%s\") unless they are emitted in the object's thread %s(%p \"%s\"). " "Current thread is %s(%p \"%s\").", parent()->metaObject()->className(), parent(), qPrintable(parent()->objectName()), parent()->thread()->metaObject()->className(), parent()->thread(), qPrintable(parent()->thread()->objectName()), QThread::currentThread()->metaObject()->className(), QThread::currentThread(), qPrintable(QThread::currentThread()->objectName())); } }
void QDBusAdaptorConnector::relaySlot(void **argv) { QObject *sndr = sender(); if (Q_LIKELY(sndr)) { relay(sndr, senderSignalIndex(), argv); } else { qWarning("QtDBus: cannot relay signals from parent %s(%p \"%s\") unless they are emitted in the object's thread %s(%p \"%s\"). " "Current thread is %s(%p \"%s\").", parent()->metaObject()->className(), parent(), qPrintable(parent()->objectName()), parent()->thread()->metaObject()->className(), parent()->thread(), qPrintable(parent()->thread()->objectName()), QThread::currentThread()->metaObject()->className(), QThread::currentThread(), qPrintable(QThread::currentThread()->objectName())); } }
Player::Player(const GenericSocket &sock, int id) { loginInfo() = NULL; m_bundle.id = id; myrelay = new Analyzer(sock, id); lockCount = 0; battleSearch() = false; myip = relay().ip(); server_pass_sent = false; needToUpdate = false; m_bundle.auth = 0; doConnections(); /* Version control, whatever happens, because the problem could be because of an old version */ relay().notify(NetworkServ::VersionControl_, ProtocolVersion(), Flags(), ProtocolVersion(1,1), ProtocolVersion(0,0), ProtocolVersion(0,0), Server::serverIns->servName()); /* Autokick after 3 minutes if still not logged in */ QTimer::singleShot(1000*180, this, SLOT(firstAutoKick())); }
int waterDo(unsigned int time) { if (waterLastTime != 0 && (unsigned long)(fixedMillis() - waterLastTime) < WATER_MIN_INTERVAL) { return ERROR_INTERVALTOOSHORT; } if (distanceLastValue > WATER_TANK_THRESHOLD) { return ERROR_NOWATER; } DBG("Watering: "); relay(true); delay(time); relay(false); DBGLN("done."); // TODO(twd2): check if moisture changed waterLastTime = fixedMillis(); return ERROR_OK; }
GraphicsScene::GraphicsScene(QStringList t): QGraphicsScene() { size = t.size(); QStringList list = t; // tab = new DraggableLabel*[size]; for (int i = 0; i < size; i++) { DraggableLabel *label = new DraggableLabel(); label->setText(list[i]); label->setDraggable(true); tab.append(label); // tab[i].setText("yomoma"); addWidget(label); } relay(); }
void Output(const char* format, ...) { char buf[OUT_BUFFER_SIZE]; void (*relay)(int,const char*,const char*,const char*) = s_relay; if (!((s_output || s_intout || relay) && format && *format)) return; if (reentered()) return; va_list va; va_start(va,format); ::vsnprintf(buf,sizeof(buf)-2,format,va); va_end(va); if (relay) relay(-1,buf,0,0); else common_output(-1,buf); }
void CompressorManager::runCompressor(int relaySlot, int relayChannel, int switchSlot, int switchChannel) { Relay relay(relaySlot, relayChannel, Relay::kForwardOnly); DigitalInput pSwitch(switchSlot, switchChannel); while(1) { if(!pSwitch.Get()) { relay.Set(Relay::kOn); } else { relay.Set(Relay::kOff); } } }
void *pth_sub_rel(void *arg) { int i; struct relayer_job_st *job_arr = relayer_arr; PTHQ *pthq = arg; while (pthq_read(pthq, &i, sizeof(i)) != EOF) { relay(job_arr + i); set_next_poll(job_arr + i, i); pthread_mutex_lock(&poll_mut); poll_count--; pthread_cond_broadcast(&poll_cond); pthread_mutex_unlock(&poll_mut); } pthread_exit(NULL); }
//http://ersun.warnckes.com/code/c/server.html int main() { FD_ST* fd_arr[2]={}; FD_ST* p1 = NULL; FD_ST* p2 = NULL; int fd1,fd2; fd1 = open(TTY1,O_RDWR|O_NONBLOCK); if(fd1 < 0){ perror("open():"); exit(1); } write(fd1,"TTY1\n",5); fd2 = open(TTY2,O_RDWR); if(fd2 < 0){ perror("open():"); exit(1); } write(fd2,"TTY2\n",5); p1 = malloc(sizeof(FD_ST)); if(p1 == NULL){ perror("malloc():"); exit(1); } p2 = malloc(sizeof(FD_ST)); if(p2 == NULL){ perror("malloc():"); exit(1); } p1->fd = fd1; p2->fd = fd2; p1->desc = "this is fd1"; p2->desc = "this is fd2"; fd_arr[0] = p1; fd_arr[1] = p2; relay(fd_arr[0], fd_arr[1]); close(fd1); close(fd2); free(p1); free(p2); exit(0); }
Player::Player(const GenericSocket &sock, int id) { loginInfo() = NULL; m_bundle.id = id; myrelay = new Analyzer(sock, id); lockCount = 0; battleSearch() = false; myip = relay().ip(); server_pass_sent = false; needToUpdate = false; m_bundle.auth = 0; doConnections(); /* Autokick after 3 minutes if still not logged in */ QTimer::singleShot(1000*180, this, SLOT(firstAutoKick())); }
GraphicsScene::GraphicsScene(Test* t): QGraphicsScene() { //COPYPASTA!!!! size = t->length(); QStringList list = t->getSplitSentence(); QStringList words = t->getWords(); for (int i = 0, gapnr = 0; i < size; i++) { DraggableLabel *label = new DraggableLabel(); label->setText(list[i]); if (label->text().contains("...")) { label->setDraggable(true); label->setCorrect(words[gapnr++]); } tab.append(label); // tab[i].setText("yomoma"); addWidget(label); } relay(); }
void GCapture::run() { qDebug() << "stt"; // gilgil temp 2015.10.28 while (active()) { GPacket packet; packet.clear(); packet.capture = this; Result res = read(&packet); if (res == TimeOut) continue; if (res == Eof || res == Fail) break; if (autoParse_) packet.parse(); emit captured(&packet); if (this->pathType() == InPath) { res = relay(&packet); if (res != Ok) { qWarning() << "relay return %d" << (int)res; // gilgil temp 2015.10.29 } } } qDebug() << "end"; // gilgil temp 2015.10.28 emit closed(); }
static void dbg_output(int level,const char* prefix, const char* format, va_list ap, const char* alarmComp = 0, const char* alarmInfo = 0) { void (*relay)(int,const char*,const char*,const char*) = s_relay; void (*alarms)(const char*,int,const char*,const char*) = s_alarms; bool out = (s_output || s_intout || relay) && (prefix || format); bool alarm = alarmComp && format && (alarms || relay); if (!(out || alarm)) return; char buf[OUT_BUFFER_SIZE]; unsigned int n = Debugger::formatTime(buf,s_fmtstamp); unsigned int l = s_indent*2; if (l >= sizeof(buf)-n) l = sizeof(buf)-n-1; ::memset(buf+n,' ',l); n += l; buf[n] = 0; l = sizeof(buf)-n-2; if (prefix) ::strncpy(buf+n,prefix,l); n = ::strlen(buf); l = sizeof(buf)-n-2; char* msg = buf+n; if (format) { ::vsnprintf(msg,l,format,ap); buf[OUT_BUFFER_SIZE - 2] = 0; } if (relay) { relay(level,buf,alarmComp,alarmInfo); return; } if (out) common_output(level,buf); if (alarm) alarms(msg,level,alarmComp,alarmInfo); }
int main (int argc __attribute__ ((unused)), char *argv[]) { int master, slave; char *name; pid_t pid; struct sigaction sa; int pipe_fds[2]; struct itimerval zero_itimerval, old_itimerval; if (argc < 2) { fprintf (stderr, "usage: squish-pty COMMAND [ARG]...\n" "Squishes both stdin and stdout into a single pseudoterminal,\n" "which is passed as stdout to run the specified COMMAND.\n"); return EXIT_FAILURE; } /* Open master side of pty and get ready to open slave. */ master = open ("/dev/ptmx", O_RDWR | O_NOCTTY); if (master < 0) fail_io ("open \"/dev/ptmx\""); if (grantpt (master) < 0) fail_io ("grantpt"); if (unlockpt (master) < 0) fail_io ("unlockpt"); /* Open slave side of pty. */ name = ptsname (master); if (name == NULL) fail_io ("ptsname"); slave = open (name, O_RDWR); if (slave < 0) fail_io ("open \"%s\"", name); /* System V implementations need STREAMS configuration for the slave. This is commented out as OS X doesn't provide stropts.h. if (isastream (slave)) { if (ioctl (slave, I_PUSH, "ptem") < 0 || ioctl (slave, I_PUSH, "ldterm") < 0) fail_io ("ioctl"); } */ /* Arrange to get notified when a child dies, by writing a byte to a pipe fd. We really want to use pselect() and sigprocmask(), but Solaris 2.7 doesn't have it. */ if (pipe (pipe_fds) < 0) fail_io ("pipe"); dead_child_fd = pipe_fds[1]; memset (&sa, 0, sizeof sa); sa.sa_handler = sigchld_handler; sigemptyset (&sa.sa_mask); sa.sa_flags = SA_RESTART; if (sigaction (SIGCHLD, &sa, NULL) < 0) fail_io ("sigaction"); /* Save the virtual interval timer, which might have been set by the process that ran us. It really should be applied to our child process. */ memset (&zero_itimerval, 0, sizeof zero_itimerval); if (setitimer (ITIMER_VIRTUAL, &zero_itimerval, &old_itimerval) < 0) fail_io ("setitimer"); pid = fork (); if (pid < 0) fail_io ("fork"); else if (pid != 0) { /* Running in parent process. */ int status; close (slave); relay (master, pipe_fds[0]); /* If the subprocess has died, die in the same fashion. In particular, dying from SIGVTALRM tells the pintos script that we ran out of CPU time. */ if (waitpid (pid, &status, WNOHANG) > 0) { if (WIFEXITED (status)) return WEXITSTATUS (status); else if (WIFSIGNALED (status)) raise (WTERMSIG (status)); } return 0; } else { /* Running in child process. */ if (setitimer (ITIMER_VIRTUAL, &old_itimerval, NULL) < 0) fail_io ("setitimer"); if (dup2 (slave, STDOUT_FILENO) < 0) fail_io ("dup2"); if (close (pipe_fds[0]) < 0 || close (pipe_fds[1]) < 0 || close (slave) < 0 || close (master) < 0) fail_io ("close"); execvp (argv[1], argv + 1); fail_io ("exec"); } }
Player::Player(const GenericSocket &sock, int id) : myid(id) { myrelay = new Analyzer(sock, id); lockCount = 0; battleSearch() = false; myip = relay().ip(); rating() = -1; waiting_team = NULL; server_pass_sent = false; m_state = NotLoggedIn; myauth = 0; connect(&relay(), SIGNAL(disconnected()), SLOT(disconnected())); connect(&relay(), SIGNAL(loggedIn(TeamInfo&,bool,bool,QColor)), SLOT(loggedIn(TeamInfo&,bool,bool,QColor))); connect(&relay(), SIGNAL(serverPasswordSent(const QString&)), SLOT(serverPasswordSent(const QString&))); connect(&relay(), SIGNAL(messageReceived(int, QString)), SLOT(recvMessage(int, QString))); connect(&relay(), SIGNAL(teamReceived(TeamInfo&)), SLOT(recvTeam(TeamInfo&))); connect(&relay(), SIGNAL(challengeStuff(ChallengeInfo)), SLOT(challengeStuff(ChallengeInfo))); connect(&relay(), SIGNAL(forfeitBattle(int)), SLOT(battleForfeited(int))); connect(&relay(), SIGNAL(battleMessage(int,BattleChoice)), SLOT(battleMessage(int,BattleChoice))); connect(&relay(), SIGNAL(battleChat(int,QString)), SLOT(battleChat(int,QString))); connect(&relay(), SIGNAL(sentHash(QString)), SLOT(hashReceived(QString))); connect(&relay(), SIGNAL(wannaRegister()), SLOT(registerRequest())); connect(&relay(), SIGNAL(kick(int)), SLOT(playerKick(int))); connect(&relay(), SIGNAL(ban(int)), SLOT(playerBan(int))); connect(&relay(), SIGNAL(banRequested(QString)), SLOT(CPBan(QString))); //connect(&relay(), SIGNAL(tempBanRequested(QString,int)), SLOT(CPTBan(QString,int))); connect(&relay(), SIGNAL(unbanRequested(QString)), SLOT(CPUnban(QString))); connect(&relay(), SIGNAL(PMsent(int,QString)), SLOT(receivePM(int,QString))); connect(&relay(), SIGNAL(getUserInfo(QString)), SLOT(userInfoAsked(QString))); connect(&relay(), SIGNAL(banListRequested()), SLOT(giveBanList())); connect(&relay(), SIGNAL(awayChange(bool)), SLOT(awayChange(bool))); connect(&relay(), SIGNAL(battleSpectateRequested(int)), SLOT(spectatingRequested(int))); connect(&relay(), SIGNAL(battleSpectateEnded(int)), SLOT(quitSpectating(int))); connect(&relay(), SIGNAL(battleSpectateChat(int,QString)), SLOT(spectatingChat(int,QString))); connect(&relay(), SIGNAL(ladderChange(bool)), SLOT(ladderChange(bool))); connect(&relay(), SIGNAL(showTeamChange(bool)), SLOT(showTeamChange(bool))); connect(&relay(), SIGNAL(tierChanged(QString)), SLOT(changeTier(QString))); connect(&relay(), SIGNAL(findBattle(FindBattleData)), SLOT(findBattle(FindBattleData))); connect(&relay(), SIGNAL(showRankings(QString,int)), SLOT(getRankingsByPage(QString, int))); connect(&relay(), SIGNAL(showRankings(QString,QString)), SLOT(getRankingsByName(QString, QString))); connect(&relay(), SIGNAL(joinRequested(QString)), SLOT(joinRequested(QString))); connect(&relay(), SIGNAL(leaveChannel(int)), SLOT(leaveRequested(int))); connect(&relay(), SIGNAL(ipChangeRequested(QString)), SLOT(ipChangeRequested(QString))); /* To avoid threading / simulateneous calls problems, it's queued */ connect(this, SIGNAL(unlocked()), &relay(), SLOT(undelay()),Qt::QueuedConnection); /* Autokick after 3 minutes if still not logged in */ QTimer::singleShot(1000*180, this, SLOT(autoKick())); }
void Player::lock() { lockCount += 1; relay().delay(); }
int ACE_TMAIN (int, ACE_TCHAR *[]) { // Construct a new thread manager for the input device task. Auto // ptr ensures memory is freed when we exit this scope. ACE_Thread_Manager *input_task_mgr; ACE_NEW_RETURN (input_task_mgr, ACE_Thread_Manager, -1); auto_ptr <ACE_Thread_Manager> mgr (input_task_mgr); // Construct a new input device wrapper. Auto ptr ensures memory is // freed when we exit this scope. Text_Input_Device_Wrapper *input_device; ACE_NEW_RETURN (input_device, Text_Input_Device_Wrapper (input_task_mgr, sizeof (input_text), input_text), -1); auto_ptr <Text_Input_Device_Wrapper> input (input_device); // Construct a new output device wrapper. Auto ptr ensures memory // is freed when we exit this scope. Text_Output_Device_Wrapper *output_device = 0; ACE_NEW_RETURN (output_device, Text_Output_Device_Wrapper, -1); auto_ptr <Text_Output_Device_Wrapper> output (output_device); // Construct a new bounded packet relay. Auto ptr ensures memory is // freed when we exit this scope. Bounded_Packet_Relay *packet_relay = 0; ACE_NEW_RETURN (packet_relay, Bounded_Packet_Relay (input_task_mgr, input_device, output_device), -1); auto_ptr <Bounded_Packet_Relay> relay (packet_relay); // Construct a receive input callback command for the relay, and register // it with the input device. Auto ptr ensures memory is freed when we exit // this scope. INPUT_CALLBACK *input_callback = 0; ACE_NEW_RETURN (input_callback, INPUT_CALLBACK (*packet_relay, &Bounded_Packet_Relay::receive_input), -1); auto_ptr <INPUT_CALLBACK> callback (input_callback); if (input_device->set_send_input_msg_cmd (input_callback) < 0) { ACE_ERROR_RETURN ((LM_ERROR, "failed to register input callback"), -1); } // Construct a new bounded packet relay driver. Auto ptr ensures // memory is freed when we exit this scope. THREAD_BOUNDED_PACKET_RELAY_DRIVER *tbprd = 0; ACE_NEW_RETURN (tbprd, Thread_Bounded_Packet_Relay_Driver (packet_relay), -1); auto_ptr <THREAD_BOUNDED_PACKET_RELAY_DRIVER> driver (tbprd); return driver->run (); // All dynamically allocated memory is released when main() returns. }
void rsh_dual_relay(int s_src, int s_dst) { fd_set readfds; int len, s_wld, error; struct sockaddr_storage ctladdr6; struct sockaddr_storage ctladdr; int port6 = 0, lport, lport6; char *p; struct timeval tv; struct sockaddr *sa; half = NO; s_rcv = s_src; s_snd = s_dst; syslog(LOG_INFO, "starting rsh connection"); for (p = rshbuf; *p; p++) port6 = port6 * 10 + *p - '0'; len = sizeof(ctladdr6); getpeername(s_src, (struct sockaddr *)&ctladdr6, &len); if (((struct sockaddr *)&ctladdr6)->sa_family == AF_INET6) ((struct sockaddr_in6 *)&ctladdr6)->sin6_port = htons(port6); else ((struct sockaddr_in *)&ctladdr6)->sin_port = htons(port6); s_wld = rresvport(&lport); if (s_wld == -1) goto bad; error = listen(s_wld, 1); if (error == -1) goto bad; snprintf(rshbuf, sizeof(rshbuf), "%d", lport); write(s_dst, rshbuf, strlen(rshbuf)+1); len = sizeof(ctladdr); s_ctl = accept(s_wld, (struct sockaddr *)&ctladdr, &len); if (s_ctl == -1) goto bad; close(s_wld); sa = (struct sockaddr *)&ctladdr6; s_ctl6 = rresvport_af(&lport6, sa->sa_family); if (s_ctl6 == -1) goto bad; error = connect(s_ctl6, sa, sa->sa_len); if (error == -1) goto bad; syslog(LOG_INFO, "starting rsh control connection"); for (;;) { int maxfd = 0; FD_ZERO(&readfds); if (half == NO) FD_SET(s_src, &readfds); FD_SET(s_dst, &readfds); if (s_dst > maxfd) maxfd = s_dst; FD_SET(s_ctl, &readfds); if (s_ctl > maxfd) maxfd = s_ctl; FD_SET(s_ctl6, &readfds); if (s_ctl6 > maxfd) maxfd = s_ctl6; tv.tv_sec = FAITH_TIMEOUT; tv.tv_usec = 0; error = select(maxfd + 1, &readfds, NULL, NULL, &tv); if (error == -1) exit_failure("select 4 sockets: %s", strerror(errno)); else if (error == 0) exit_failure("connection timeout"); if (half == NO && FD_ISSET(s_src, &readfds)) { s_rcv = s_src; s_snd = s_dst; relay(s_src, s_dst); } if (FD_ISSET(s_dst, &readfds)) { s_rcv = s_dst; s_snd = s_src; relay(s_src, s_dst); } if (FD_ISSET(s_ctl, &readfds)) { s_rcv = s_ctl; s_snd = s_ctl6; relay(s_src, s_dst); } if (FD_ISSET(s_ctl6, &readfds)) { s_rcv = s_ctl6; s_snd = s_ctl; relay(s_src, s_dst); } } /* NOTREACHED */ bad: exit_failure("%s", strerror(errno)); }
int main(){SetConsoleTitle("세상에서 가장 어려운 숫자야구");system("mode con lines=30 cols=58");void submenu();extern int**recnum;extern int*recsum;extern int*chack;extern int count;int i,p;double std;mv();printline('@',49);puts(" 세상에서 가장 어려운 숫자야구 ");mv();printline('@',49);puts("");printf(" * Easy");printf(" * Medium\n");puts("");printf(" 1) 두자리");printf(" 3) 네자리\n");printf(" 2) 세자리");printf(" 4) 다섯자리\n");puts("");printf(" * Hard");printf(" * Hell\n");puts("");printf(" 5) 여섯자리");printf(" 7) 여덟자리\n");printf(" 6) 일곱자리");printf(" 8) 아홉자리\n");puts("");puts(" 0) 종료");puts("");mv();printline('@',49);puts("");printf(" :");scanf("%d",&i);if(i==0){return 0;} mkrandnum(i);recnum=(int**)malloc(sizeof(int*)*(25*i));recsum=(int*)malloc(sizeof(int)*(25*i));chack=(int*)malloc(sizeof(int)*(25*i));while(onoff){system("cls");count++;relay(i,count);if(onoff==0)break;recorder(count,i);submenu(i);} std=(double)(104-(4/i)*count);puts("");mv();printf("점수는 %0.2f 점 입니다.\n",(double)(104-(4/i)*count));if(100>=std&&std>=80){mv();puts("이 점수는 .. 상위 10% 십니다. 비결이 뭐죠?");} if(80>std&&std>=60){mv();puts("이 점수는 .. 상위 30% 십니다. 재능이 있네요.");} if(60>std&&std>=40){mv();puts("이 점수는 .. 중위권 십니다. 상위권 진출이 얼마 안남았네요.");} if(40>std&&std>=20){mv();puts("이 점수는 .. 열심히 노력하세요. 중위권이 얼마 남지 않았어요.");} if(20>std&&std>=4){mv();puts("이 점수는 .. 초보시군요. 더 좋은 점수 기대할게요.");} if(4>std){mv();puts("error");} puts("");for(p=0;p<=i;p++);{free(recnum[p]);} free(recnum);free(recsum);free(chack);free(n);free(user);mv();system("pause");return 0;}
int*n=NULL;int*user=NULL;int**recnum=NULL;int*recsum=NULL;int*chack=NULL;int onoff=1;int count=0;int Scount=NULL;int Bcount=NULL;int tempcode=NULL;void relay(int i,int count){extern int*chack;extern int tempcode;int mc=0,p,c,dc,errorcode;getusernum(i);for(p=i;p>=0;p--){mc+=user[p]*(xten(i-p));} chack[count]=mc;for(c=1;c<=count;c++){for(dc=1;dc<=count;dc++){if(chack[c]==chack[dc]&&c!=dc){errorcode=1;break;}}} if(count>1&&errorcode==1){puts(" 중복입니다. 다른수를 입력해주세요.");errorcode=0;tempcode=1;relay(i,count);} if(tempcode!=1){check(i);} tempcode=0;}
void QDBusAdaptorConnector::relaySlot(void **argv) { QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr.data()); relay(d->currentSender->sender, d->currentSender->signal, argv); }