void InputMemberData(BAN *pMember) { InputString("ID",&pMember->id); InputString("Name",&pMember->name); InputString("NumberPhone",&pMember->numberphone); InputString("Date",&pMember->datetime); }
int main() { char *text, *pattern; size_t length_of_text = 128, length_of_pattern = 128; int q, d; printf("Enter Text: "); text = InputString(stdin, &length_of_text); printf("Enter Pattern: "); pattern = InputString(stdin, &length_of_pattern); printf("Enter d: "); scanf("%d", &d); printf("Enter q: "); scanf("%d", &q); RabinKarpMatcher(text, pattern, length_of_text - 1, length_of_pattern - 1, d, q); free(text); free(pattern); return 0; }
DATA InputData() { DATA data; char *str = "\0"; InputString("New Word:",&data.word); InputString("Mean:", &data.mean); return data; }
void InputBookData(BOOK *pBook) { int AuthorIndex ; int ContentIndex; InputString("ISBN code",&pBook->b_Isbncode); InputString("Title",&pBook->b_Title ); InputString("Publisher",&pBook->b_Publisher ); InputPrice("Price",&pBook->b_Price); InputAuthor(&pBook->AuthorList,&AuthorIndex,sizeof(pBook->AuthorList.Author)/sizeof(pBook->AuthorList.Author[0])); InputContent(&pBook->ContentList,&ContentIndex,sizeof(pBook->ContentList.Content)/sizeof(pBook->ContentList.Content[0])); }
void RestoreConfig() { int n; char *envname; char envbuf[256]; char *name; char *ptr; char buf[80]; SetColor(LIGHTWHITE); SetBackColor(BLUE); OpenWindow(10,10,3,60); SetColor(YELLOW); Print_At(10,13," Restore Predefined Configuration "); SetColor(LIGHTWHITE); Print_At(11,12,"Enter file name:"); name=InputString(11,30,37,cfgfilename); if(name!=NULL && name[0]!=0) { strcpy(buf,name); ptr=(char *)strchr(buf,'.'); if(ptr!=NULL) strset(ptr,0); strcpy(cfgfilename,buf); strcat(buf,".d32"); n=open(buf,O_RDONLY | O_BINARY); if(n==-1) { envname=getenv("DOS32A"); if(envname!=NULL) { ptr=strchr(envname,' '); if(ptr==NULL) ptr=strchr(envname,0); memset(envbuf,0,256); strncpy(envbuf,envname,(dword)ptr-(dword)envname); strcat(envbuf,"\\D32\\"); strcat(envbuf,buf); n=open(envbuf,O_RDWR | O_BINARY); } } if(n!=-1) { read(n,&id32,24); close(n); SetColor(LIGHTWHITE); SetBackColor(BLUE); strupr(buf); for(n=0; n<13; n++) { SetPos(24,66+n); PrintC(' '); } Print_At(24,66,"%.13s",buf); } else DiskError(); } ValidateConfig(); CloseWindow(); if(mainmenu_sel==1) ShowBannerStatus(); }
int WheterSavaASPM() { char str[13]=""; int suc,enter,i; for (i=0;i<13 && setup_data.jdfroute_name[i] != '.';++i) str[i] = setup_data.jdfroute_name[i]; str[i>=13 ? 12 : i] = 0; PopUpWin(4); DispStr(24,8,"\xce\xc4\xbc\xfe\xc3\xfb(*.pm)");//file_name do { suc = InputString(24,24,str,1,8); if (suc==KEY_CTRL_EXIT) break; if (! str[0]) continue; }while(suc!=KEY_CTRL_EXE); if(suc!=KEY_CTRL_EXIT) { enter = 1; strcat(str,".pm"); if (TestPMFile(str)) { enter = WhetherCoverPM(); } if (enter) { SavePMFile(str); strcpy(setup_data.pmroute_name,str); } } }
/****************************************************************************** * ++ * Method name : CListStudent::Update(string sID) * Description : Cap nhat thong tin sinh vien * * Parameters : * string sID: ma cua sinh vien can cap nhat thong tin * Return values : * IS_SUCCESS : cap nhat thanh cong * NOT_SUCCESS : cap nhat khong thanh cong * -- *****************************************************************************/ bool CListStudent::Update(string sID) { //Tien hanh lay sinh vien co ma la chuoi truyen vao CStudent* cStudent = this->GetStudentByID(sID); if(cStudent) //Neu sinh vien ton tai { //Nhap thong tin sinh vien cStudent->InputInformation(); //Lay ma lop sau khi nhap thong tin string sString = cStudent->GetClassID(); //Neu ma lop khong ton tai while(g_cSchool->GetListClass()->IsValidateClass(sString)) { cout<<endl<<"Class ID is not exist, please enter another Class ID!"<<endl; //Tien hanh nhap lai ma lop cout<<"Class ID: "; InputString(sString); sString = StringToUpper(sString); } cStudent->SetClassID(sString); //Gan gia tri moi cho ma lop return IS_SUCCESS; } return NOT_SUCCESS; }
pDICT MakeDictionary() { pDICT root =NULL; DATA temp1,temp2; char *str = "\0"; temp1 = InputData(); root = CreateWord(temp1); while (1) { InputString("New Word:",&temp2.word); if(strcmp(temp2.word, str)==0) break; InputString("Mean's:", &temp2.mean); AddWordTree(root,temp2); } return root; }
/****************************************************************************** * ++ * Method name :CSubject::Input() * Description : Nhap thong tin cho mon hoc bao gom ca ma mon hoc * -- *****************************************************************************/ void CSubject::Input() { //Tien hanh nhap ma mon hoc cout<<"Subject ID: "; InputString(this->m_sID); //Chuyen ma mon hoc sang kieu in hoa this->m_sID = StringToUpper(this->m_sID); //Tien hanh nhap thong tin mon hoc this->InputInformation(); }
/****************************************************************************** * ++ * Method name : CSubject::InputInformation() * Description : Nhap thong tin cho mon hoc * -- *****************************************************************************/ void CSubject::InputInformation() { //Tien hanh nhap ten mon hoc cout<<"Name: "; InputString(this->m_sName); bool bCheck = false; do { //Tien hanh nhap he so mon hoc cout<<"Coefficient: "; string sString; InputString(sString); //Chuyen chuoi nhap vao sang kieu so thuc bCheck = ConvertStringToFloat(sString, m_flCoefficient); if(bCheck == NOT_SUCCESS) //Neu chuyen khong thanh cong { cout<<"Coefficient isn't valid. Please enter Coefficient again!"<<endl; } }while(bCheck == NOT_SUCCESS); //Neu he so nhap vao khong hop le, cho nguoi dung nhap lai }
/****************************************************************************** * ++ * Method name : CListStudent::CreateStudent() * Description : Tao moi mot sinh vien * * Return values : * cStudent : sinh vien moi tao * -- *****************************************************************************/ CStudent* CListStudent::CreateStudent() { //Khoi tao sinh vien moi CStudent* cStudent = new CStudent(); //Tien hanh nhap du lieu cho sinh vien cStudent->Input(); string sString = cStudent->GetID(); //Neu ma sinh vien da ton tai while(IsValidateStudent(sString) == NOT_VALIDATE) { cout<<endl<<"ID is inserted, please enter new ID!"<<endl; //Tien hanh nhap lai ma sinh vien cout<<"ID: "; InputString(sString); //Chuyen ma sinh vien sang kieu in hoa sString = StringToUpper(sString); } cStudent->SetID(sString); sString = cStudent->GetClassID(); //Neu ma lop khong ton tai while(g_cSchool->GetListClass()->IsValidateClass(sString) == IS_VALIDATE) { cout<<endl<<"Class ID is not exist, please enter another Class ID!"<<endl; //Tien hanh nhap lai ma lop cout<<"Class ID: "; InputString(sString); sString = StringToUpper(sString); } cStudent->SetClassID(sString); //Gan gia tri moi cho ma lop return cStudent; }
void InputContent(Content *pContent, int *piIndex, int iContentArraySize) { char *String; String = "\0" ; *piIndex = 0; while(*piIndex <10) { if(*piIndex >= iContentArraySize) { break; } else { InputString("Content ",&pContent->Content[*piIndex]); if(strcmp(pContent->Content[*piIndex], String) == 0) break; } ++(*piIndex); } }
void InputAuthor(Author *pAuthor,int *piIndex, int iAuthorArraySize) { char *String; String = "\0" ; *piIndex = 0; while(*piIndex <5) { if(*piIndex >= iAuthorArraySize) { break; } else { InputString("Author ",&pAuthor->Author[*piIndex]); if(strcmp(pAuthor->Author[*piIndex], String) == 0) break; } ++(*piIndex); } }
void CreateConfig() { int n; char *name; char *ptr; char buf[80]; SetColor(LIGHTWHITE); SetBackColor(BLUE); OpenWindow(10,10,3,60); SetColor(YELLOW); Print_At(10,13," Create Predefined Configuration "); SetColor(LIGHTWHITE); Print_At(11,12,"Enter file name:"); name=InputString(11,30,37,cfgfilename); if(name!=NULL && name[0]!=0) { strcpy(buf,name); ptr=(char *)strchr(buf,'.'); if(ptr!=NULL) strset(ptr,0); strcpy(cfgfilename,buf); strcat(buf,".D32"); n=open(buf,O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU); if(n!=-1) { write(n,&id32,24); close(n); SetColor(LIGHTWHITE); SetBackColor(BLUE); strupr(buf); for(n=0; n<13; n++) { SetPos(24,66+n); PrintC(' '); } Print_At(24,66,"%.13s",buf); } else DiskError(); } CloseWindow(); }
/****************************************************************************** * ++ * Method name : CListSubject::CreateSubject() * Description : Tao moi mot mon hoc * * Return values : * cSubject : mon hoc moi tao * -- *****************************************************************************/ CSubject* CListSubject::CreateSubject() { //Khoi tao mon hoc moi CSubject* cSubject = new CSubject(); //Tien hanh nhap thong tin mon hoc moi cSubject->Input(); //Tien hanh kiem tra ma mon hoc co hop le string sString = cSubject->GetID(); //Neu ma mon hoc khong hop le while(IsValidateSubject(sString) == NOT_VALIDATE) { //Tien hanh nhap lai ma mon hoc cout<<endl<<"Subject ID is inserted, please enter new ID!"<<endl; cout<<"Subject ID: "; InputString(sString); //Chuyen ma mon hoc sang kieu in hoa sString = StringToUpper(sString); } cSubject->SetID(sString); return cSubject; }
int main(void) { I_REQUEST_H hd ; I_RESULT_H rd ; I_LOGIN_IN in ; I_LOGIN_OUT out ; char productid[PRODUCTID_LEN+1] = {'\0'} ; char notice[NOTICE_LEN+1] = {'\0'} ; memset(&hd, 0, sizeof(I_REQUEST_H)) ; memset(&rd, 0, sizeof(I_RESULT_H)) ; memset(&in, 0, sizeof(I_LOGIN_IN)) ; memset(&out, 0, sizeof(I_LOGIN_OUT)) ; hd.serviceid = htonl(MSG_LOGIN) ; InputInt("hd.mdn", &(hd.mdn), 1031993325) ; hd.mdn = htonl(hd.mdn) ; InputString("PRODUCTID", productid, PRODUCTID_LEN+1, "ABCD") ; memcpy(in.productid, productid, PRODUCTID_LEN) ; int wlen, rlen ; struct sockaddr_in serv_addr; memset((char *) &serv_addr, 0, sizeof(serv_addr)) ; serv_addr.sin_family = AF_INET ; serv_addr.sin_addr.s_addr = inet_addr(SM_SERVER_IP) ; serv_addr.sin_port = htons(SM_SERVER_PORT) ; if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("clientsoc: can't open stream socket") ; close(sockfd), exit(0); } if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) { printf("clientsoc: can't connect to server") ; close(sockfd), exit(0); } ///[SEND]//////////////// if((wlen = write(sockfd, &hd, sizeof(I_REQUEST_H))) <= 0) { printf("ERR: write I_REQUEST_H[wlen:%d]\n", wlen) ; close(sockfd), exit(1) ; } printf("SEND: I_REQUEST_H[wlen:%d]\n", wlen) ; if((wlen = write(sockfd, &in, sizeof(I_LOGIN_IN))) <= 0) { printf("ERR: write I_LOGIN_IN[wlen:%d]\n", wlen) ; close(sockfd), exit(1) ; } printf("SEND: I_LOGIN_IN[wlen:%d]\n", wlen) ; ///[READ]//////////////// if ((rlen = read(sockfd, &rd, sizeof(I_RESULT_H))) <= 0) { printf("ERR: read DATA_SD[rlen:%d]...\n", rlen) ; close(sockfd), exit(1) ; } printf("READ: I_RESULT_H[rlen:%d]\n", rlen) ; rd.error = ntohl(rd.error) ; rd.count = ntohl(rd.count) ; rd.total = ntohl(rd.total) ; printf("I_RESULT_H: error[%d] count[%d] total[%d]\n", rd.error, rd.count, rd.total) ; if ((rlen = read(sockfd, &out, sizeof(I_LOGIN_OUT))) <= 0) { printf("ERR: read DATA_SD[rlen:%d]...\n", rlen) ; close(sockfd), exit(1) ; } printf("READ: I_LOGIN_OUT[rlen:%d]\n", rlen) ; out.road = ntohl(out.road) ; out.highway= ntohl(out.highway) ; out.req_date = ntohl(out.req_date) ; out.req_time = ntohl(out.req_time) ; out.size = ntohl(out.size) ; printf("road[%d]highway[%d]-req_date[%d]time[%d]-regnum[%.13s]carrier[%c]sms[%c]service[%d]size[%d]\n", out.road, out.highway, out.req_date, out.req_time, out.regnum, out.carrier, out.sms, out.service, out.size) ; if(out.size > 0) { if ((rlen = read(sockfd, notice, out.size)) <= 0) { printf("ERR: read DATA_SD[rlen:%d]...\n", rlen) ; close(sockfd), exit(1) ; } printf("notice[%s]\n", notice) ; } exit_handler() ; }
ClassLong::ClassLong(const char* str) { this->number = InputString(str); }
void InputTelnoDetail(TELNO *pTelNo) { InputString("Name",&pTelNo->t_name); InputString("Number Phone",&pTelNo->t_telno); }
int _tmain(int argc, TCHAR** argv) { char szPath[MAX_PATH] = ""; GetModuleFileNameA(NULL, szPath, MAX_PATH); strrchr(szPath, '\\')[1] = '\0'; std::string sDllPath = szPath; sDllPath += "WinIo32.dll"; std::string sDrvPath = szPath; sDrvPath += "WinIo64.sys"; HMODULE hLib = LoadLibraryA(sDllPath.c_str()); if (hLib == NULL) { printf("Failed to load winio32.dll"); return -1; } InitializeWinIo = (_InitializeWinIo)GetProcAddress(hLib, "InitializeWinIo"); ShutdownWinIo = (_ShutdownWinIo)GetProcAddress(hLib, "ShutdownWinIo"); InstallWinIoDriver = (_InstallWinIoDriver)GetProcAddress(hLib, "InstallWinIoDriver"); RemoveWinIoDriver = (_RemoveWinIoDriver)GetProcAddress(hLib, "RemoveWinIoDriver"); GetPortVal = (_GetPortVal)GetProcAddress(hLib, "GetPortVal"); SetPortVal = (_SetPortVal)GetProcAddress(hLib, "SetPortVal"); static unsigned int nWaitMilliSeconds = 25; static std::string sInput = ""; int c; while (1) { static struct option long_options[] = { { _T("wait"), ARG_REQ, 0, _T('w') }, { _T("install"), ARG_NULL, 0, _T('i') }, { _T("remove"), ARG_NULL, 0, _T('r') }, { _T("help"), ARG_NULL, 0, _T('h') }, { ARG_NULL , ARG_NULL , ARG_NULL , ARG_NULL } }; int option_index = 0; c = getopt_long(argc, argv, _T("w:hir"), long_options, &option_index); // Check for end of operation or error if (c == -1) break; // Handle options switch (c) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; case _T('w'): nWaitMilliSeconds = std::atoi(optarg); break; case _T('i'): if (!InstallWinIoDriver((char *)sDrvPath.c_str(), false)) { printf("Failed to install driver, winio64.sys"); return -1; } else { return 0; } case _T('r'): if (!RemoveWinIoDriver()) { printf("Failed to remove driver, winio64.sys"); return -1; } else { return 0; } case _T('h'): PrintHelp(argv[0]); return 0; case '?': /* getopt_long already printed an error message. */ break; default: abort(); } } if (optind < argc) { sInput = argv[optind]; } // End of command line parsing. // Start to Input characters. if (!InitializeWinIo()) { printf("Failed to initialize winio"); return -1; } InputString(sInput, nWaitMilliSeconds); ::Sleep(1000); ShutdownWinIo(); FreeLibrary(hLib); return 0; }
int computeFS () { uint refresh = 2,key; int index = 0,i,hcs; char ch; double ht,hz,v,bh,hd; double value[4] = {0.0,0.0,0.0,0.0}; const char * context[] = {"","","",""}; while(1){ if (refresh == REFRESH_ALL){ refresh = REFRESH_PART; Bdisp_AllClr_VRAM(); SetMyFont(&stHz12x12,&stAsc6x12); //¶¨Òå×ÖÌå´óС DispStr(2,1, "Ïß "); DispStr(2,12,"· "); DispStr(2,25,"·´ "); DispStr(2,38,"Ëã "); ShowTitle(TITLE); DispStr(17,0, "×ø±êX: "); DispStr(17,13,"×ø±êY: "); DispStr(17,26,"×ø±êZ: "); //DispStr(17,39,"×ø±êZ: "); for (i=0;i<4;++i){ PrintXY(50,2+i*12,(uchar*)context[i],0); } PrintIcon (0,"Rou",0); PrintIcon (1,"Set",0); PrintIcon (2,"Disp",0); PrintIcon (3,"=0=",1); PrintIcon (4,"Save",1); PrintIcon (5,"?",0); } if (refresh == REFRESH_PART){ for (i=0;i<4;++i){ PrintFloat(value[i],48,0+i*12,index==i,4); //ÊäÈë¿òλÖà } refresh = 0; } GetKey(&key); switch(key){ case KEY_CTRL_F1 : SET(); refresh=REFRESH_ALL; break; case KEY_CTRL_F2 : ZSSET(); refresh=REFRESH_ALL; break; case KEY_CTRL_F3 : RestoreDisp(SAVEDISP_PAGE1);refresh=REFRESH_ALL;WaitKey();break; case KEY_CTRL_F4 : case KEY_CTRL_F5 : Nodata(); refresh=REFRESH_ALL; break; case KEY_CTRL_F6 : About(); refresh=REFRESH_ALL; break; case KEY_CTRL_UP : refresh=REFRESH_PART; --index; break; case KEY_CTRL_DOWN : refresh=REFRESH_PART; ++index; break; case KEY_CTRL_EXE: if (index<3){ refresh = REFRESH_PART; index++; }else{ yscs.x1 = value[0]; yscs.y1 = value[1]; hz = value[2]; ht = value[3]; refresh=REFRESH_ALL; //yscs.k=0.0; yscs.k=xy_to_sdSrd( yscs.x1, yscs.y1, 0); yscs.d=xy_to_sdSrd( yscs.x1, yscs.y1, 1); //yscs.k=xy_to_sd( yscs.x1, yscs.y1, 0); //yscs.d=xy_to_sd( yscs.x1, yscs.y1, 1); //FS(); GC(); HP(); if (yscs.d<0) hcs=-1; //Æ«¾à×ó²à if (yscs.d>=0) hcs=1; //Æ«¾àÓÒ²à if (yscs.d*hcs<=zfset.zsp) hd=0; // if (zfset.zsh==0) hd=0; if (yscs.d*hcs>zfset.zsp && yscs.d*hcs-zfset.zsp<zfset.zsh) hd=(yscs.d*hcs-zfset.zsp)*hcs; if (yscs.d*hcs-zfset.zsp>=zfset.zsh) hd=zfset.zsh*hcs; bh=yscs.gch+(yscs.hpd*hd)-ht; Bdisp_AllClr_VRAM(); DispStr(2,0, "¼Æ "); DispStr(2,12,"Ëã "); DispStr(2,26,"½á "); DispStr(2,39,"¹û "); ShowTitle(TITLE); DispStr(17,0,"×®ºÅ "); DispStr(17,13,"Æ«¾à "); DispStr(17,26,"ÌîÍÚ: "); DispStr(17,39,"»ù¸ß: "); PrintfXY (48,2.5,0,"%.4f",yscs.k); PrintfXY (48,15,0,"%.4f",yscs.d); PrintfXY (48,28,0,"%.4f",yscs.gch); PrintfXY (48,42,0,"%.4f",yscs.hpd); //PrintfXY (22,40,0," H= %.3f",bh); //PrintfXY (22,48,0," H-Z= %.3f",hz-bh); SaveDisp(SAVEDISP_PAGE1); WaitKey(); ++index; }break; case KEY_CTRL_EXIT: return 0; default: if ((ch=GetPressNumChar(key))!=0){ char buf[14]; int r; refresh = REFRESH_PART; buf[0] = ch; buf[1] = '\0'; r = InputString (48,0+index*12,buf,0,12); //ÊäÈë¿òλÖà if (r != KEY_CTRL_EXIT){ value[index] = atof(buf); if (r==KEY_CTRL_DOWN) ++index; if (r==KEY_CTRL_UP) --index; if (r==KEY_CTRL_EXE && index<3) ++index; } break; } } if (index >=4) index = 2; if (index < 0) index = 3; } }
///[주유소 리스트 정보 추출]/////: 1060 int main(void) { int len, wlen, rlen ; struct sockaddr_in serv_addr; OPW_HEADER hd ; OPW_RESULT rd ; char search_opt[D_SEARCH_OPT_SIZE+1] = {'\0'} ; int i ; OPW_LIST_REQ in ; OPW_LIST_INFO *out = NULL ; int search_num = 0 ; int start_pos = 0 ; int pole = 0 ; int sort_opt = 0 ; memset(&hd, 0, sizeof(OPW_HEADER)) ; memset(&rd, 0, sizeof(OPW_RESULT)) ; memset(&in, 0, sizeof(OPW_LIST_REQ)) ; printf("====[OPW_HEADER]====\n") ; hd.serviceid = htonl(OPW_LIST) ; InputInt("hd.mdn", &(hd.mdn), 1031993325) ; hd.mdn = htonl(hd.mdn) ; InputChar("hd.menu_id", &(hd.menu_id), 'O') ; printf("oiltype: G-휘발유 K-경유 L-LPG A-ALL\n") ; InputChar("hd.oil_type", &(hd.oil_type), 'A') ; printf("search_opt: AL-좌표로 검색 IL-주소로 검색\n") ; InputString("hd.search_opt", search_opt, D_SEARCH_OPT_SIZE+1, "AL") ; memcpy(hd.search_opt, search_opt, D_SEARCH_OPT_SIZE) ; printf("====[OPW_LIST_REQ]====\n") ; memset(&in, 0, sizeof(OPW_LIST_REQ)) ; InputInt("in.search_num", &(search_num), 10) ; InputInt("in.start_pos", &(start_pos), 0) ; printf("pole: 3072-LPG 16-SK 32-GS 64-H-OIL 128-S-OIL 512-기타 144-(SK or S-OIL) 0-ALL\n") ; InputInt("in.pole", &(pole), 0) ; printf("pole: 1-휘발유 가격순 2-경유 가격순 4-LPG 가격순 5-거리순 6-휘발유/경유/LPG 순서\n") ; InputInt("in.sort_opt", &(sort_opt), 6) ; if(!strcmp(search_opt, "AL")) { //좌표로 검색 InputInt("in.x", &(in.x), 320821) ; InputInt("in.y", &(in.y), 551729) ; InputInt("in.radius", &(in.radius), 5000) ; } else if(!strcmp(search_opt, "IL")) { //주소로 검색 InputString("cido", in.sido, D_SIDO_SIZE, "인천광역시") ; InputString("gugun", in.gugun, D_GUGUN_SIZE, "") ; InputString("dong", in.dong, D_DONG_SIZE, "") ; } else { //잘못된 선택 return 0 ; } // sprintf(in.sido, "인천광역시") ; // sprintf(in.gugun, "계양구") ; in.search_num = htonl(search_num) ; in.start_pos = htonl(start_pos) ; in.x = htonl(in.x) ; in.y = htonl(in.y) ; in.radius = htonl(in.radius) ; in.nr_num = htonl(in.nr_num) ; in.pole = pole ; in.sort_opt = sort_opt ; in.pole = htons(in.pole) ; in.sort_opt = htons(in.sort_opt) ; memset((char *) &serv_addr, 0, sizeof(serv_addr)) ; serv_addr.sin_family = AF_INET ; serv_addr.sin_addr.s_addr = inet_addr(SM_SERVER_IP) ; serv_addr.sin_port = htons(SM_SERVER_PORT) ; if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("clientsoc: can't open stream socket") ; close(sockfd), exit(0); } if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) { printf("clientsoc: can't connect to server") ; close(sockfd), exit(0); } if((wlen = write(sockfd, &hd, sizeof(OPW_HEADER))) <= 0) { printf("ERR: write OPW_HEADER[wlen:%d]\n", wlen) ; close(sockfd), exit(1) ; } printf("SEND: OPW_HEADER[wlen:%d]\n", wlen) ; if((wlen = write(sockfd, &in, sizeof(OPW_LIST_REQ))) < 0) { printf("ERR: write OPW_LIST_REQ\n") ; close(sockfd), exit(1) ; } printf("SEND: OPW_LIST_REQ[wlen:%d]\n", wlen) ; if ((rlen = read(sockfd, &rd, sizeof(OPW_RESULT))) <= 0) { printf("ERR: read OPW_RESULT[rlen:%d]...\n", rlen) ; close(sockfd), exit(1) ; } printf("READ: OPW_RESULT[rlen:%d]\n", rlen) ; rd.res_code = ntohl(rd.res_code) ; rd.total_num = ntohl(rd.total_num) ; rd.search_num = ntohl(rd.search_num) ; printf("OPW_RESULT: res_code[%d] total_num[%d] search_num[%d]\n", rd.res_code, rd.total_num, rd.search_num) ; if(rd.res_code == M_TRUE) { out = (OPW_LIST_INFO *) malloc (rd.search_num * sizeof(OPW_LIST_INFO)) ; memset(out, 0, rd.search_num * sizeof(OPW_LIST_INFO)) ; for(i = 0 ; i < rd.search_num; i++) { if((rlen = read(sockfd, &(out[i]), sizeof(OPW_LIST_INFO))) <= 0) { printf("ERR: [%d] read OPW_LIST_INFO(%d)\n", i, rlen) ; if(out != NULL) free(out), out = NULL ; close(sockfd), exit(1) ; } // printf("READ: OPW_LIST_INFO(%d) Len:[%d]\n", i, rlen) ; } for(i = 0 ; i < rd.search_num; i ++) { out[i].id = ntohl(out[i].id) ; out[i].pole = ntohl(out[i].pole) ; out[i].g_price = ntohs(out[i].g_price) ; out[i].k_price = ntohs(out[i].k_price) ; out[i].d_price = ntohs(out[i].d_price) ; out[i].l_price = ntohs(out[i].l_price) ; out[i].update_date = ntohl(out[i].update_date) ; out[i].update_time = ntohl(out[i].update_time) ; out[i].x = ntohl(out[i].x) ; out[i].y = ntohl(out[i].y) ; out[i].distance = ntohl(out[i].distance) ; printf("[%d]-ID[%d]NAME[%.52s] POLE[%d]G[%d]K[%d]D[%d]L[%d]DATE[%d]TIME[%d]X[%d]Y[%d]DISTANCE[%d]\n", i, out[i].id, out[i].name, out[i].pole, out[i].g_price, out[i].k_price, out[i].d_price, out[i].l_price, out[i].update_date, out[i].update_time, out[i].x, out[i].y, out[i].distance) ; } if(out != NULL) free(out) ; } exit_handler() ; }
int SelectfilePM() { index = 0; need_redraw = REDRAW_PART; SetMyFont(&stHz12x12,&stAsc6x12); while(1) { if (need_redraw == REDRAW_PART) { PopUpWin(6); DrawPicture(32,9, 16, 10, G_ICON_SAVE); DispStr(48,8,"保存为 "); DrawPicture(32,25, 16, 10, G_ICON_OPEN); DispStr(48,24,"打开 "); DrawPicture(32,41, 16, 10, G_ICON_OTHER); DispStr(48,40,"新建 "); Bdisp_AreaReverseVRAM(14,8+16*index,112,20+index*16); } GetKey(&key); if (key==KEY_CTRL_UP) {if(--index<0) index = 2;need_redraw = REDRAW_PART;} if (key==KEY_CTRL_DOWN) {if(++index>2) index = 0;need_redraw = REDRAW_PART;} if (key==KEY_CTRL_EXIT) break; if (key==KEY_CTRL_EXE) { char str[13]=""; int suc,enter,i; switch(index) { case 0: for (i=0;i<13 && setup_data.pmroute_name[i] != '.';++i) str[i] = setup_data.pmroute_name[i]; str[i>=13 ? 12 : i] = 0; PopUpWin(4); DispStr(24,8,"\xce\xc4\xbc\xfe\xc3\xfb(*.pm)");//file_name do { suc = InputString(24,24,str,1,8); if (suc==KEY_CTRL_EXIT) break; if (! str[0]) continue; }while(suc!=KEY_CTRL_EXE); if(suc!=KEY_CTRL_EXIT) { enter = 1; strcat(str,".pm"); if (TestJDFFile(str)) { PopUpWin(5); DispStr(48,12,"覆盖?"); //fugai locate(7,5);Print("Yes : [F1]"); locate(7,6);Print("No : [F6]"); do{ GetKey(&key); if (key==KEY_CTRL_F6 || key==KEY_CTRL_EXIT){enter =0 ;break;} else if (KEY_CTRL_F1) {enter = 1;break;} }while(1); } if (enter) { SavePMFile(str); strcpy(setup_data.pmroute_name,str); } } break; case 1: suc = SelectPMFile (str); if (suc==-1) { PopUpWin(1); locate(7,4);Print("No File!"); GetKey(&key); } if(suc==1) { LoadPMFile (str); strcpy(setup_data.pmroute_name,str); if(LoadPMFile (setup_data.pmroute_name)==1) SaveIniPMFile(); goto EXIT; } case 2: PopUpWin(5); DispStr(48,12,"新建?"); locate(7,5);Print("Yes : [F1]"); locate(7,6);Print("No : [F6]"); GetKey(&key); if (key==KEY_CTRL_F1){ PopUpWin(5); DispStr(40,12,"保存数据?"); locate(7,5);Print("Yes : [F1]"); locate(7,6);Print("No : [F6]"); GetKey(&key); if(key==KEY_CTRL_F1) { if(setup_data.pmroute_name[0]==0) { WheterSavaASPM(); } else { SavePMFile(setup_data.pmroute_name); } } setup_data.pmroute_name[0]=0; pmroute_initial(&pmroute); pmroute_push_back(&pmroute); goto EXIT; } break; default:break; } need_redraw = REDRAW_PART; } } EXIT: return 0; }
int PM_parameter() { char * table_label[]= {"DH","QDZH","ZDZH","X","Y","FWJ","ZX","QDBJ","ZDBJ"}; char * icons[] = {"","","","",""}; char * ch_text[] = {"\xb5\xe3\xc3\xfb", "起点桩号", "终点桩号", "X坐标 ", "Y坐标 ", "方位角 ", "转向 ", "起点半径", "终点半径"}; int x = 0,y = 0,i,j,t; int left = 0,top = 0; int refresh = REDRAW_ALL; int enter,suc; char str[13]=""; char c; PMproduce(); //打开交点参数转换平面参数 InsertLine(l_pqx.length,&y,&refresh); GetListq(); //取链表链表线元参数 while(1){ if (refresh==REDRAW_ALL){ Bdisp_AllClr_VRAM(); for (i=0;i<4;++i) PrintTablesPM(i,0,table_label[left+i],1,1); t = pmroute.size<= 1 ? 2 : 5; //如果交点个数小于等于1 那么T=2 否则等于5 if (t>=2){ SetMyFont(&stHz8x8,&stAsc6x12); DispStr(2,56,"\xCE\xC4\xBC\xFE"); DispStr(23,56,"添加"); } if (t>2){ SetMyFont(&stHz8x8,&stAsc6x12); DispStr(45,56,"插入 "); DispStr(65,56,"删行 "); DispStr(86,56,"清空 "); } for (i=0;i< t;++i) // i<2 或 i<5 PrintIcon(i,icons[i],0); //打印下标 PrintIcon(5,"?",0); //固定打印下标 refresh = REDRAW_PART; // 重画部分 } if (refresh==REDRAW_PART){ //如果画部分 double * sd; for (i=top;i<top+4 && i<pmroute.size;++i){ sd = & (pmroute.set[i].pm_qk); for (j=(left==0 ? 1:0);j<4;++j){ //if (i==0 && j+left>3) ////////////////////////////////////////// //PrintTablesPM(j,i+1-top,"",y==i && x-left==j,0);/////////////// //else///////// PrintTableFormatPM(j,i+1-top,y==i && x-left==j,0,"%lf",sd[j+left-1]); } if (left==0) PrintTableFormatPM(0,i+1-top,y==i && x-left==0,0,"%s",pmroute.set[i].name); PrintTableIndexPM(i-top+1,i); } SetMyFont(&stHz12x12,&stAsc6x12); if(x>0){ //if (!(y==0 && x>2)){ sd = & (pmroute.set[y].pm_qk); //取地址的值*************** DispStr(0,42,ch_text[x]); PrintFloat(sd[x-1],49,42,0,setup_data.point); //打印 //} }else{ DispStr(0,42,ch_text[x]); PrintXY(51,44,pmroute.set[y].name,0); } refresh = 0; } GetKey(&key); switch (key){ case KEY_CTRL_UP: y--;refresh = REDRAW_ALL;break; case KEY_CTRL_DOWN: y++;refresh = REDRAW_ALL;break; case KEY_CTRL_LEFT: x--;refresh = REDRAW_ALL;break; case KEY_CTRL_RIGHT: x++;refresh = REDRAW_ALL;break; case KEY_CTRL_EXIT: pmroute_initial(&pmroute); InitList(&l_pqx); return 0 ; case KEY_CTRL_F1: /* Set */ refresh = REDRAW_ALL; SelectfilePM(); break; case KEY_CTRL_F2: /* Add */ pmroute_push_back (&pmroute); y = pmroute.size - 1; refresh = REDRAW_ALL; break; case KEY_CTRL_F3: /* ins */ //if (y==0) break; pmroute_insert (&pmroute,y); y++; refresh = REDRAW_ALL; break; case KEY_CTRL_F4: /* Del a point */ //if (y==0) break; refresh = REDRAW_ALL; PopUpWin(4);DispStr(25,10,"删 除 一 行?"); locate(3,5);Print("[F1]Yes [F6]No"); GetKey(&key); if (key==KEY_CTRL_F1){ pmroute_del(&pmroute,y);y--; } break; case KEY_CTRL_F5: /* Del All */ refresh = REDRAW_ALL; PopUpWin(4);DispStr(25,10,"清 空 所 有 ?"); locate(3,5);Print("[F1]Yes [F6]No"); GetKey(&key); if (key==KEY_CTRL_F1){ pmroute_initial(&pmroute); pmroute_push_back(&pmroute); } break; case KEY_CTRL_F6: refresh = REDRAW_ALL; //PrintfXY (70,30,0,"%.3f",route.set[0].xy_zr); //DispStr(15,10,"线路名称"); //if(setup_data.pmroute_name[0]==0) //{ //DispStr(25,27,"请保存线路文件 "); //} //else //{ //DispStr(25,27,setup_data.zdmroute_name); //} break; default: /*other things*/ if (x>0 && (c=GetPressNumChar(key))!=0){ char buffer[14]; int r; //if (y==0 && x > 3)break; buffer[0] = c; buffer[1] = '\0'; r = InputString(49,42,buffer,0,12); if (r!=KEY_CTRL_EXIT){ double * sd; sd = (double*)&(pmroute.set[y].pm_qk); sd[x-1] = atof(buffer); switch(r){ case KEY_CTRL_UP: y--;break; case KEY_CTRL_DOWN: y++;break; case KEY_CTRL_EXE: x++;break; } } refresh = REDRAW_ALL; } else if (x==0 && (c=GetPressChar(key))!=0){ char buffer[14]; int r; buffer[0] = c; buffer[1] = '\0'; r = InputString(49,42,buffer,1,12); if (r!=KEY_CTRL_EXIT){ strncpy(pmroute.set[y].name,buffer,12); switch(r){ case KEY_CTRL_UP: y--;break; case KEY_CTRL_DOWN: y++;break; case KEY_CTRL_EXE: x++;break; } } refresh = REDRAW_ALL; } break; } if (x<0) x = 8,y--; if (x>8) x = 0,y++; if (y<0) y = 0; if (y>=pmroute.size) y = pmroute.size - 1; if (y>top + 3) top = y - 3; if (y<top) top = y; if (x>left +3) left = x - 3; if (x<left) left = x; } }
///[TEXT Á¤º¸ ¾ò±â]///// int main(void) { SRH_IN srh_in ; SRH_OUT srh_out ; INFO_OUT info_out ; TOTAL_INFO total_info; TXT_INFO txt_info; int i, len, wlen, rlen ; struct sockaddr_in serv_addr; int ret, ret_size = 0 ; char *info = NULL ; char *data = NULL ; char *content = NULL; int gpres_ver = 0; time_t t ; char contents[512+1] = {'\0'}; char data_fname[256] = {'\0'}; FILE *fp; memset(&srh_in, 0, sizeof(SRH_IN)) ; memset(&srh_out, 0, sizeof(SRH_OUT)) ; memset(&info_out, 0, sizeof(INFO_OUT)) ; memset(&total_info, 0x00, sizeof(total_info)); memset(&txt_info, 0x00, sizeof(txt_info)); printf("====[SRH_IN]====\n") ; InputInt("srh_in.engVersion", &(srh_in.engVersion), 20060101) ; srh_in.engVersion = htonl(srh_in.engVersion) ; srh_in.mapVersion = htonl(1) ; srh_in.serviceId = htonl(1050) ; InputInt("srh_in.resourceVersion", &(srh_in.resourceVersion), 9032100) ; srh_in.resourceVersion = htonl(srh_in.resourceVersion) ; InputInt("srh_in.mdn", &(srh_in.mdn), 1199981076) ; srh_in.mdn = htonl(srh_in.mdn); InputInt("GPRES.version", &(gpres_ver), 1) ; gpres_ver = htonl(gpres_ver); printf("----FILE NAME---\n"); InputString("oildatafile_name", data_fname, 256, "GP.DAT"); memset((char *) &serv_addr, 0, sizeof(serv_addr)) ; serv_addr.sin_family = AF_INET ; serv_addr.sin_addr.s_addr = inet_addr(SM_SERVER_IP) ; serv_addr.sin_port = htons(SM_SERVER_PORT) ; if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("clientsoc: can't open stream socket") ; close(sockfd), exit(0); } if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) { printf("clientsoc: can't connect to server") ; close(sockfd), exit(0); } if((wlen = write(sockfd, &srh_in, sizeof(SRH_IN))) <= 0) { printf("ERR: write SRH_IN[wlen:%d]\n", wlen) ; close(sockfd), exit(1) ; } printf("SEND: SRH_IN[wlen:%d]\n", wlen) ; if((wlen = write(sockfd, &gpres_ver, sizeof(int))) <= 0) { printf("ERR: write SRH_IN[wlen:%d]\n", wlen) ; close(sockfd), exit(1) ; } printf("SEND: GPRES_VERSION(%d)[wlen:%d]\n", ntohl(gpres_ver), wlen) ; if ((rlen = read(sockfd, &srh_out, sizeof(SRH_OUT))) <= 0) { printf("ERR: read SRH_OUT[rlen:%d]...\n", rlen) ; close(sockfd), exit(1) ; } printf("READ: SRH_OUT[rlen:%d]\n", rlen) ; srh_out.engVersion = ntohl(srh_out.engVersion) ; srh_out.mapVersion = ntohl(srh_out.mapVersion) ; srh_out.serviceId = ntohl(srh_out.serviceId) ; srh_out.resourceVersion = ntohl(srh_out.resourceVersion) ; srh_out.totalCount = ntohl(srh_out.totalCount) ; srh_out.count = ntohl(srh_out.count) ; srh_out.errorCode = ntohl(srh_out.errorCode) ; srh_out.compFlag = ntohl(srh_out.compFlag) ; srh_out.uncompSize = ntohl(srh_out.uncompSize) ; srh_out.compSize = ntohl(srh_out.compSize) ; printf("SRH_OUT-engVer[%d] mapVer[%d] SerId[%d] ResVer[%d] Total[%d] Cnt[%d] Err[%d] CompFlag[%d] UNCOM[%d] COM[%d]\n", srh_out.engVersion, srh_out.mapVersion, srh_out.serviceId, srh_out.resourceVersion, srh_out.totalCount, srh_out.count, srh_out.errorCode, srh_out.compFlag, srh_out.uncompSize, srh_out.compSize) ; if(srh_out.errorCode == 0) { if(srh_out.compFlag == 0) ret_size = srh_out.uncompSize ; else ret_size = srh_out.compSize ; if((info = (char *) malloc (srh_out.uncompSize)) == NULL) { printf("ERR: Memory Alloc Fail\n") ; close(sockfd), exit(1) ; } memset(info, 0, srh_out.uncompSize) ; if ((rlen = readn(sockfd, info, ret_size)) <= 0) { printf("ERR: read info[rlen:%d/%d]...\n", rlen, ret_size) ; close(sockfd), exit(1) ; } printf("READ: DATA[rlen:%d]\n", rlen) ; if(srh_out.compFlag == 1) { if((data = (char *) malloc (srh_out.uncompSize)) == NULL) { printf("ERR: Memory Alloc Fail\n") ; close(sockfd), exit(1) ; } memset(data, 0, srh_out.uncompSize) ; memcpy(data, info, srh_out.uncompSize) ; memset(info, 0, srh_out.uncompSize) ; ret = uncompress(info, &(srh_out.uncompSize), data, srh_out.compSize) ; printf("uncompress():ret[%d] uncompSize[%d] compSize[%d]\n", ret, srh_out.uncompSize, srh_out.compSize) ; } fp = fopen(data_fname, "wb"); fwrite(info, srh_out.uncompSize, 1, fp); fclose(fp); printf("---[%s] write complete!\n", data_fname); if (info != NULL) free(info); info = NULL; if (data != NULL) free(data); data = NULL; } exit_handler() ; }