//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure striptilltoken //Author Robert Slater //Date Thu 1 Feb 1996 // //Description // //Inputs // //Returns // //------------------------------------------------------------------------------ static string Trans3d::striptilltoken(file ifile, TokenCode requiredcode) { char *text; text = TokenSpell::getword(ifile); while (!checktoken(ifile,text,requiredcode)) text = TokenSpell::getword(ifile); return(text); }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 // //Procedure bfieldstudiointerpreter //Author Rob Slater //Date Mon 29 Jan 1996 // //Description Converts a 3d studio file to a bfield text tree // //Inputs The 3d studio ascii file // //Returns // //------------------------------------------------------------------------------ static void Trans3d::bfieldstudiointerpreter(file ifile) { char *nexttext; while (TokenSpell::stripwhite(ifile)) { nexttext = TokenSpell::getword(ifile); if ( checktoken(ifile,nexttext,T_named) && checktoken(ifile,nexttext,T_object) ) { if (nexttext[0] != ':') EmitSysErr("':' was expected; not a standard 3d Studio file!"); get3dsentry(ifile); } } fclose(ifile); }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure pullvertex //Author Robert Slater //Date Tue 30 Jan 1996 // //Description Extracts a single line of vertex points // //Inputs // //Returns // //------------------------------------------------------------------------------ static void Trans3d::pullvertex(file ifile, int &x, int &y, int &z) { char *text; char sign; // Default c**k-up values... x = 0; y = 0; z = 0; text = striptilltoken(ifile,T_vertex); Assert (isnumeric(text,sign)); { text = TokenSpell::getword(ifile); Assert (text[0] == ':'); { // Get data... text = TokenSpell::getword(ifile); Assert ( checktoken(ifile,text,T_x) && (text[0] == ':') ); x = texttoint(TokenSpell::getword(ifile)); text = TokenSpell::getword(ifile); Assert ( checktoken(ifile,text,T_y) && (text[0] == ':') ); y = texttoint(TokenSpell::getword(ifile)); text = TokenSpell::getword(ifile); Assert ( checktoken(ifile,text,T_z) && (text[0] == ':') ); z = texttoint(TokenSpell::getword(ifile)); } } }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure pointliststudiointerpreter //Author Robert Slater //Date Wed 3 Apr 1996 // //Description Converts a 3d studio file to a world coordinate point list // //Inputs The 3d studio ascii file // //Returns // //------------------------------------------------------------------------------ static point* Trans3d::pointliststudiointerpreter(file ifile) { char *nexttext; while (TokenSpell::stripwhite(ifile)) { nexttext = TokenSpell::getword(ifile); if ( checktoken(ifile,nexttext,T_named) && checktoken(ifile,nexttext,T_object) ) { if (nexttext[0] != ':') EmitSysErr("':' was expected; not a standard 3d Studio file!"); makepointlist(ifile); } } fclose(ifile); return(pointroot); }
void MainWindow::readAnswer() { QString data = client->readAll(); QString answer = data.split("||").first(); if (answer=="LOG_OK") { token = data.split("||").value(1); checktoken(); } else if (answer=="LOG_NOUSR") { QMessageBox msg; msg.setText("Неправильное имя пользователя!"); msg.exec(); } else if (answer=="REG_FAIL") { QMessageBox msg; msg.setText("Такой пользователь уже есть!"); msg.exec(); } else if (answer=="REG_OK") { QMessageBox msg; msg.setText("Пользователь зарегистрирован успешно!"); msg.exec(); } else if (answer=="TOKEN_OK") { proceed(); } else if (answer=="TOKEN_FAIL") { //could possibly do something } else { QMessageBox msg; msg.setText("Неизвестная ошибка!"); msg.exec(); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setWindowIcon(QIcon("../ClientPro/icon.png")); QFile serv("../ClientPro/address"); if (serv.open(QIODevice::ReadOnly)) { QString s = QString(serv.readAll()); ui->ipLine->setText(s.split(":").first()); ui->portLine->setText(s.split(":").last()); } QFile file("../ClientPro/token"); if (file.open(QIODevice::ReadOnly)) { QString s = QString(file.readAll()); token=s; file.close(); } checktoken(); this->setFixedSize(301,200); }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure makepointlist //Author Robert Slater //Date Tue 2 Apr 1996 // //Description Constructs a linked list of 3dstudio vertices. // If it is a route then the points are linked, // otherwise they are stored as single points. // //Inputs // //Returns // //------------------------------------------------------------------------------ static void Trans3d::makepointlist(file ifile) { char name[80], *nexttext, letter; char nvertstext[80], nfacestext[80]; Bool finished, route; int noverts, nofaces, vertno; Coordinates *vertex; Connections *face; char *material; point *thispoint; int number; strcpy(name,TokenSpell::getword(ifile)); finished = FALSE; while(!finished) { nexttext = TokenSpell::getword(ifile); if ( checktoken(ifile,nexttext,T_vertex) && (nexttext[0] == ':') ) strcpy(nvertstext,TokenSpell::getword(ifile)); if ( checktoken(ifile,nexttext,T_face) && (nexttext[0] == ':') ) { strcpy(nfacestext,TokenSpell::getword(ifile)); finished = TRUE; } } noverts = texttoint(nvertstext); nofaces = texttoint(nfacestext); if (noverts > 0) { pullvertices(ifile,noverts,vertex); material = pullfaces(ifile,nofaces,face); route = checkforroute(face,nofaces,noverts); for (vertno = 0; vertno < noverts; vertno++) { thispoint = (point*) new point; thispoint->x = (vertex[vertno].x / 512) * 100; thispoint->y = (vertex[vertno].y / 512) * 100; thispoint->adj1 = NULL; thispoint->adj2 = NULL; if (pointroot) { nextpoint->next = thispoint; nextpoint = thispoint; } else pointroot = nextpoint = thispoint; } nextpoint->next = NULL; if (route) { nextpoint = pointroot; do { thispoint = nextpoint; nextpoint = thispoint->next; thispoint->adj1 = nextpoint; if (nextpoint) nextpoint->adj2 = thispoint; } while (nextpoint); nextpoint = thispoint; } delete []material; delete []face; delete []vertex; } }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure get3dsentry //Author Robert Slater //Date Tue 30 Jan 1996 // //Description // //Inputs // //Returns // //------------------------------------------------------------------------------ static void Trans3d::get3dsentry(file ifile) { char name[80], *nexttext, letter; char nvertstext[80], nfacestext[80]; Bool finished, route; int noverts, nofaces, vertno; Coordinates *vertex; Connections *face; char tag[4]; char routename[80]; char *material; strcpy(name,TokenSpell::getword(ifile)); finished = FALSE; while(!finished) { nexttext = TokenSpell::getword(ifile); if ( checktoken(ifile,nexttext,T_vertex) && (nexttext[0] == ':') ) strcpy(nvertstext,TokenSpell::getword(ifile)); if ( checktoken(ifile,nexttext,T_face) && (nexttext[0] == ':') ) { strcpy(nfacestext,TokenSpell::getword(ifile)); finished = TRUE; } } noverts = texttoint(nvertstext); nofaces = texttoint(nfacestext); if (noverts <= 30) { pullvertices(ifile,noverts,vertex); material = pullfaces(ifile,nofaces,face); route = checkforroute(face,nofaces,noverts); if (route) { for(vertno = 0; vertno < noverts; vertno++) { letter = (char)('A' + vertno); tag[0] = '_'; tag[1] = letter; tag[2] = 0; strcpy(routename,name); strcat(routename,tag); add3dsentry(routename, vertex[vertno].x, vertex[vertno].y, vertex[vertno].z, NULL); } } else add3dsentry(name, vertex[0].x, vertex[0].y, vertex[0].z, material); delete []material; delete []face; delete []vertex; } }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure pullfaceline //Author Robert Slater //Date Tue 30 Jan 1996 // //Description Extracts a single line of face information // //Inputs // //Returns // //------------------------------------------------------------------------------ static string Trans3d::pullfaceline(file ifile, int &a, int &b, int &c) { char *text; string material; char *temp; char sign; int count; char charcopy; Bool stop; // Default values... to detect no-match situation a = -1; b = -1; c = -1; material = NULL; text = striptilltoken(ifile,T_face); Assert (isnumeric(text,sign)); { text = TokenSpell::getword(ifile); Assert (text[0] == ':'); { text = TokenSpell::getword(ifile); Assert ( checktoken(ifile,text,T_a) && (text[0] == ':') ); a = texttoint(TokenSpell::getword(ifile)); text = TokenSpell::getword(ifile); Assert ( checktoken(ifile,text,T_b) && (text[0] == ':') ); b = texttoint(TokenSpell::getword(ifile)); text = TokenSpell::getword(ifile); Assert ( checktoken(ifile,text,T_c) && (text[0] == ':') ); c = texttoint(TokenSpell::getword(ifile)); text = TokenSpell::getword(ifile); while (!checktoken(ifile,text,T_mtl)) text = TokenSpell::getword(ifile); if (text[0] == ':') { material = temp = TokenSpell::getword(ifile); // Remove quotes & full stops... count = 0; stop = FALSE; charcopy = temp[0]; if (*temp=='"') material = ++temp; while (*temp!=0 && *temp!='"' && *temp!='.') temp++; *temp=0; if (strcmp(material,"Default") == 0) return(NULL); } else EmitSysErr("Material description not found!"); } } return(material); }
int main(int argc, char *argv[]){ if(argc == 1){ printf("Please enter a index file \n"); printf("Usage: <name of compiled program> <option> <Memory Size> <Index File> \n"); } if(argc == 4){ FILE *fp; /***** CONVERT INPUTTED STRING TO MEMORY SIZE *******/ data *dataptr = (data *) malloc(sizeof(struct data_)); char *rawmemory = argv[2]; int num = 0; char *memory = rawmemory; int multiplier; while(isdigit(*rawmemory)){ num++; rawmemory++; } if(*rawmemory == 'K'){ multiplier = 1024; } if(*rawmemory == 'M'){ multiplier = 1024 * 1024; } if(*rawmemory == 'G'){ multiplier = 1024 * 1024 * 1024; } *rawmemory = '\0'; dataptr->maxmemory = atoi(memory) * multiplier; dataptr->currmemory = 0; /**************************************************/ char line[1000]; TokenizerT *tokenizer; char *token; word *newword; int memusage = 0; dataptr->file = argv[3]; fp = fopen(argv[3], "r"); if(fp == NULL){ fprintf(stderr, "file could not be opened \n"); } while(fgets(line, 1000, fp) != NULL){ tokenizer = TKCreate(line); token = TKGetNextToken(tokenizer); while (token != NULL){ checktoken(token); if(start == 1){ if (!(counter % 2)){ /* THIS IS WHERE I GET THE FILENAME STRING OF EACH WORD*/ LLInsert(newword->filelist, token); memusage = memusage + strlen(token); } counter++; } /*fprintf(fp2, "%s \n", token);*/ token = TKGetNextToken(tokenizer); if(var == 1){ newword = (word *)malloc(sizeof(struct words)); newword->string = token; newword->filelist = LLCreate(); memusage = memusage + strlen(token); var = 0; start = 1; counter++; } if(var2 == 1){ /* AFTER I HAVE ADDED ALL THE FILENAME INDEXES TO THE WORD THEN I INSERT IT INTO listwords array and print it out onto the console */ if(memusage + dataptr->currmemory > dataptr->maxmemory){ free(newword); break; } else{ listwords[lwsize] = newword; lwsize++; var2 = 0; dataptr->currmemory = dataptr->currmemory + memusage; newword->memory = memusage; memusage = 0; } } } if(memusage + dataptr->currmemory > dataptr->maxmemory) break; } var = 0; var2 = 0; start = 0; TKDestroy(tokenizer); fclose(fp); char str[100]; int x; for(; ;){ linkedListPtr searchlist = LLCreate(); linkedListPtr foundlist = LLCreate(); /* LOOPING USER INTERFACE */ printf("search> "); fgets(str, 100, stdin); x = strlen(str)-1; if(str[x] == '\n') str[x] = '\0'; token = strtok(str, " "); LLInsert(searchlist, token); while ((token = (strtok(NULL, " "))) != NULL){ LLInsert(searchlist, token); searchlist->size++; } if (strcmp(searchlist->head->filename, "q") == 0){ break; } if(strcmp(searchlist->head->filename, "so") == 0){ searchlist->head = searchlist->head->next; searchor(foundlist, searchlist, dataptr); } else if(strcmp(searchlist->head->filename, "sa") == 0){ searchlist->head = searchlist->head->next; searchand(foundlist, searchlist, dataptr); } LLDestroy(searchlist); LLDestroy(foundlist); } int i; for (i = 0; i < lwsize; i++){ LLDestroy(listwords[i]->filelist); free(listwords[i]->string); free(listwords[i]); } } }