home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / LINUX / gopchop-1.1.7.tar.tar / gopchop-1.1.7.tar / gopchop-1.1.7 / src / rc.h < prev    next >
C/C++ Source or Header  |  2003-04-26  |  2KB  |  71 lines

  1. /*
  2. #
  3. # Routines for handling loading/saving an runtime commands file.
  4. #
  5. # $Id: rc.h,v 1.2 2003/04/27 02:49:10 nemies Exp $
  6. #
  7. # Copyright (C) 2003 Kees Cook
  8. # kees@outflux.net, http://outflux.net/
  9. # This program is free software; you can redistribute it and/or
  10. # modify it under the terms of the GNU General Public License
  11. # as published by the Free Software Foundation; either version 2
  12. # of the License, or (at your option) any later version.
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20. # http://www.gnu.org/copyleft/gpl.html
  21. #
  22. */
  23. #ifndef _RC_H_
  24. #define _RC_H_
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30.  
  31.                             /*
  32.                              * When an RC_TYPE_STRING is found, the variable
  33.                              * will be free()d, and the loaded value will
  34.                              * be strdup()d into place.  It is the caller's
  35.                              * responsibility to free() this as needed.
  36.                              * (And to only pass in variables that have been
  37.                              * malloc()d.)
  38.                              */
  39. #define RC_TYPE_STRING    0    /* char*                    */ 
  40. #define RC_TYPE_BOOLEAN 1    /* int (enforced to 0 or 1) */
  41. #define RC_TYPE_INTEGER 2    /* int                      */
  42.  
  43. typedef struct rc_parse_item_t {
  44.     char * option;     /* name of the rc option */
  45.     void * variable; /* variable to load into */
  46.     int    vartype;  /* type of option to load */
  47. } rc_parse_item;
  48.  
  49. /*
  50.  * takes
  51.  *  package name (used as "$HOME/.[PACKAGE]/options")
  52.  *  a list of rc_parse_items (last item must have a NULL 'option')
  53.  * returns
  54.  *   0 on success
  55.  *  -1 on failure
  56.  */
  57. int rc_save(char * package, rc_parse_item * items);
  58. int rc_load(char * package, rc_parse_item * items);
  59.  
  60.  
  61.  
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65.  
  66. #endif /* _RC_H_ */
  67. /* vi:set ai ts=4 sw=4 expandtab: */
  68.