home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3297 / printrlimits.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-07  |  1.5 KB  |  63 lines

  1. /* History:
  2. 5/1/91 DJB baseline public domain
  3. */
  4.  
  5. /*
  6.  
  7. char *printrlimits(rl) struct rlimit *rl; returns a string representing
  8. various information about rlimit array rl. Not well defined.
  9.  
  10. */
  11.  
  12. #include <stdio.h>
  13. #include <strings.h>
  14. #include <sys/types.h>
  15. #include <sys/time.h>
  16. #include <sys/resource.h>
  17. #include "printrlimits.h"
  18.  
  19. static char result[500];
  20.  
  21. /* XXX: print anything other than max? */
  22.  
  23. char *printrlimits(rl)
  24. struct rlimit *rl;
  25. {
  26.  char *t;
  27.  
  28.  t = result;
  29.  
  30. #ifdef RLIMIT_CPU
  31.  if (rl[RLIMIT_CPU].rlim_max == RLIM_INFINITY) sprintf(t,"cpu inf ");
  32.  else sprintf(t,"cpu %8d ",rl[RLIMIT_CPU].rlim_max);
  33.  t += strlen(t);
  34. #endif
  35. #ifdef RLIMIT_FSIZE
  36.  if (rl[RLIMIT_FSIZE].rlim_max == RLIM_INFINITY) sprintf(t,"file inf ");
  37.  else sprintf(t,"fsize %8d ",rl[RLIMIT_FSIZE].rlim_max);
  38.  t += strlen(t);
  39. #endif
  40. #ifdef RLIMIT_DATA
  41.  if (rl[RLIMIT_DATA].rlim_max == RLIM_INFINITY) sprintf(t,"data inf ");
  42.  else sprintf(t,"data %8d ",rl[RLIMIT_DATA].rlim_max);
  43.  t += strlen(t);
  44. #endif
  45. #ifdef RLIMIT_STACK
  46.  if (rl[RLIMIT_STACK].rlim_max == RLIM_INFINITY) sprintf(t,"stack inf ");
  47.  else sprintf(t,"stack %8d ",rl[RLIMIT_STACK].rlim_max);
  48.  t += strlen(t);
  49. #endif
  50. #ifdef RLIMIT_CORE
  51.  if (rl[RLIMIT_CORE].rlim_max == RLIM_INFINITY) sprintf(t,"core inf ");
  52.  else sprintf(t,"core %8d ",rl[RLIMIT_CORE].rlim_max);
  53.  t += strlen(t);
  54. #endif
  55. #ifdef RLIMIT_RSS
  56.  if (rl[RLIMIT_RSS].rlim_max == RLIM_INFINITY) sprintf(t,"mem inf ");
  57.  else sprintf(t,"rss %8d ",rl[RLIMIT_RSS].rlim_max);
  58.  t += strlen(t);
  59. #endif
  60.  
  61.  return result;
  62. }
  63.