res_getname.c

Go to the documentation of this file.
00001 /********************************** */
00002 /* Rule Set Based Access Control    */
00003 /* Author and (c) 2002:             */
00004 /*   Amon Ott <ao@rsbac.org>        */
00005 /* Getname functions for RES module */
00006 /* Last modified: 22/Nov/2002       */
00007 /********************************** */
00008 
00009 #ifndef __KERNEL__
00010 
00011 #include <rsbac/getname.h>
00012 #include <rsbac/res_getname.h>
00013 #include <rsbac/helpers.h>
00014 #include <rsbac/error.h>
00015 
00016 #include <string.h>
00017 
00018 static char  res_list[RSBAC_RES_MAX+2][8] = {
00019    "cpu",
00020    "fsize",
00021    "data",
00022    "stack",
00023    "core",
00024    "rss",
00025    "nproc",
00026    "nofile",
00027    "memlock",
00028    "as",
00029    "locks",
00030    "NONE" };
00031 
00032 /*****************************************/
00033 
00034 char * get_res_name(char * name,
00035                     u_int value)
00036   {
00037     if(!name)
00038       return(NULL);
00039     if(value > RSBAC_RES_MAX)
00040       strcpy(name, "ERROR!");
00041     else
00042       strcpy(name, res_list[value]);
00043     return(name);
00044   };
00045 
00046 int get_res_nr(const char * name)
00047   {
00048     int i;
00049     
00050     if(!name)
00051       return(RSBAC_RES_NONE);
00052     for (i = 0; i <= RSBAC_RES_MAX; i++)
00053       {
00054         if (!strcmp(name, res_list[i]))
00055           {
00056             return(i);
00057           }
00058       }
00059     return(RSBAC_RES_NONE);
00060   };
00061 
00062 #endif /* !__KERNEL__ */

Generated on Fri Jun 17 09:45:26 2005 for RSBAC by  doxygen 1.4.2