home *** CD-ROM | disk | FTP | other *** search
- /* History:
- 5/1/91 DJB baseline public domain
- */
-
- /*
-
- char *printrlimits(rl) struct rlimit *rl; returns a string representing
- various information about rlimit array rl. Not well defined.
-
- */
-
- #include <stdio.h>
- #include <strings.h>
- #include <sys/types.h>
- #include <sys/time.h>
- #include <sys/resource.h>
- #include "printrlimits.h"
-
- static char result[500];
-
- /* XXX: print anything other than max? */
-
- char *printrlimits(rl)
- struct rlimit *rl;
- {
- char *t;
-
- t = result;
-
- #ifdef RLIMIT_CPU
- if (rl[RLIMIT_CPU].rlim_max == RLIM_INFINITY) sprintf(t,"cpu inf ");
- else sprintf(t,"cpu %8d ",rl[RLIMIT_CPU].rlim_max);
- t += strlen(t);
- #endif
- #ifdef RLIMIT_FSIZE
- if (rl[RLIMIT_FSIZE].rlim_max == RLIM_INFINITY) sprintf(t,"file inf ");
- else sprintf(t,"fsize %8d ",rl[RLIMIT_FSIZE].rlim_max);
- t += strlen(t);
- #endif
- #ifdef RLIMIT_DATA
- if (rl[RLIMIT_DATA].rlim_max == RLIM_INFINITY) sprintf(t,"data inf ");
- else sprintf(t,"data %8d ",rl[RLIMIT_DATA].rlim_max);
- t += strlen(t);
- #endif
- #ifdef RLIMIT_STACK
- if (rl[RLIMIT_STACK].rlim_max == RLIM_INFINITY) sprintf(t,"stack inf ");
- else sprintf(t,"stack %8d ",rl[RLIMIT_STACK].rlim_max);
- t += strlen(t);
- #endif
- #ifdef RLIMIT_CORE
- if (rl[RLIMIT_CORE].rlim_max == RLIM_INFINITY) sprintf(t,"core inf ");
- else sprintf(t,"core %8d ",rl[RLIMIT_CORE].rlim_max);
- t += strlen(t);
- #endif
- #ifdef RLIMIT_RSS
- if (rl[RLIMIT_RSS].rlim_max == RLIM_INFINITY) sprintf(t,"mem inf ");
- else sprintf(t,"rss %8d ",rl[RLIMIT_RSS].rlim_max);
- t += strlen(t);
- #endif
-
- return result;
- }
-