void dictionary() { char newtime[100]; FILE* pf3 = fopen("log.txt","a+"); int func_choice; TREETYPE *root = NULL; root = Create_Tree(root); ELEMTYPE word[WN]; func_choice=dict_memu();//功能选择 int skip; char ch[10] = "q"; switch(func_choice) { case 1: { printf("请输入要查找的内容\n"); scanf("%s", word); skip=Search_Word(root,word); strcpy(newtime , timeinfo()); fprintf(pf3,"%s",newtime); fprintf(pf3,"%s","搜索词条: "); fprintf(pf3,"%s, ",word); if(skip==0) { fprintf(pf3, "%s\n", "不存在"); fseek(pf3,0,SEEK_END); strcpy(ch, "q"); while(NOTNEED) { printf("是否添加到字典?(y/n)\n"); scanf("%s", ch); } if(0 == strcmp(ch, "y")) goto ADDWORD; else { printf("%s","\033[1H\033[2J"); dictionary(); } } if(skip==1) { fprintf(pf3,"%s\n","成功"); fseek(pf3,0,SEEK_END); printf("查找结束,按任意键继续....\n"); setbuf(stdin, NULL); getchar(); printf("%s","\033[1H\033[2J"); dictionary(); } break; } case 2: { printf("请输入要增加的词条\n"); scanf("%s", word); ADDWORD: strcpy(newtime , timeinfo()); fprintf(pf3,"%s",newtime); fprintf(pf3,"%s","增加词条: "); fprintf(pf3,"%s, ",word); skip=Add_Word(root,word); if (-1==skip) { fprintf(pf3, "撤销操作\n"); fseek(pf3, 0, SEEK_END); printf("按任意键继续....\n"); getchar(); } if(skip==0) { fprintf(pf3, "%s\n", "已存在"); fseek(pf3,0,SEEK_END); strcpy(ch, "q"); while(NOTNEED) { printf("此单词已存在,是否进行修改?(y/n)\n"); printf("%s\n", word); Search_Word(root, word); scanf("%s", ch); } if (0 == strcmp(ch, "y")) goto MODIWORD; } if(skip==1) { fprintf(pf3,"%s\n","成功"); fseek(pf3,0,SEEK_END); sgn_save = 1; printf("添加成功,按任意键继续....\n"); setbuf(stdin, NULL); getchar(); } printf("%s","\033[1H\033[2J"); dictionary(); break; } case 3: { printf("请输入要删除的词条\n"); scanf("%s", word); strcpy(newtime , timeinfo()); fprintf(pf3,"%s",newtime); fprintf(pf3,"%s","删除词条: "); fprintf(pf3,"%s, ",word); skip = Dele_Word(root, word); if (skip == 1) { fprintf(pf3,"%s\n","成功"); fseek(pf3,0,SEEK_END); sgn_save = 1; printf("删除成功,按任意键继续...\n"); } else { fprintf(pf3,"%s\n","不存在"); fseek(pf3,0,SEEK_END); printf("词条不存在,按任意键继续...\n"); } setbuf(stdin, NULL); getchar(); printf("%s","\033[1H\033[2J"); dictionary(); break; } case 4: { printf("请输入要修改的词条\n"); scanf("%s", word); Search_Word(root, word); MODIWORD: strcpy(newtime , timeinfo()); fprintf(pf3,"%s",newtime); fprintf(pf3,"%s","修改词条: "); fprintf(pf3,"%s, ",word); skip = Modi_Word(root, word); if (skip == 1) { fprintf(pf3,"%s\n","成功"); fseek(pf3,0,SEEK_END); sgn_save = 1; printf("修改成功,按任意键继续....\n"); } else { fprintf(pf3,"%s\n","不存在"); fseek(pf3,0,SEEK_END); strcpy(ch, "q"); while(NOTNEED) { printf("是否添加?(y/n)\n"); scanf("%s", ch); } if (0 == strcmp(ch, "y")) goto ADDWORD; else { printf("%s","\033[1H\033[2J"); dictionary(); } } setbuf(stdin, NULL); getchar(); printf("%s","\033[1H\033[2J"); dictionary(); break; } case 5: { strcpy(ch, "q"); while (NOTNEED) { printf("是否覆盖已有词库?(y/n)\n"); scanf("%s", ch); } if (strcmp(ch, "y") == 0) { strcpy(newtime , timeinfo()); fprintf(pf3,"%s",newtime); fprintf(pf3,"%s","保存词库: "); fprintf(pf3,"%s, ",dictPath); if(Overwrite_Dict(TMPPATH, dictPath)==1) { fprintf(pf3,"%s\n","成功"); fseek(pf3,0,SEEK_END); printf("保存成功,按任意键继续....\n"); sgn_save = 0; } else { fprintf(pf3,"%s\n","失败"); fseek(pf3,0,SEEK_END); printf("抱歉,保存失败,按任意键继续....\n"); } } else { fprintf(pf3, "%s\n", "撤销操作"); fseek(pf3, 0 , SEEK_END); printf("已取消操作,按任意键继续....\n"); } setbuf(stdin, NULL); getchar(); printf("%s","\033[1H\033[2J"); dictionary(); break; } case 6: { char ch[10] = "q"; if (sgn_save) { while (NOTNEED) { printf("文件已修改,是否保存?(y/n)\n"); scanf("%s", ch); } if (0 == strcmp(ch, "y")) { strcpy(newtime , timeinfo()); fprintf(pf3,"%s",newtime); fprintf(pf3,"%s","保存词库: "); fprintf(pf3,"%s, ",dictPath); if(Overwrite_Dict(TMPPATH, dictPath)==1) { fprintf(pf3,"%s\n","成功"); fseek(pf3,0,SEEK_END); printf("保存成功,按任意键继续....\n"); } else { fprintf(pf3,"%s\n","失败"); fseek(pf3,0,SEEK_END); printf("抱歉,保存失败,按任意键继续....\n"); } setbuf(stdin, NULL); getchar(); } sgn_save = 0; } printf("%s","\033[1H\033[2J"); main_menu(); } default: break; } }
void ICACHE_FLASH_ATTR process_form(char *pdata , unsigned short len,void * conn) { int Locations[10]; int length[9]; int address[0]; char Post_Error=0; char Local_Port[5]=""; char Remote_Port[5]=""; int LP,RP; int Header_type; int Mode; int Buffer_Size; TCP_recieved_flag=1; if(Search_Word(pdata,10,"POST")!=-1){ Locations[0]=Search_Word(pdata,len,"RID"); Locations[1]=Search_Word(pdata,len,"&RPWD"); Locations[2]=Search_Word(pdata,len,"&AID"); Locations[3]=Search_Word(pdata,len,"&APWD"); Locations[4]=Search_Word(pdata,len,"&STATION"); Locations[5]=Search_Word(pdata,len,"&UDPLP"); Locations[6]=Search_Word(pdata,len,"&UDPRP"); Locations[7]=Search_Word(pdata,len,"&TERMINATOR"); Locations[8]=Search_Word(pdata,len,"&PCTSIZE"); length[0]=Locations[1]-Locations[0]-4; length[1]=Locations[2]-Locations[1]-6; length[2]=Locations[3]-Locations[2]-5; length[3]=Locations[4]-Locations[3]-6; length[4]=Locations[5]-Locations[4]-9; length[5]=Locations[6]-Locations[5]-7; length[6]=Locations[7]-Locations[6]-7; length[7]=Locations[8]-Locations[7]-12; address[0]=Locations[0]+4; address[1]=Locations[1]+6; address[2]=Locations[2]+5; address[3]=Locations[3]+6; address[4]=Locations[4]+9; address[5]=Locations[5]+7; address[6]=Locations[6]+7; address[7]=Locations[7]+12; address[8]=Locations[8]+9; if(length[0]>0 && address[0]!=-1){ os_memcpy(&info.Router_ssid,&pdata[address[0]],length[0]); } if(length[1]>0 && address[1]!=-1){ os_memcpy(&info.Router_password,&pdata[address[1]],length[1]); } if(length[2]>0 && address[2]!=-1){ os_memcpy(&info.Soft_AP_ssid,&pdata[address[2]],length[2]); } if(length[3]>0 && address[3]!=-1){ os_memcpy(&info.Soft_AP_password,&pdata[address[3]],length[3]); } if(length[6]>0 && address[6]!=-1){ os_memcpy(&Remote_Port,&pdata[address[6]],length[6]); RP=Ptoi(Remote_Port); info.UDP_Client_Port=(uint32)RP; } if(length[5]>0 && address[5]!=-1){ os_memcpy(&Local_Port,&pdata[address[5]],length[5]); LP=Ptoi(Local_Port); info.UDP_Server_Port=(uint32)LP; } if(address[4]!=-1) info.Mode=(uint32)pdata[address[4]]; if(address[7]!=-1) info.Terminator=(uint32)pdata[address[7]]; os_memcpy(&conv.data_struct,&info,sizeof(info)); spi_flash_erase_sector(0x3D); spi_flash_write(0x3D000,conv.data,sizeof(info)); TCP_Send((struct espconn *)conn,"<h1>OK!!! ,Changes Saved<h1>",sizeof("<h1>OK!!! ,Changes Saved<h1>")); return ; } headers((struct espconn *) conn ,"http"); TCP_Send((struct espconn *)conn,Page,os_strlen(Page)); }