msg.c
上传用户:sdtbys
上传日期:2009-12-06
资源大小:13k
文件大小:1k
- #include <stdio.h>
- #include <stdlib.h>
- #include <varargs.h>
- extern char MsgLog[50];
- int ShowMsg(va_alist)
- {
- FILE *fp;
- char *fmt;
- va_list args;
- fp=fopen(MsgLog,"a+");
- if (fp==NULL) {printf("Open MsgLog Failed!n");return;}
-
- va_start(args);
- fmt=va_arg(args,char *);
- fprintf(fp,"[%s %d]n",GetFmtTime(),getpid());
- (void)vfprintf(fp,fmt,args);
- va_end(args);
- fclose(fp);
- }
- int LookChar(char *buf,int len)
- {
- FILE *fp;
- int i;
- fp=fopen("/tmp/buf.log","a+");
- fprintf(fp,"[%s %d]n",GetFmtTime(),getpid());
- for(i=0;i<len;i++) fputc(buf[i],fp);
- fputc('n',fp);
- fclose(fp);
- }
- int LooKChar(char *buf,int len)
- {
- FILE *fp;
- int i;
- fp=fopen(MsgLog,"a+");
- fprintf(fp,"[%s %d]n",GetFmtTime(),getpid());
- for(i=0;i<len;i++) fputc(buf[i],fp);
- fputc('n',fp);
- fclose(fp);
- }
- int ShowId(char *program)
- {
- ShowMsg("pid=%d program=%s ppid=%dn",getpid(),program,getppid());
- }
- #define ShowID() ShowId(argv[0])