📄 publib.ec
字号:
fprintf(stderr,"起信息量完毕!!!\n"); shmdt((char *)ip); return(0);}rcv_queue(qnum, qmsgtyp, buffer)int qnum;long * qmsgtyp;unsigned char *buffer;{int msglen, i;struct commsg_fmt tmpbuf; unsigned char *current; msglen = msgrcv(qnum, &tmpbuf, BUFFSIZE, *qmsgtyp, 0); *qmsgtyp=tmpbuf.msg_typ; if(msglen != -1) { current = buffer; for(i = 0; i < msglen; i++, current++) *current = tmpbuf.msg[i]; } return(msglen);}snd_queue(qnum, msg_type, buffer, msg_size)int qnum;long msg_type;unsigned char *buffer;int msg_size;{int sent, i;struct commsg_fmt tmpbuf; tmpbuf.msg_typ = msg_type; for(i = 0; i < msg_size; i++) tmpbuf.msg[i] = buffer[i]; tmpbuf.msg[i] = 0; sent = msgsnd(qnum, &tmpbuf, msg_size, IPC_NOWAIT); return(sent);}int get_queue(int QueName){int QueHandle;QueHandle = msgget(QueName,IPC_CREAT|QPERM);/*if (QueHandle < 0) err_return(errno, program_ID, "MSGGET error");*/ return(QueHandle);}int s_uncompress(s,d,length)char *s;char *d;int length;{int i;for(i=0;i<length;i++){d[2*i]=((s[i]>>4)&0x0f)+48;d[2*i+1]=(s[i]&0x0f)+48;}; return 0;} int s_compress(sour,d,length)char *sour;char *d;int length;{int i;char s[100];strcpy(s,sour);if(length%2==1){ d[0]=s[0];for(i=1;i<(length/2+1);i++){ s[2*i-1]=s[2*i-1]<<4; d[i]=s[2*i-1]|(s[2*i]&0x0f);}}elsefor(i=0;i<length/2;i++){s[2*i]=s[2*i]<<4;d[i]=s[2*i]|(s[2*i+1]&0x0f);}}/* 显示通讯包内容 */unsigned int err_jnl(char *errid,char *buff,int len) { FILE *fp; char tmpbuf[BUFFSIZE]; unsigned char *abuf,*hbuf; int i,g,k,flag; long second; struct tm his; if ((fp=fopen("../report/hcdl_err","a"))==0x00) { return(TRUE); }/* EtoA(tmpbuf,buff,len); */ fprintf(fp,"===========================================================\n"); fprintf(fp,"\n%s\n",errid); time(&second); his = *(localtime(&second)); fprintf(fp,"DATE--%02d/%02d TIME--%02d:%02d:%02d\n",his.tm_mon+1,his.tm_mday,his.tm_hour,his.tm_min,his.tm_sec); fprintf(fp,"Buffer length=%d\n",len); hbuf=buff; abuf=buff; for(i=0, g=len/16; i < g; i++) { fprintf(fp, "M(%6.6d)=< ",i*16); for(k=0; k<16; k++) fprintf(fp, "%02x ",*hbuf++); fprintf(fp,"> "); for(k=0; k<16; k++, abuf++) fprintf(fp, "%c",(*abuf>32) ? ((*abuf<128) ? *abuf : '*') : '.'); fprintf(fp,"\n"); } if((i=len%16) > 0) { fprintf(fp,"M(%6.6d)=< ",len-len%16); for(k=0; k < i; k++) fprintf(fp, "%02x ",*hbuf++); for(k=i; k < 16; k++) fprintf(fp, " "); fprintf(fp, "> "); for(k=0; k < i; k++, abuf++) fprintf(fp, "%c",(*abuf>32) ? ((*abuf<128) ? *abuf : '*') : '.'); fprintf(fp, "\n"); } fprintf(fp,"===========================================================\n"); fflush(fp); fclose(fp); return(TRUE);} int AtoE( unsigned char *d,unsigned char *s,int len){ int i; for(i=0;i<len;i++) { d[i]=atoe[s[i]]; } d[len]='\0';}int EtoA(unsigned char *d, unsigned char *s,int len){ int i; for(i=0;i<len;i++) { d[i]=etoa[s[i]]; } d[len]='\0';}short sna_toascii(pointer,length) char *pointer; unsigned short length; { int n,m,flag; unsigned short l,i; unsigned char *pp1,*pp2,a,b; pp1=pp2=pointer; n=length; m=0; flag=0; while (n>0){ a=*pp1++; switch (a) { case 0x0e : flag=1; n--; break; case 0x0f : flag=0; n--; break; case 0x28 : n-=3; pp1+=2; *pp2++ =0x20; m++; break; default : if (flag==1) { /* chinese character */ b=*pp1++; if ((b==0x40)&&(a==0x40)) { *pp2++=0x20; *pp2++=0x20; m+=2; n-=2; break; } if (a==0x41) { if (b>0xf0) { *pp2++=0xa2; *pp2++=b; } else { *pp2++=0x20; *pp2++=0x20; } m+=2; n-=2; break; } if(a==0x42) { if (b==0x4d){ *pp2++=0xa3; *pp2++=0xa8; m+=2; n-=2; break; } if (b==0x5d){ *pp2++=0xa3; *pp2++=0xa9; m+=2; n-=2; break; } if (b==0x60){ *pp2++=0xa3; *pp2++=0xaa; m+=2; n-=2; break; } if (b==0x7a){ *pp2++=0xa3; *pp2++=0xba; m+=2; n-=2; break; } if (b==0xe0){ *pp2++=0x20; *pp2++=0x24; m+=2; n-=2; break; } if (b==0x5b){ *pp2++=0xa3; *pp2++=0xa4; m+=2; n-=2; break; } if((b >=0xf0) && (b <=0xf9)){ *pp2++=0xa3; *pp2++=b-0x40; m+=2; n-=2; break; } } if (a==0x7f) { switch (b) { case 0x4a: *pp2++=0xa1; *pp2++=0xea; break; case 0x79: *pp2++=0xa3; *pp2++=*(aa+b); break; case 0xe0: *pp2++=0xa1; *pp2++=0xe7; break; default : *pp2++=0xa3; *pp2++=*(aa+b)+0x80; } m+=2; n-=2; break; } if ((a==0x43)||(a==0x44)) { l=a; l=(l<<8)|b; for (i=0;i<96;i++) { if (l==chrtab[i]) break; } if (i<95) { *pp2++=0xa1; *pp2++=i+0xa1; } else { *pp2++=0x20; *pp2++=0x20; } m+=2; n-=2; break; } if (a==0x45) { if ((b>0x5a)&&(b<0x7b)) { *pp2++=0xa1; *pp2++=b+0x61; } else if (b<0xb0) { *pp2++=0xa1; *pp2++=b+0x60; } if ((b>0xb0)&&(b<0xd9)) { *pp2++=0xa2; *pp2++=b; } if ((b>0xe0)&&(b<0xeb)) { *pp2++=0xa2; *pp2++=b-0x08; } if ((b>0xf0)&&(b<0xfb)) { *pp2++=0xa2; *pp2++=b-0x0c; } m+=2; n-=2; break; } if (a==0x46) { if (b>0xa3) { *pp2++=0xa9; *pp2++=b; } else { *pp2++=0x20; *pp2++=0x20; } m+=2; n-=2; break; } if (a>0x47) { if (b>0x9f) { *pp2++=(a-0x31)*2+0x82; *pp2++=b+1; } if ((b>0x7f)&&(b<=0x9f)) { *pp2++=(a-0x31)*2+0x81; *pp2++=b+0x5f; } if ((b>=0x41)&&(b<=0x7f)) { *pp2++=(a-0x31)*2+0x81; *pp2++=b+0x60; } m+=2; n-=2; } } else { /* English character */ *pp2++=*(aa+a); n--; m++; } } } return(m); }int sna2a(sp,strp)char *sp,*strp;{ short i,j; strcpy(sp,strp); i=strlen(sp); i=sna_toascii(sp,i); sp[i]='\0'; return(0);}int quk_rcv_queue(qnum, buffer, msgtyp)int qnum;unsigned char *buffer;long *msgtyp;{int msglen, i;struct commsg_fmt tmpstru;unsigned char *current; msglen = msgrcv(qnum, &tmpstru, BUFFSIZE, *msgtyp, IPC_NOWAIT); *msgtyp=tmpstru.msg_typ; if(msglen != -1) { current = buffer; for(i = 0; i < msglen; i++, current++) *current = tmpstru.msg[i]; } return(msglen);} void clear_queue(int QueHandle){int NoRcvQue;long QueMsgType;unsigned char buffer[BUFFSIZE];NoRcvQue = 0;while(NoRcvQue >= 0) /* clear Queue */ { QueMsgType = 0L; NoRcvQue = quk_rcv_queue(QueHandle,buffer,&QueMsgType); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -