home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / pty4 / part02 / ptyerr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-18  |  955 b   |  59 lines

  1. #include "getoptquiet.h"
  2. #include "fmt.h"
  3. #include "ptyerr.h"
  4. #include "ralloc.h"
  5.  
  6. void die(n)
  7. int n;
  8. {
  9.  _exit(n);
  10. }
  11.  
  12. static int flagwarning = 1;
  13.  
  14. void warn_disable()
  15. {
  16.  flagwarning = 0;
  17. }
  18.  
  19. void warn(level,problem)
  20. char *level;
  21. char *problem;
  22. {
  23.  char *buf;
  24.  
  25.  if (!flagwarning)
  26.    return;
  27.  if (!optprogname)
  28.    optprogname = "pty";
  29.  buf = ralloc(strlen(optprogname) + strlen(level) + strlen(problem) + 10);
  30.  if (!buf)
  31.   {
  32.    write(2,optprogname,strlen(optprogname));
  33.    write(2,": ",2);
  34.    write(2,level,strlen(level));
  35.    write(2,": ",2);
  36.    write(2,problem,strlen(problem));
  37.    write(2,"\r\n",2);
  38.   }
  39.  else
  40.   {
  41.    char *t; t = buf;
  42.    t += fmt_strncpy(t,optprogname,0);
  43.    t += fmt_strncpy(t,": ",0);
  44.    t += fmt_strncpy(t,level,0);
  45.    t += fmt_strncpy(t,": ",0);
  46.    t += fmt_strncpy(t,problem,0);
  47.    t += fmt_strncpy(t,"\r\n",0);
  48.    *t = 0;
  49.    write(2,buf,strlen(buf));
  50.    rfree(buf);
  51.   }
  52. }
  53.  
  54. void info(text)
  55. char *text;
  56. {
  57.  write(2,text,strlen(text));
  58. }
  59.