home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gsview13 / src / gvwprf.c < prev    next >
C/C++ Source or Header  |  1995-12-09  |  2KB  |  60 lines

  1. /* Copyright (C) 1993, 1994, Russell Lang.  All rights reserved.
  2.   
  3.   This file is part of GSview.
  4.   
  5.   This program is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the GSview Free Public Licence 
  9.   (the "Licence") for full details.
  10.   
  11.   Every copy of GSview must include a copy of the Licence, normally in a 
  12.   plain ASCII text file named LICENCE.  The Licence grants you the right 
  13.   to copy, modify and redistribute GSview, but only under certain conditions 
  14.   described in the Licence.  Among other things, the Licence requires that 
  15.   the copyright notice and this notice be preserved on all copies.
  16. */
  17.  
  18. /* gvwprf.c */
  19. /* Profile (INI file) routines for Windows */
  20.  
  21. #include "gvwin.h"
  22.  
  23. PROFILE *
  24. profile_open(char *filename)
  25. {
  26. PROFILE *prf;
  27.     if ( (prf = (PROFILE *)malloc(sizeof(PROFILE))) == (PROFILE *)NULL )
  28.         return (PROFILE *)NULL;
  29.     if ( (prf->name = malloc(strlen(filename)+1)) == (char *)NULL ) {
  30.         free(prf);
  31.         return (PROFILE *)NULL;
  32.     }
  33.     strcpy(prf->name, filename);
  34.     return prf;
  35. }
  36.  
  37. int 
  38. profile_read_string(PROFILE *prf, char *section, char GVFAR *entry, char *def, char *buffer, int len)
  39. {
  40.     return GetPrivateProfileString(section, entry, def, buffer, len, prf->name);
  41. }
  42.  
  43. BOOL
  44. profile_write_string(PROFILE *prf, char *section, char *entry, char *value)
  45. {
  46.     return WritePrivateProfileString(section, entry, value, prf->name);
  47. }
  48.  
  49. BOOL
  50. profile_close(PROFILE *prf)
  51. {
  52.     if (prf == (PROFILE *)NULL)
  53.         return FALSE;
  54.     if (prf->name)
  55.         free(prf->name);
  56.     free(prf);
  57.     return TRUE;
  58. }
  59.  
  60.