#include #include //#include //#include #define chan1 "1" #define chan2 "2" int main(int argc, char **argv) { char buf,b1; FILE *f; char b[648]=""; char nick[20]=""; int i=0; int step=0; int fdr,fdw; // открыть именнованные каналы if ((fdw=open(chan1,atoi(argv[1])))<0) printf("parent: can't open write fifo: %s",chan1); if ((fdr=open(chan2,atoi(argv[0])))<0) printf("parant: can't open read fifo: %s", chan2); printf("%s\n","==DONE=="); // загрузка заставки и вывод ее на экран f=fopen("logon","r"); while (!feof(f)) { fscanf(f,"%c",&buf); write(0,&buf,1); } fclose(f); write(0,"Введите имя героя: ",19); buf=0x00; b[0]=0x00; i=0; // ввод ника while ((read(0,&buf,1)!=-1)&&(buf!=0x0A)) { if (buf!=0x0A) strcat(b,&buf); } while (i!=strlen(b)-8) { if (i%8==0) { sprintf(&b1,"%c",b[i]); strcat(nick,&b1); } ++i; } printf("%s%s\n","Nick Accepted ... ",nick); // основное тело клиента while (1) { write(0,nick,strlen(nick)); write(0," > ",4); b[0]=0x00; buf=0x00; i=0; while ((read(0,&buf,1)!=-1)&&(buf!=0x0A)) if (buf!=0x0A) strcat(b,&buf); f=fopen("log/input.log","a"); fprintf(f,"%s%s",nick," > "); printf("%s%s",nick," > "); while (i!=strlen(b)) { if (i%8==0) { fprintf(f,"%c",b[i]); printf("%c",b[i]); } ++i; } printf("%c\n"); fprintf(f,"%c\n"); fclose(f); } return 0; }