void indent(int depth) /* Provide indentation to show directory depth. */ { int n= BASE_INDENT * (depth - 1); while (n >= 8) { if (putc('\t', statefp) == EOF) checkstate(); n-= 8; } while (n > 0) { if (putc(' ', statefp) == EOF) checkstate(); n--; } }
unsigned int SimFilterWheel::currentPosition() { checkstate(); if (_currentstate != FilterWheel::idle) { throw BadState("filterwheel not idle"); } return _currentposition; }
int main() { bool newreadings; bool buttonschanged; load_init(); initsystem(); watchdog_init(); initserial(); timer_init(); display_init(); initfan(); adc_init(); buttons_init(); enableInterrupts(); protocol_onbooted(); while (1) { watchdog_kick(); newreadings = adc_updatereadings(); if (newreadings) { checkstate(); } buttonschanged = buttons_check(); if (newreadings || buttonschanged) { protocol_sendstate(); display_update(); } protocol_checkcommand(); } }
void MoveEngine::loadGame(const LoadSave& load) { for(int a=0;a<28;a++) { population[a].total=load.pop[a].total; } checkstate(); }
void NmdcHub::connect(const User* aUser) { checkstate(); dcdebug("NmdcHub::connectToMe %s\n", aUser->getNick().c_str()); if(SETTING(CONNECTION_TYPE) == SettingsManager::CONNECTION_ACTIVE) { send("$ConnectToMe " + toNmdc(aUser->getNick()) + " " + getLocalIp() + ":" + Util::toString(SETTING(IN_PORT)) + "|"); } else { send("$RevConnectToMe " + toNmdc(getNick()) + " " + toNmdc(aUser->getNick()) + "|"); } }
FocusAssistant::FocusAssistant(QWidget *parent) : QWidget(parent), ui(new Ui::FocusAssistant) { ui->setupUi(this); displayLeft = checkstate(); connect(ui->leftCamera, SIGNAL(toggled(bool)), this, SLOT(checkchange())); connect(ui->okButton, SIGNAL(clicked()), SIGNAL(winhide())); connect(ui->okButton, SIGNAL(clicked()), this, SLOT(hide())); //connect(this, SIGNAL(destroyed()), SIGNAL(winhide())); }
void multiCombobox::switchCheckstate ( int row ) { if ( checkstate ( row ) ) { setCheckstate ( row, 0 ); } else { setCheckstate ( row, 1 ); } emit checkstateChanged ( row ); }
void mkstatefile(void) /* Make a state file out of the directory tree. */ { entry_t *entry; while ((entry= traverse()) != nil) { indent(entry->depth); if (!print_name(statefp, entry->name)) checkstate(); if (entry->ignore) { fprintf(statefp, "\tignore (%s)\n", strerror(entry->ignore)); checkstate(); continue; } switch (entry->type) { case F_DIR: fprintf(statefp, "\td%03o %u %u", (unsigned) entry->mode, (unsigned) entry->uid, (unsigned) entry->gid); break; case F_FILE: fprintf(statefp, "\t%03o %u %u %lu %lu", (unsigned) entry->mode, (unsigned) entry->uid, (unsigned) entry->gid, (unsigned long) entry->size, (unsigned long) entry->mtime); break; case F_BLK: case F_CHR: fprintf(statefp, "\t%c%03o %u %u %x", entry->type == F_BLK ? 'b' : 'c', (unsigned) entry->mode, (unsigned) entry->uid, (unsigned) entry->gid, (unsigned) entry->rdev); break; case F_PIPE: fprintf(statefp, "\tp%03o %u %u", (unsigned) entry->mode, (unsigned) entry->uid, (unsigned) entry->gid); break; case F_LINK: fprintf(statefp, "\t-> "); checkstate(); (void) print_name(statefp, entry->link); break; } checkstate(); if (entry->fake_ino != 0) fprintf(statefp, " %lu", entry->fake_ino); if (entry->lastlink) fprintf(statefp, " last"); if (fputc('\n', statefp) == EOF) checkstate(); } fflush(statefp); checkstate(); }
void NmdcHub::kick(const User::Ptr& aUser, const string& aMsg) { checkstate(); dcdebug("NmdcHub::kick\n"); static const char str[] = "$To: %s From: %s $<%s> You are being kicked because: %s|<%s> %s is kicking %s because: %s|"; string msg2 = toNmdc(Util::validateMessage(aMsg, false)); char* tmp = new char[sizeof(str) + 2*aUser->getNick().length() + 2*msg2.length() + 4*getNick().length()]; const char* u = aUser->getNick().c_str(); const char* n = getNick().c_str(); const char* m = msg2.c_str(); sprintf(tmp, str, u, n, n, m, n, n, u, m); send(tmp); delete[] tmp; // Short, short break to allow the message to reach the NmdcHub... Thread::sleep(200); send("$Kick " + toNmdc(aUser->getNick()) + "|"); }
void MoveEngine::diceroll(const int& newplayer,const int& face1,const int& face2,const int& face3,const int& face4,bool computer) { checkstate(); player=newplayer; otherplayer=(player==1) ? 2 : 1; dice[0]=face1; dice[1]=face2; dice[2]=face3; dice[3]=face4; marker_current=-1; if(getPossibleMoves()==0) { emit nomove(); return; // player will be changed } if(!computer) return; //human intervention required QTimer::singleShot(2000,this,SLOT(automove())); }
void NmdcHub::search(int aSizeType, int64_t aSize, int aFileType, const string& aString){ checkstate(); char* buf; char c1 = (aSizeType == SearchManager::SIZE_DONTCARE) ? 'F' : 'T'; char c2 = (aSizeType == SearchManager::SIZE_ATLEAST) ? 'F' : 'T'; string tmp = toNmdc(aString); string::size_type i; while((i = tmp.find(' ')) != string::npos) { tmp[i] = '$'; } int chars = 0; if(SETTING(CONNECTION_TYPE) == SettingsManager::CONNECTION_ACTIVE) { string x = getLocalIp(); buf = new char[x.length() + aString.length() + 64]; chars = sprintf(buf, "$Search %s:%d %c?%c?%s?%d?%s|", x.c_str(), SETTING(IN_PORT), c1, c2, Util::toString(aSize).c_str(), aFileType+1, tmp.c_str()); } else { buf = new char[getNick().length() + aString.length() + 64]; chars = sprintf(buf, "$Search Hub:%s %c?%c?%s?%d?%s|", getNick().c_str(), c1, c2, Util::toString(aSize).c_str(), aFileType+1, tmp.c_str()); } send(buf, chars); delete[] buf; }
void NmdcHub::myInfo() { checkstate(); dcdebug("MyInfo %s...\n", getNick().c_str()); lastCounts = counts; string tmp1 = ";**\x1fU9"; string tmp2 = "+L9"; string tmp3 = "+G9"; string tmp4 = "+R9"; string tmp5 = "+N9"; string::size_type i; for(i = 0; i < 6; i++) { tmp1[i]++; } for(i = 0; i < 3; i++) { tmp2[i]++; tmp3[i]++; tmp4[i]++; tmp5[i]++; } char modeChar = '?'; if(SETTING(CONNECTION_TYPE) == SettingsManager::CONNECTION_ACTIVE) modeChar = 'A'; else if(SETTING(CONNECTION_TYPE) == SettingsManager::CONNECTION_PASSIVE) modeChar = 'P'; else if(SETTING(CONNECTION_TYPE) == SettingsManager::CONNECTION_SOCKS5) modeChar = '5'; string uMin = (SETTING(MIN_UPLOAD_SPEED) == 0) ? Util::emptyString : tmp5 + Util::toString(SETTING(MIN_UPLOAD_SPEED)); string minf = "$MyINFO $ALL " + toNmdc(checkNick(getNick())) + " " + toNmdc(Util::validateMessage(getDescription(), false)) + tmp1 + VERSIONSTRING + tmp2 + modeChar + tmp3 + getCounts() + tmp4 + Util::toString(SETTING(SLOTS)) + uMin + ">$ $" + SETTING(CONNECTION) + "\x01$" + toNmdc(Util::validateMessage(SETTING(EMAIL), false)) + '$' + ShareManager::getInstance()->getShareSizeString() + "$|"; if(minf != lastMyInfo) { send(minf); lastMyInfo = minf; } }
void FocusAssistant::checkchange() { displayLeft = checkstate(); }
FilterWheel::State SimFilterWheel::getState() { checkstate(); return _currentstate; }
entry_t *readstate(void) /* Read one entry from the state file. */ { static entry_t entry; static pathname_t path; static size_t *trunc; static size_t trunc_len; static base_indent; char *line; char **argv; size_t argc; static off_t lineno; int indent, depth; recurse: keep= KEEP_STATE; if (feof(statefp) || (line= read1line(statefp)) == nil) { checkstate(); return nil; } lineno++; /* How far is this entry indented? */ indent= 0; while (*line != 0) { if (*line == ' ') indent++; else if (*line == '\t') indent= (indent + 8) & ~7; else break; line++; } if (indent > 0 && base_indent == 0) base_indent= indent; depth= (base_indent == 0 ? 0 : indent / base_indent) + 1; if (entry.ignore && depth > entry.depth) { /* If the old directory is ignored, then so are its entries. */ goto recurse; } entry.depth= depth; splitline(line, &argv, &argc); if (argc < 2) state_syntax(lineno); if (trunc == nil) { /* The root of the tree, initialize path. */ if (argv[0][0] != '/') state_syntax(lineno); path_init(&path); path_add(&path, "/"); trunc= allocate(nil, (trunc_len= 16) * sizeof(trunc[0])); /* The root has depth 0. */ entry.depth= 0; trunc[0]= 0; } else { if (entry.depth > trunc_len) { trunc= allocate(trunc, (trunc_len*= 2) * sizeof(trunc[0])); } path_trunc(&path, trunc[entry.depth - 1]); path_add(&path, argv[0]); trunc[entry.depth]= path_length(&path); } entry.path= path_name(&path); entry.name= argv[0]; entry.link= nil; if ((entry.ignore= strcmp(argv[1], "ignore") == 0)) { return &entry; } if (!getattributes(&entry, argc - 1, argv + 1)) state_syntax(lineno); return &entry; }
void NmdcHub::redirect(const User* aUser, const string& aServer, const string& aMsg) { checkstate(); dcdebug("NmdcHub::opForceMove\n"); send("$OpForceMove $Who:" + toNmdc(aUser->getNick()) + "$Where:" + aServer + "$Msg:" + toNmdc(aMsg) + "|"); }
int main(int argc, char *argv[]) { double u[NN], v[NN], p[NN], fat[NN], Vc[NN], w[NN][N2], a[NX+1][NY+1][NZ+1], B[NX+1][NY+1][NZ+1], u_ave[NN]; double xx[NN], yy[NN], zz[NN], r[NN]; double ageb[NN], agek[NN]; int state[NN], div_times[NN], touch[NN]; int lj[NN][N2]; int indx[NN]; // lj[i][0...indx-1] int ljd[NN][N2]; int ljd_indx[NN]; // ljd[i][0...ljd_indx-1] /* debug */ int pair[NN], pair2[NN], pair_indx = 0; double L[NN]; int other_cell[NN]; int tb[NN]; int ncell_var, num; int i, j, k; int KEY_INPUT_DATA; char celldata_name[100]; char str[100], str_chem[100]; FILE *finput, *fdebug; void checkstate(int [], int ); void checkparam(); int nmx = (int)(COMPRESS_FACTOR * LX/(2.0*R_memb)); int nmy = (int)(COMPRESS_FACTOR * LY/(2.0*R_memb)); printf("mkdir %s\n", OUTPUTDIR ); sprintf(str, "mkdir -p %s", OUTPUTDIR); system(str); checkparam(); if (fabs(dx-dh)>EPS || fabs(dy-dh)>EPS || fabs(dz-dh)>EPS) { printf("error: dx=%f dy=%f dz=%f.\n", dx, dy, dz); printf("grid size must be dh=%f.\n", dh); exit(1); } if (argc <= 1) { printf("input file name required\n"); exit(1); } strcpy(celldata_name, argv[1]); if((finput = fopen(celldata_name, "r")) == NULL) { printf("input file error2\n"); exit(1); } if ((num = count_line(finput)) != NN) { printf(" error: input data file not consistent.\n"); printf("input file lines = %d: NN = %d\n", num, NN); exit(5); } fclose(finput); if((finput = fopen(celldata_name, "r")) == NULL) { printf("input file error2\n"); exit(1); } initialize_state(state, ageb, agek, fat, Vc); /* input vales, initialize gj, return first blank cell's index*/ initialize_vars(finput, xx, yy, zz, lj, state, r, ageb, agek, div_times, fat, Vc, touch, L, other_cell, tb, &ncell_var, &NDER, &NMEMB); printf("variables initialized: NDER=%d NMEMB=%d ncell=%d NN=%d\n", NDER, NMEMB, ncell_var, NN); if (nmx != NMX || nmy != NMY) { printf("error: number of membrane particles inconsistent with parameter file\n"); exit(1); } checkstate(state, ncell_var); connect_lj(lj, state, ncell_var, xx, yy, zz, r, indx); printf("lj connection initialized\n"); check_pair(ncell_var, xx, yy, zz, pair, pair2, &pair_indx, L, other_cell); fclose(finput); initial_u(u, v, p, a, B, w); // initialization KEY_INPUT_DATA = atoi(argv[2]); if (KEY_INPUT_DATA != 1 && KEY_INPUT_DATA != 0) { printf("error: 2nd argument must be 0 or 1\n"); exit(3); } if (KEY_INPUT_DATA) { printf("chemical data read from recycled_data\n"); sprintf(str_chem, "recycled_data"); input_uvp(str_chem, u, v, p, a, B, w, ncell_var); } if (SYSTEM == WHOLE) { printf("computing the whole epidermis.\n"); // SYSTEM = WHOLE; } else if (SYSTEM == BASAL) { printf("computing only the basal layer and the dermis.\n"); // SYSTEM = BASAL; } else { printf("parameter SYSTEM must be 'WHOLE' or 'BASAL'\n"); exit(1); } if (KEY_FORCED_SC) printf("forced cornification enabled\n"); else printf("forced cornification disabled\n"); if (KEY_INPUT_DATA && KEY_FORCED_SC) { printf("error: forced cornification must be disabled\n"); exit(1); } else if (!KEY_INPUT_DATA && !KEY_FORCED_SC) { printf("WARNING: sc formation would take longer without forced cornification.\n"); } if (KEY_DERMAL_CHANGE) printf("computing dermal change\n"); else printf("fixed dermal shape\n"); printf("divmax=%d, accel_div=%f MALIGNANT=%d\n", div_max, accel_div, MALIGNANT); printf("K_TOTAL=%f, K_DESMOSOME_RATIO=%f\n", K_TOTAL, K_DESMOSOME_RATIO); evolution(u, v, p, w, a, B, xx, yy, zz, r, ageb, agek, state, div_times, fat, Vc, touch, lj, indx, &ncell_var, u_ave, pair, pair2, &pair_indx, L, other_cell, ljd, ljd_indx, tb); printf("finished\n"); return 0; }