void main(void) { struct ctrl_conheader header; char buffer[FUDGE_BSIZE]; struct ipv4_arpentry entry; struct ipv4_socket socket; if (!file_walk(FILE_L0, "/system/ethernet/ipv4/arptable")) return; file_open(FILE_L0); file_readall(FILE_L0, &entry, sizeof (struct ipv4_arpentry)); file_close(FILE_L0); socket.address[0] = entry.paddress[0]; socket.address[1] = entry.paddress[1]; socket.address[2] = entry.paddress[2]; socket.address[3] = entry.paddress[3]; socket.port[0] = 0x1F; socket.port[1] = 0x90; if (!file_walk(FILE_L0, "/system/con/con:0")) return; if (!file_walkfrom(FILE_L1, FILE_L0, "ctrl")) return; file_open(FILE_L1); file_writeall(FILE_L1, &socket, sizeof (struct ipv4_socket)); file_close(FILE_L1); if (!file_walkfrom(FILE_L1, FILE_L0, "data")) return; file_open(FILE_PO); file_open(FILE_L1); while (file_readall(FILE_L1, &header, sizeof (struct ctrl_conheader))) { file_readall(FILE_L1, buffer, header.count); file_writeall(FILE_PO, buffer, header.count); send(&socket, &header.sender, "ack\n", 4); } file_close(FILE_L1); file_close(FILE_PO); }
void main(void) { struct ipv4_arpentry entry; if (!file_walk2(FILE_L0, "/system/ethernet/if:0/addr")) return; file_open(FILE_L0); file_readall(FILE_L0, &entry.haddress, 6); file_close(FILE_L0); entry.paddress[0] = 10; entry.paddress[1] = 0; entry.paddress[2] = 5; entry.paddress[3] = entry.haddress[4]; if (!file_walk2(FILE_L0, "/system/ethernet/ipv4/arptable")) return; file_open(FILE_L0); file_writeall(FILE_L0, &entry, sizeof (struct ipv4_arpentry)); file_close(FILE_L0); }
LIST_T* way_init(TRN_T*data,char*name) { LIST_T*head; WAY_T*fstt,*lstt; head=list_init(); fstt=(WAY_T*)malloc(IWAY); memset(fstt,0,IWAY); lstt=(WAY_T*)malloc(IWAY); memset(lstt,0,IWAY); strcpy(fstt->id,data->id); strcpy(fstt->etime,data->btime); strcpy(fstt->btime,data->btime); strcpy(fstt->stt,data->fstt); fstt->usetime=0; fstt->distance=0; fstt->price=0; fstt->tickctnum=data->ticketnum; strcpy(lstt->id,data->id); strcpy(lstt->btime,data->etime); strcpy(lstt->etime,data->etime); strcpy(lstt->stt,data->lstt); lstt->usetime=0; lstt->distance=data->distance; lstt->price=1.2*lstt->distance; lstt->tickctnum=data->ticketnum; list_add(head,fstt); list_add(head,lstt); file_writeall(head,IWAY,name); return head; }
static void send(struct ipv4_socket *sender, struct ipv4_socket *target, void *buffer, unsigned int count) { struct {struct ctrl_conheader header; char buffer[FUDGE_BSIZE];} packet; memory_copy(&packet.header.sender, sender, sizeof (struct ipv4_socket)); memory_copy(&packet.header.target, target, sizeof (struct ipv4_socket)); packet.header.count = memory_write(packet.buffer, FUDGE_BSIZE, buffer, count, 0); file_writeall(FILE_L1, &packet, sizeof (struct ctrl_conheader) + packet.header.count); }
void main(void) { unsigned char out[FUDGE_BSIZE]; unsigned char in[FUDGE_BSIZE]; unsigned int count; file_open(FILE_PO); file_open(FILE_PI); while ((count = file_read(FILE_PI, in, FUDGE_BSIZE))) file_writeall(FILE_PO, out, convert(out, FUDGE_BSIZE, in, count)); file_close(FILE_PI); file_close(FILE_PO); }
void way_add_arb(LIST_T*head) { int get,count; FILE*stt_fp,*way_fp; LIST_T*stt_head; STT_T*stt_data; char str=' '; WAY_T*data,*fdata,*ldata; char filename[15]=" "; int sum=list_count(head); stt_head=list_init(); stt_fp=file_open("station.txt"); file_readall(stt_fp,stt_head,ISTT); data=(WAY_T*)malloc(IWAY); memset(data,0,IWAY); fdata=(WAY_T*)malloc(IWAY); memset(fdata,0,IWAY); ldata=(WAY_T*)malloc(IWAY); memset(ldata,0,IWAY); while(1) { count=way_printpage(head); if (count==27) { return; } if (count==sum) { gotoXY(18,16); printf("不能在终点站后插入站点"); Sleep(1000); continue; } fdata=list_search_count(count,head); ldata=list_search_count(count+1,head); break; } data->tickctnum=((WAY_T*)(head->pnext->data))->tickctnum; print_way_add(); strcpy(data->id,((WAY_T*)(head->pnext->data))->id); while(1) { gotoXY(26,3); get=glb_putString(data->stt,4,10,1); if(get==27) { return ; } if(list_search_name(data->stt,head,way_sttmatch)!=NULL) { gotoXY(20,20); printf("该车次已有该站点"); Sleep(1000); gotoXY(20,20); printf(" "); gotoXY(26,3); printf(" "); continue; } else if(list_search_name(data->stt,stt_head,stt_namematch)==NULL) { gotoXY(20,20); printf("没有该站点"); Sleep(1000); gotoXY(20,20); printf(" "); gotoXY(26,3); printf(" "); continue; } else if (list_search_name(data->stt,head,way_sttmatch)!=NULL) { gotoXY(20,20); printf("该站点已经在该车次中出现"); Sleep(1000); gotoXY(20,20); printf(" "); gotoXY(26,3); printf(" "); continue; } else { break; } } while (1) { gotoXY(26,5); get=glb_putTime(data->btime); if(get==27) { return ; } gotoXY(26,7); get=glb_putTime(data->etime); if(get==27) { return ; } if(!(trn_usetime(data->btime,fdata->etime)<0&&trn_usetime(ldata->btime,data->etime)<0)) { gotoXY(17,17); printf("该时间不合法"); Sleep(1000); gotoXY(17,17); printf(" "); gotoXY(26,5); printf(" "); gotoXY(26,7); printf(" "); continue; } break ; } data->usetime=trn_usetime(data->btime,data->etime); gotoXY(26,9); printf("%d:%d",data->usetime/60,data->usetime%60); while (1) { gotoXY(26,11); get=data->distance=glb_putNumber(4); if(get==0) { return ; } if(!(data->distance>fdata->distance&&data->distance<ldata->distance)) { gotoXY(17,17); printf("该里程不合法"); Sleep(1000); gotoXY(17,17); printf(" "); gotoXY(26,11); printf(" "); continue; } break; } gotoXY(26,13); data->price=data->distance*1.2; printf("%.2f",data->price); list_add_count(head,count,data); gotoXY(20,18); printf("成功增加途径站点"); sprintf(filename,"%s.txt",((WAY_T*)(head->pnext->data))->id); file_writeall(head,IWAY,filename); way_fp=file_open(filename); fclose(way_fp); stt_data=list_search_name(data->stt,stt_head,stt_search); stt_data->isdelete++; file_writeall(stt_head,ISTT,"station.txt"); fclose(stt_fp); Sleep(1000); return ; }