util.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. #include "bem.h"
  6. #ifndef NORSCID
  7. static char rcs_id[] = "$Id$" ;
  8. #endif
  9. #define abs(X) (X>=0?X:-X)
  10. /* Miscelaneous routines can be found here */
  11. int errorcnt;
  12. warning(str)
  13. char *str;
  14. {
  15. if (wflag) return;
  16. Xerror("WARNING", str);
  17. }
  18. error(str)
  19. char *str;
  20. {
  21. Xerror("ERROR", str);
  22. errorcnt++;
  23. }
  24. Xerror(type, str)
  25. char *str;
  26. char *type;
  27. {
  28. extern int listing;
  29. extern int basicline;
  30. if( !listing) fprint(STDERR, "LINE %d:",basicline);
  31. fprint(STDERR, "%s:%s\n",type, str);
  32. }
  33. fatal(str)
  34. char *str;
  35. {
  36. Xerror("FATAL",str);
  37. C_close();
  38. sys_stop(S_EXIT);
  39. }
  40. notyetimpl()
  41. {
  42. warning("not yet implemented");
  43. }
  44. illegalcmd()
  45. {
  46. warning("illegal command");
  47. }
  48. char *itoa(i)
  49. int i;
  50. {
  51. static char buf[30];
  52. sprint(buf,"%d",i);
  53. return(buf);
  54. }
  55. char *salloc(length)
  56. unsigned length;
  57. {
  58. char *s,*c;
  59. s=c=malloc(length);
  60. if ( !s ) fatal("Out of memory") ;
  61. while(length--)*c++ =0;
  62. return(s);
  63. }