void AGOSEngine_PN::opn_opcode42() { int a = doaction(); if (_dolineReturnVal != 0) return; int b = doaction(); setScriptReturn(a ^ b); }
static void processevent(const struct inotify_event *event) { const struct lookfor *l; /* report errors and possible problems */ if (isanybitset(event->mask, IN_DELETE_SELF|IN_UNMOUNT)) { logerror_die("Watched directory vanished!\n"); } if (isbitset(event->mask, IN_Q_OVERFLOW)) { logerror( "Warning: overflow happened! Events might have been missed.\n"); } // debug stuff, to be removed or conditialized: // if (isbitset(event->mask, IN_CREATE)) { // dolog("File was created: %s\n", event->name); // } // if (isbitset(event->mask, IN_CLOSE_WRITE)) { // dolog("File ready: %s\n", event->name); // } // if (isbitset(event->mask, IN_MOVED_TO)) { // dolog("Full file moved here: %s\n", event->name); // } /* look if anything intresting is happening */ if (!isanybitset(event->mask, IN_MOVED_TO|IN_CLOSE_WRITE)) return; for (l = lookfor ; l != NULL ; l = l->next) { if (shouldprocess(l, event->name)) doaction(l, event->name); } }
static void process_directory(DIR *dir) { const struct lookfor *l; struct dirent *ent; while ((ent = readdir(dir)) != NULL) { if (ent->d_type != DT_REG) continue; for (l = lookfor ; l != NULL ; l = l->next) { if (shouldprocess(l, ent->d_name)) doaction(l, ent->d_name); } } }
int AGOSEngine_PN::doline(int needsave) { assert(!_stackbase == !needsave); int x; int myTag = ++_tagOfActiveDoline; // Obtain a unique tag for this doline invocation _dolineReturnVal = 0; if (_stackbase && needsave) _stackbase->tagOfParentDoline = myTag; do { _linct = ((*_linebase) & 127) - 1; _workptr = _linebase + 1; if (*_linebase > 127) { x = varval(); if (x != (int)_variableArray[1]) goto skipln; } do { x = doaction(); if (_dolineReturnVal != 0) { if (_tagOfActiveDoline != myTag) return 0; x = _dolineReturnVal; _dolineReturnVal = 0; if (x > 0) { if (x != 3) dumpstack(); // Restore the active jmpbuf to its previous value, // then return _dolineReturnVal-1 (will be 2-1=1 or 1-1=0). _tagOfActiveDoline = myTag - 1; return (x - 1); } } } while (x && !shouldQuit()); skipln: _linebase += 127 & *_linebase; _linembr++; } while (!shouldQuit()); return 0; }
int main(int argc, char *argv[]) { int sockfd, newsockfd, port, pid, clilen; struct sockaddr_in server, client; int reuse = 1; if(argc != 2) { printf("usage: server port\n"); exit(1); } if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) error("socket"); bzero((char *) &server, sizeof(server)); port = atoi(argv[1]); server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(port); if (bind (sockfd, (struct sockadd *) &server, sizeof(server)) < 0) error("bind"); if (setsockopt (sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) < 0) error("setsockopt"); listen(sockfd, 5); clilen = sizeof(client); while (1) { newsockfd = accept(sockfd, (struct sockadd *) &client, &clilen); if (newsockfd < 0) error("accept"); pid = fork(); if (pid < 0 ) error("fork"); if (pid == 0) { close(sockfd); doaction(newsockfd); exit(0); } else close(newsockfd); } return 0; }
void AGOSEngine_PN::opn_opcode43() { int a = doaction(); setScriptReturn(!a); }