int searchName(const string& s, int mode) /* 이름 검색 */ { int n; switch (mode) { case 'G': /* 글로벌 심볼 테이블 검색 */ for (n=0; n<(int)Gtable.size(); n++) { if (Gtable[n].name == s) return n; } break; case 'L': /* 로컬 심볼 테이블 검색 */ for (n=startLtable; n<(int)Ltable.size(); n++) { if (Ltable[n].name == s) return n; } break; case 'F': /* 함수명 검색 */ n = searchName(s, 'G'); if (n != -1 && Gtable[n].nmKind==fncId) return n; break; case 'V': /* 변수명 검색 */ if (searchName(s, 'F') != -1) err_exit("함수명과 중복되었습니다: ", s); if (s[0] == '$') return searchName(s, 'G'); if (is_localScope()) return searchName(s, 'L'); /* 로컬 영역 처리중 */ else return searchName(s, 'G'); /* 글로벌 영역 처리중 */ } return -1; // 발견되지 않음 }
void KPrinter::saveSettings() { if (d->m_impl) { setOption("kde-searchname", searchName()); d->m_impl->saveOptions(d->m_options); } // save latest used printer to config file KConfig *conf = KGlobal::config(); conf->setGroup("KPrinter Settings"); conf->writeEntry("Printer",searchName()); // latest used print command conf->writePathEntry("PrintCommand",option("kde-printcommand")); // latest used document directory if ( d->m_docdirectory.isEmpty() ) { KURL url( outputFileName() ); if ( url.isValid() ) conf->writePathEntry( "DocDirectory", url.directory() ); } else conf->writePathEntry( "DocDirectory", d->m_docdirectory ); }
int enter(SymTbl& tb, SymKind kind) /* 심볼 테이블 등록 */ { int n, mem_size; bool isLocal = is_localName(tb.name, kind); extern int localAdrs; /* 로컬 변수 주소 관리 */ extern Mymemory Dmem; /* 메모리 */ // 확인 mem_size = tb.aryLen; if (mem_size == 0) mem_size = 1; /* 단순 변수일 때 */ if (kind!=varId && tb.name[0]=='$') /* $ 사용 확인 */ err_exit("변수명 이외에서 $를 사용할 수 없습니다: ", tb.name); tb.nmKind = kind; n = -1; /* 중복확인 */ if (kind == fncId) n = searchName(tb.name, 'G'); if (kind == paraId) n = searchName(tb.name, 'L'); if (n != -1) err_exit("이름이 중복되었습니다: ", tb.name); // 주소 설정 if (kind == fncId) tb.adrs = get_lineNo(); /* 함수 시작 행 */ else { if (isLocal) { tb.adrs = localAdrs; localAdrs += mem_size; } /* 로컬 */ else { tb.adrs = Dmem.size(); /* 글로벌 */ Dmem.resize(Dmem.size() + mem_size); /* 글로벌 영역 확보 */ } } // 등록 if (isLocal) { n = Ltable.size(); Ltable.push_back(tb); } /* 로컬 */ else { n = Gtable.size(); Gtable.push_back(tb); } /* 글로벌 */ return n; /* 등록 위치 */ }
void KPrinter::loadSettings() { d->m_options = d->m_impl->loadOptions(); // load the last printer used in the current process (if any) // and remove the corresponding entry in the option map, as it // is not needed anymore setSearchName(option("kde-searchname")); d->m_options.remove("kde-searchname"); KConfig *conf = KGlobal::config(), *pconf = KMFactory::self()->printConfig(); conf->setGroup("KPrinter Settings"); pconf->setGroup("General"); // load latest used printer from config file, if required in the options if (searchName().isEmpty() && pconf->readBoolEntry("UseLast", true)) setSearchName(conf->readEntry("Printer")); // latest used print command setOption("kde-printcommand",conf->readPathEntry("PrintCommand")); // latest used document directory setDocDirectory( conf->readPathEntry( "DocDirectory" ) ); setDocFileName( "print" ); }
int main() { struct Student student_list[SIZE]; char keyName[N+1]; int i=0; int key; for(i=0;i<SIZE;i++) { printf("Please input your number:"); scanf("%d%*c",&student_list[i].no); printf("Please input your grades:"); scanf("%[^\n]%*c",student_list[i].grades); printf("Please input your name:"); scanf("%[^\n]%*c",student_list[i].name); } display(student_list); printf("Input the student number you're looking for:\n"); scanf("%d%*c",&key); search(student_list,key); printf("Input the student name you're looking for:\n"); scanf("%[^\n]%*c",&keyName); searchName(student_list,keyName); }
void FriendWidget::search(const QString &searchString, bool hide) { searchName(searchString, hide); CircleWidget* circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleID(FriendList::findFriend(friendId)->getToxId())); if (circleWidget != nullptr) circleWidget->search(searchString); }
void JabberAdd::search() { if (m_bBrowser) return; if (grpName->isChecked()) searchName(edtFirst->text(), edtLast->text(), edtNick->text()); if (grpMail->isChecked()) searchMail(edtMail->text()); }
RecordList PhoneBook::searchByName(const string & name) { Iter i = _records.begin(), j; RecordList ret; while ((j=searchName(name, i++)) != _records.end()) ret.push_back(*j); return ret; }
void main() { char n[SIZE][20]; load(n, SIZE); print(n, SIZE); sort(n, SIZE); searchName(n); system("PAUSE"); }
void adjustMemberInfo(Member_t *id) { int choice = 0; // 검색옵션 선택 변수 int studentid, i; // 검색에서 입력한 studentid를 받는 변수, 검색에서 받는 배열의 순서 변수 i char name[NAME_MAXCHAR]; // 검색에서 입력한 name을 받는 변수 char cellphone[CELLPHONE_MAXCHAR] ; // 검색에서 입력한 cellphone을 받는 변수 while (choice != -1){ case4SearchOptionUI(); gotoxy(20, 12); choice = getche(); if (choice < 49 || choice > 52) errorSearchChoice(); else { switch (choice) { case '1': textColor(16 * 10); gotoxy(7, 5); printf("1. 학번 "); textColor(7); studentid = searchStudentID(); if (studentid != -1){ i = searchInfoIDnum(id, studentid); choice = adjustInfo(id, i); } break; case '2': textColor(16 * 10); gotoxy(7, 6); printf("2. 이름 "); textColor(7); studentid = searchName(name); if (studentid != -1){ i = searchInfoName(id, name); choice = adjustInfo(id, i); } break; case '3': textColor(16 * 10); gotoxy(7, 7); printf("3. 전화번호"); textColor(7); studentid = searchCellphone(cellphone); if (studentid == -2) studentid = -1; if (studentid != -1){ i = searchInfoCellphone(id, cellphone); choice = adjustInfo(id, i); } break; case '4': textColor(16 * 10); gotoxy(7, 8); printf("4. 취소 "); textColor(7); searchCancel(); choice = -1; break; } } } }
Setting * SettingCollectionList::Get(const char * name) { Node * node = data; do { Setting * setting = node->data; if(setting) { BSAutoFixedString searchName(name); BSAutoFixedString settingName(setting->name); if(searchName == settingName) { return setting; } } node = node->next; } while(node); return nullptr; }
void UI::searchMenu() { cout << endl; char choice; cout << "Search by: " << endl; cout << "(N) Name" << endl << "(G) Gender" << endl << "(B) Year of Birth" << endl << "(D) Year of Death" << endl << "(M) Return to Menu" << endl << "(Q) Quit program " << endl; cout << "Select a letter: "; cin >> choice; switch(choice) { case 'n': case 'N': searchName(); //<- breyta í core.searchName þegar core hefur það fall break; case 'g': case 'G': searchGender(); break; case 'b': case 'B': searchBirth(); break; case 'd': case 'D': searchDeath(); break; case 'M': case 'm': return; //this->menu(); break; case 'q': case 'Q': exit(1); break; default: errorInput(); searchMenu(); } searchMenu(); }
/** * Envia un mensaje a todos los usuarios conectados */ void mp(user* conn, int* connTam, sms msj, int socketID, sqlite3* db){ // le ponemos el nombre real, por si acaso nos engaña el ciente int aux2; if(socketID == 0){ strcpy(msj.name, SERVER); }else{ aux2 = searchConn(conn, *connTam, socketID); strcpy(msj.name, (*(conn+aux2)).name); } PDEBUG("INFO: Añadiendo al log"); db_addLog(msj, &db); msj.flag = MSJ; PDEBUG("DATA: MP\n"); int aux = searchName(conn, *connTam, msj.to); if(aux < 0){ PDEBUG("DATA: Usuario no encontrado\n"); strcpy(msj.text, "Usuario no encontrado"); SSL_write((*(conn+aux2)).ssl, &msj, sizeof(sms)); return; } SSL_write((*(conn+aux)).ssl, &msj, sizeof(sms)); PDEBUG("DATA: MP enviado\n"); }
t_token AlexicalAnalizer::nextToken(void) { t_token token; int token2 = -1; // Trata comentários skipSeparators(); // Alfa numerico if (isalpha(next_char)) { // Palavras Reservadas char text[MAX_STRING_SIZE]; // init text for (int i=0; i<MAX_STRING_SIZE ;i++) { text[i] = '\0'; } int i = 0; do { text[i++] = next_char; next_char = readChar(); } while (isalnum(next_char) || next_char == '_'); // discover alpha type token = searchKeyWord(text); // if is a id, add to table if (token == ID) { token2 = searchName(text); } } // Numeral else if (isdigit(next_char)) { int n = 0; do { n = n * 10 + (next_char - '0'); next_char = readChar(); } while (isdigit(next_char)); // update token variables token = NUMERAL; token2 = addIntConst(n); } // Stringval else if (next_char == '"') { char string[MAX_STRING_SIZE + 1]; int i = 0; // to remove '"' from string next_char = readChar(); // store value of string on variable do { string[i++] = next_char; next_char = readChar(); } while (next_char != '"'); next_char = readChar(); // update token variables token = STRINGVAL; token2 = addStringConst(string); } else { switch (next_char) { /************ * SIMBOLOS * ************/ case '.': next_char = readChar(); token = DOT; break; // COLON case ':': next_char = readChar(); token = COLON; break; // SEMI_COLON case ';': next_char = readChar(); token = SEMI_COLON; break; // COMMA case ',': next_char = readChar(); token = COMMA; break; // 'Squares' case '[': next_char = readChar(); token = LEFT_SQUARE; break; case ']': next_char = readChar(); token = RIGHT_SQUARE; break; // Braces case '{': next_char = readChar(); token = LEFT_BRACES; break; case '}': next_char = readChar(); token = RIGHT_BRACES; break; // Parenthesis case '(': next_char = readChar(); token = LEFT_PARENTHESIS; break; case ')': next_char = readChar(); token = RIGHT_PARENTHESIS; break; // Less_than and Less_or_equal case '<': next_char = readChar(); token = LESS_THAN; if (next_char == '=') { token = LESS_OR_EQUAL; next_char = readChar(); } break; // Greater_than and Greater_or_equal case '>': next_char = readChar(); token = GREATER_THAN; if (next_char == '=') { token = GREATER_OR_EQUAL; next_char = readChar(); } break; // Not_equal case '!': next_char = readChar(); if (next_char == '=') { token = NOT_EQUAL; next_char = readChar(); } else { token = NOT; } break; // Equals and equal_equal case '=': next_char = readChar(); if (next_char == '=') { token = EQUAL_EQUAL; next_char = readChar(); } else { token = EQUALS; } break; // Plus and plus_plus case '+': next_char = readChar(); if (next_char == '+') { token = PLUS_PLUS; next_char = readChar(); } else { token = PLUS; } break; // Minus and minus_minus case '-': next_char = readChar(); if (next_char == '-') { token = MINUS_MINUS; next_char = readChar(); } else { token = MINUS; } break; // Times case '*': next_char = readChar(); token = TIMES; break; // Divide case '/': next_char = readChar(); token = DIVIDE; break; /******************** * Tokens Regulares * ********************/ // Character case '\'': next_char = readChar(); // update token variable token = CHARACTER; token2 = addCharConst(next_char); next_char = readChar(); if ('\'' != next_char) token = UNKNOWN; next_char = readChar(); break; } } // setup last token variables last_token = token; last_token2 = token2; return token; }
/* Main function */ int main(){ takeCard(); searchElixir(); return 0; system("clear"); takeCard(); printf("\nWelcome to my Clash Royal Program, please enter an option:\n"); printf("\n"); printf("[0] : Deck Maker\n"); printf("\n"); printf("Sort by \n"); printf("[1] : Name\n"); printf("[2] : Cost [1 - 10]\n"); printf("[3] : Rarity - Level [Common [1-12], Rare [1-7], Epic [1-4], Legendary[1]]\n"); printf("[4] : Arena [0 - 8]\n"); printf("[5] : Type [Spell, Troop, Building]\n"); printf("[6] : Hitpoints\n"); printf("[7] : Damage\n"); printf("[8] : Hit Speed\n"); printf("[9] : Target Type [Air, Ground, Air & Ground]\n"); printf("[10] : Speed [null, slow, medium, fast, very fast]\n"); printf("\n"); printf("Search for\n"); printf("[11] : Name\n"); printf("[12] : Cost [1 - 10]\n"); printf("[13] : Rarity by Level [Common [1-12], Rare [1-7], Epic [1-4], Legendary[1]]\n"); printf("[14] : Arena [0 - 8]\n"); printf("[15] : Type [Spell, Troop or Building]\n"); printf("[16] : Target Type [Air, Ground, Air & Ground]\n"); printf("[17] : Speed [null, slow, medium, fast, very fast]\n"); printf("\n"); printf("[q] : Quit\n\n"); scanf("%d", &chooseOption); //Stores menu choice into chooseOption end(); if (chooseOption == 0){ deckMaker(); } if (chooseOption == 1){ sortName(); } if (chooseOption == 2){ sortElixir(); } if (chooseOption == 3){ sortRarity(); } if (chooseOption == 4){ sortArena(); } if (chooseOption == 5){ sortType(); } if (chooseOption == 11){ searchName(); } if (chooseOption == 12){ searchElixir(); } if (chooseOption == 13){ searchRarity(); } if (chooseOption == 14){ searchArena(); } if (chooseOption == 15){ searchType(); } /* printf("Again?: \n"); printf("'1'\t: Yes\n"); printf("'other'\t: No\n\n"); scanf("\n%d", &answer); if (answer == 1){ system("clear"); main(); return 0; } */ end(); return 0; }
/** * Ejecuta en el servidor la cadena recibida */ int execParams(user* conn, int connTam, char* str, int socketID, int sock, sqlite3* db, room* rooms, int dim){ PDEBUG("INFO: Analizando lista de parámetros\n"); char saux[10][DIM]; bzero(saux, 10 * DIM); int error = 0; // tienes permisos para ejecutar comandos en el servidor??? PDEBUG("INFO: Comprobando permisos\n"); int aux = searchConn(conn, connTam, socketID); // almacenamos en la base de datos sms auxMsj; strcpy(auxMsj.name, (*(conn + aux)).name); strcpy(auxMsj.text, str); db_addLog(auxMsj, &db); if((*(conn + aux)).rol != ADMIN){ PDEBUG("INFO: Usuario sin permisos\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Usuario sin permisos"); SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); PDEBUG("INFO: Mensaje de usuario no válido enviado al emisor\n"); return -1; } PDEBUG("INFO: Usuario autorizado\n"); str = trim(str); // eliminamos os espacios en blanco if(strcmp(str, "-x") == 0){ // comando de salida PDEBUG("EXIT: Cerrando el servidor\n"); shutdown(sock, SHUT_RDWR); // cerramos el socket sms auxMsj; auxMsj.flag = SERV_EXIT; strcpy(auxMsj.name, SERVER); broadcast(conn, &connTam, auxMsj, socketID, db); closeAll(conn, &connTam); // cerramos todas las conexiones PDEBUG("EXIT: Cerrando la conexión con la base de datos\n"); db_close(&db); PDEBUG("EXIT: Liberando espacio\n"); free(conn); PDEBUG("EXIT: Cerrando el proceso\n"); exit(0); }else if(sscanf(str, "--add-user %s %s %s", saux[0], saux[1], saux[2]) == 3){ // añadiendo un usuario //saux[0] es el nombre //saux[1] es el password //saux[2] es el rol PDEBUG("INFO: Añadiendo usuario 3 param\n"); int rol = 0; if(strcmp(saux[2], "admin") == 0){ rol = ADMIN; }else if(strcmp(saux[2], "user") == 0){ rol = USER; }else{ PDEBUG("INFO: tercer argumento no válido"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Rol no reconocido."); SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); return 0; } error = db_addUser(saux[0], saux[1], rol, &db); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); if(error == 0){ strcpy(auxMsj.text, "Usuario creado"); }else if(error == 1){ strcpy(auxMsj.text, "Nombre de usuario en uso"); }else{ strcpy(auxMsj.text, "Error al crear el usuario"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--add-user %s %s", saux[0], saux[1]) == 2){ // añadiendo un usuario // se usará el rol por defecto //saux[0] es el nombre //saux[1] es el password PDEBUG("INFO: Añadiendo usuario 2 param\n"); error = db_addUser(saux[0], saux[1], USER, &db); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); if(error == 0){ strcpy(auxMsj.text, "Usuario creado"); }else if(error == 1){ strcpy(auxMsj.text, "Nombre de usuario en uso"); }else{ strcpy(auxMsj.text, "Error al crear el usuario"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--delete-user %s", saux[0]) == 1){ // borrando un usuario //saux[0] es el nombre PDEBUG("INFO: Borrando usuario\n"); int num = 0; num = db_deleteUser(saux[0], &db); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); if(num > 0){ PDEBUG("INFO: Usuario borrado\n"); strcpy(auxMsj.text, "Usuario borrado"); }else{ PDEBUG("INFO: Usuario no encontrado\n"); strcpy(auxMsj.text, "Usuario no encontrado"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(strcmp(str, "--list-user") == 0){ // listando usuarios //saux[0] es el nombre PDEBUG("INFO: listando usuarios\n"); int num = 0; num = db_listUser(socketID, &db); }else if(sscanf(str, "--log %s %s", saux[0], saux[1]) == 2){ // listando usuarios //saux[0] es la fecha de inicio //saux[1] es la fecha de finalización PDEBUG("INFO: listando usuarios\n"); int num = 0; struct tm tm1, tm2; long t1, t2; if (strptime(saux[0], "%d/%m/%Y", &tm1) == 0 || strptime(saux[1], "%d/%m/%Y", &tm2) == 0){ PDEBUG("INFO: Formato de fecha no válido\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Formato de fecha no válido -> dd/mm/YYYY"); SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); return -1; } t1 = (long)mktime(&tm1); t2 = (long)mktime(&tm2); sprintf(saux[0], " WHERE time > %ld AND time < %ld", t1, t2); num = db_getLogPar(socketID, &db, saux[0]); }else if(strcmp(str, "--log") == 0){ // listando usuarios PDEBUG("INFO: listando usuarios\n"); int num = 0; num = db_getLog(socketID, &db); }else if(sscanf(str, "--add-room %s", saux[0]) == 1){ // creacion de un cana // saux[0] es el nombre del canal PDEBUG("INFO: añadiendo canales\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); if(addRoom(saux[0], rooms, dim) == -1){ strcpy(auxMsj.text, "Error al crear el canal, mire el log para más información"); }else{ strcpy(auxMsj.text, "Canal creado"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--delete-room %s", saux[0]) == 1){ // creacion de un cana // saux[0] es el nombre del canal PDEBUG("INFO: borrando canal\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); PDEBUG("INFO: Moviendo usuarios\n"); strcpy(saux[1], "general"); moveAllTo(conn, &connTam, saux[0], rooms, dim, db, saux[1]); if(deleteRoom(saux[0], rooms, dim) == -1){ strcpy(auxMsj.text, "Error al borrar el canal, mire el log para más información"); }else{ strcpy(auxMsj.text, "Canal borrado"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--kick %s", saux[0]) == 1){ // expulsión de un usuario // saux[0] es el nombre del usuario PDEBUG("INFO: expulsión de un usuario\n"); //PDEBUG("INFO: Moviendo usuarios\n"); //strcpy(saux[1], "general"); sms auxMsj; auxMsj.flag = SERV_EXIT; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Usuario expulsado."); int aux = searchName(conn, connTam, saux[0]); SSL_write((*(conn+aux)).ssl, &auxMsj, sizeof(sms)); //moveAllTo(conn, &connTam, saux[0], rooms, dim, db, saux[1]); if(deleteRoom(saux[0], rooms, dim) == -1){ strcpy(auxMsj.text, "Error al borrar el canal, mire el log para más información"); }else{ strcpy(auxMsj.text, "Canal borrado"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--list-room") == 0){ // listando de canales sendRoomList((*(conn + aux)).ssl, rooms, dim); }else{ // error, comando no válido PDEBUG("INFO: Comando no válido\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Comando no válido"); SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); PDEBUG("INFO: Mensaje de comando no válido enviado al emisor\n"); return -1; } return 0; }
int main(int argc, char **argv) { dlist *list; dlist *list2; dlist *list3; dlist *list4; int choice; int i = 0; int numData; Node *p; FILE *fin, *fout; int select = 0; int startFrom, numSplit; // where to split and the length of splitting list char fileName[15]; //file name for output data char textName1[20], textName2[20]; // file name for split lists char sections [MAX][40] = {"Import from phonebook.dat", "Display (traverse)", "Add new contact (insert before/after)", "Insert a position" , "Delete a position", "Delete current", "Delete first", "Search and Update", "Divide and Extract", "Reverse list", "Save to file", "Count max identical phone numbers", "Exit (free)" }; do { choice = getMenu(sections, MAX); switch (choice) { case 1: // if ((fin = fopen(argv[1], "r")) == NULL) // { // printf("Can't open file %s\n", argv[1]); // exit(1); // } // if ((fout = fopen(argv[2], "wb")) == NULL) // { // printf("Can't open file %s\n", argv[2]); // exit(1); // } // numData = importDB(fin, fout); // fclose(fin); // fclose(fout); list = iniList(list); list2 = iniList(list2); list3 = iniList(list3); list4 = iniList(list4); if ((fin = fopen(argv[1], "rb")) == NULL) { printf("Can't open file %s\n", argv[1]); exit(1); } fseek(fin, 0, SEEK_END); numData = ftell(fin) / sizeof(element_type); rewind(fin); result = import(fin, numData); for (i = 0; i < result; ++i) insertEnd(contact[i], list); // printData(); fclose(fin); break; case 2: traverse(list); break; case 3: printf("Enter 0 to insert before, 1 to insert after: "); scanf("%d", &select); while (getchar() != '\n'); if (select == 0) insertBefore(list->root, typeHand(), list); else insertEnd(typeHand(), list); break; case 4: printf("Position to insert after (1 means root element): "); scanf("%d", &select); printf("Type in the data to insert\n"); while (getchar() != '\n'); if (select < numData) insertAfter(locateNode(select, list), typeHand(), list); else insertEnd(typeHand(), list); break; case 5: printf("Position to delete: (1 means root element)"); scanf("%d", &select); delNode(locateNode(select, list), list); break; case 6: delNode(list->cur, list); break; case 7: delNode(list->root, list); break; case 8: searchName(); while (1) { printf("Update for position number (type -1 to stop updating): "); scanf("%d", &select); while (getchar() != '\n'); if (select == -1) break; insertAfter(locateNode(select, list), typeHand(), list); delNode(locateNode(select, list), list); printf("Update success\n"); } break; case 9: printf("The length of the list is %d\n", listLength(list)); printf("Type in where to start (range from 1 to end of the list): "); scanf("%d", &startFrom); printf("Length of spliting: "); scanf("%d", &numSplit); if (listLength(list) > startFrom + numSplit) splitList(startFrom, numSplit, list, list2, list3); else splitList(startFrom, listLength(list) - startFrom, list, list2, list3); while (getchar() != '\n'); printf("Now type in 2 file name to save the new lists\n"); printf("File 1: "); scanf("%s", textName1); printf("File 2: "); scanf("%s", textName2); checkList(list2, textName1); //result of splitList checkList(list3, textName2); break; case 10: reverseList(list); break; case 11: printf("Type in the file name\n"); scanf("%s", fileName); if ((fout = fopen(fileName, "w + t")) == NULL) { printf("Can't open file %s\n", fileName); exit(1); } savetoFile(fout, list); break; case 12: list4 = countsameNum(list, list4); printf("After spliting, the new list with identical numbers: \n"); p = list4->root; while ( p != NULL ) { printf("Node with phone number: %s, address %p\n", p->element.tel, p); p = p->next; } break; case MAX: freeList(list); freeList(list2); freeList(list3); freeList(list4); exit(1); break; default: printf("Invalid choice. It must be from 1 to %d\n", MAX); break; } } while (choice != MAX); return 0; }
bool ImportNative::Create(void) { bool foundtheme = false; // Load the theme for this screen foundtheme = LoadWindowFromXML("mythnative-ui.xml", "importnative", this); if (!foundtheme) return false; bool err = false; UIUtilE::Assign(this, m_progTitle_text, "progtitle", &err); UIUtilE::Assign(this, m_progDateTime_text, "progdatetime", &err); UIUtilE::Assign(this, m_progDescription_text, "progdescription", &err); UIUtilE::Assign(this, m_chanID_text, "chanid", &err); UIUtilE::Assign(this, m_chanNo_text, "channo", &err); UIUtilE::Assign(this, m_chanName_text, "name", &err); UIUtilE::Assign(this, m_callsign_text, "callsign", &err); UIUtilE::Assign(this, m_localChanID_text, "local_chanid", &err); UIUtilE::Assign(this, m_localChanNo_text, "local_channo", &err); UIUtilE::Assign(this, m_localChanName_text, "local_name", &err); UIUtilE::Assign(this, m_localCallsign_text, "local_callsign", &err); UIUtilE::Assign(this, m_searchChanID_button, "searchchanid_button", &err); UIUtilE::Assign(this, m_searchChanNo_button, "searchchanno_button", &err); UIUtilE::Assign(this, m_searchChanName_button, "searchname_button", &err); UIUtilE::Assign(this, m_searchCallsign_button ,"searchcallsign_button", &err); UIUtilE::Assign(this, m_finishButton, "finish_button", &err); UIUtilE::Assign(this, m_prevButton, "prev_button", &err); UIUtilE::Assign(this, m_cancelButton, "cancel_button", &err); if (err) { LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'importarchive'"); return false; } connect(m_finishButton, SIGNAL(Clicked()), this, SLOT(finishedPressed())); connect(m_prevButton, SIGNAL(Clicked()), this, SLOT(prevPressed())); connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(cancelPressed())); connect(m_searchChanID_button, SIGNAL(Clicked()), this, SLOT(searchChanID())); connect(m_searchChanNo_button, SIGNAL(Clicked()), this, SLOT(searchChanNo())); connect(m_searchChanName_button, SIGNAL(Clicked()), this, SLOT(searchName())); connect(m_searchCallsign_button, SIGNAL(Clicked()), this, SLOT(searchCallsign())); m_progTitle_text->SetText(m_details.title); m_progDateTime_text->SetText(m_details.startTime.toLocalTime() .toString("dd MMM yy (hh:mm)")); m_progDescription_text->SetText( (m_details.subtitle == "" ? m_details.subtitle + "\n" : "") + m_details.description); m_chanID_text->SetText(m_details.chanID); m_chanNo_text->SetText(m_details.chanNo); m_chanName_text->SetText(m_details.chanName); m_callsign_text->SetText(m_details.callsign); findChannelMatch(m_details.chanID, m_details.chanNo, m_details.chanName, m_details.callsign); BuildFocusList(); SetFocusWidget(m_finishButton); return true; }
t_token nextToken(void){ tokenString = ""; hasTokenSecundario = false; // loop do estado inicial para pular os separadores while(isspace(nextChar)){ nextChar = readChar(); } if(nextChar == EOF){ token = ENDFILE; return token; } if( isalpha(nextChar) ){ do { tokenString = tokenString + nextChar; nextChar = readChar(); } while( isalnum(nextChar) || nextChar == '_' ); token = searchKeyWord(tokenString); //std::cout << "Read:" << text << ", Token: " << token; if(token == IDT){ tokenSecundario = searchName(tokenString); hasTokenSecundario = true; //std::cout << ", Token Secundario IDT " << tokenSecundario << std::endl; } else{ //std::cout << std::endl; } } else if( isdigit(nextChar) ){ char numeral[MAX_NUM_LEN+1]; int i = 0; //std::cout << "Read: "; do{ tokenString = tokenString + nextChar; numeral[i++] = nextChar; //std::cout << nextChar; nextChar = readChar(); }while( isdigit(nextChar) ); numeral[i] = '\0'; token = NUMERAL; //std::cout << ", Token: " << token; tokenSecundario = addIntConst(atoi(numeral)); hasTokenSecundario = true; //std::cout << ", Token Secundario Const: " << tokenSecundario << std::endl; } else if( nextChar == '"' ){ tokenString = ""; nextChar = readChar(); while(nextChar != '"'){ tokenString += nextChar; nextChar = readChar(); } token = STRINGVAL; char* cstr = new char[tokenString.size()+1]; memcpy(cstr, tokenString.c_str(), tokenString.size()+1); tokenSecundario = addStringConst(cstr); hasTokenSecundario = true; nextChar = readChar(); //std::cout << "Read: " << tokenString << ", Token: " << token << ", Token Secundario Const: " << tokenSecundario << std::endl; }else if( nextChar == '\''){ nextChar = readChar(); tokenString = nextChar; token = CHARACTER; tokenSecundario = addCharConst(nextChar); hasTokenSecundario = true; //std::cout << "Read: " << '\'' << nextChar << '\'' << ", Token: " << token << ", Token Secundario Const: " << tokenSecundario << std::endl; nextChar = readChar(); //pular o ' nextChar = readChar(); } else{ //SIMBOLOS //std::cout << "Read: " << nextChar; tokenString = nextChar; switch(nextChar){ case ':': nextChar = readChar(); token = COLON; break; case ';': nextChar = readChar(); token = SEMI_COLON; break; case ',': nextChar = readChar(); token = COMMA; break; case '[': nextChar = readChar(); token = LEFT_SQUARE; break; case ']': nextChar = readChar(); token = RIGHT_SQUARE; break; case '{': nextChar = readChar(); token = LEFT_BRACES; break; case '}': nextChar = readChar(); token = RIGHT_BRACES; break; case '(': nextChar = readChar(); token = LEFT_PARENTHESIS; break; case ')': nextChar = readChar(); token = RIGHT_PARENTHESIS; break; case '&': nextChar = readChar(); if(nextChar == '&'){ tokenString += nextChar; token = AND; nextChar = readChar(); } else{ token = UNKNOWN; } break; case '|': nextChar = readChar(); if(nextChar == '|'){ tokenString += nextChar; token = OR; nextChar = readChar(); } else{ token = UNKNOWN; } break; case '=': nextChar = readChar(); if( nextChar == '=' ) { tokenString += nextChar; token = EQUAL_EQUAL; nextChar = readChar(); } else { token = EQUALS; } break; case '<': nextChar = readChar(); if( nextChar == '=' ) { tokenString += nextChar; token = LESS_OR_EQUAL; nextChar = readChar(); } else { token = LESS_THAN; } break; case '>': nextChar = readChar(); if( nextChar == '=' ) { tokenString += nextChar; token = GREATER_OR_EQUAL; nextChar = readChar(); } else { token = GREATER_THAN; } break; case '!': nextChar = readChar(); if( nextChar == '=' ) { tokenString += nextChar; token = NOT_EQUAL; nextChar = readChar(); } else { token = NOT; } break; case '+': nextChar = readChar(); if( nextChar == '+' ) { tokenString += nextChar; token = PLUS_PLUS; nextChar = readChar(); } else { token = PLUS; } break; case '-': nextChar = readChar(); if( nextChar == '-' ) { tokenString += nextChar; token = MINUS_MINUS; nextChar = readChar(); } else { token = MINUS; } break; case '*': nextChar = readChar(); token = TIMES; break; case '/': nextChar = readChar(); token = DIVIDE; break; case '.': nextChar = readChar(); token = DOT; break; default: token = UNKNOWN; } //std::cout << ", Token: " << token << std::endl; } return token; }