minGlue-stdio.h 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. /* Glue functions for the minIni library, based on the C/C++ stdio library
  2. *
  3. * Or better said: this file contains macros that maps the function interface
  4. * used by minIni to the standard C/C++ file I/O functions.
  5. *
  6. * By CompuPhase, 2008-2014
  7. * This "glue file" is in the public domain. It is distributed without
  8. * warranties or conditions of any kind, either express or implied.
  9. */
  10. /* map required file I/O types and functions to the standard C library */
  11. #include <stdio.h>
  12. #define INI_FILETYPE FILE*
  13. #define ini_openread(filename,file) ((*(file) = fopen((filename),"rb")) != NULL)
  14. #define ini_openwrite(filename,file) ((*(file) = fopen((filename),"wb")) != NULL)
  15. #define ini_openrewrite(filename,file) ((*(file) = fopen((filename),"r+b")) != NULL)
  16. #define ini_close(file) (fclose(*(file)) == 0)
  17. #define ini_read(buffer,size,file) (fgets((buffer),(size),*(file)) != NULL)
  18. #define ini_write(buffer,file) (fputs((buffer),*(file)) >= 0)
  19. #define ini_rename(source,dest) (rename((source), (dest)) == 0)
  20. #define ini_remove(filename) (remove(filename) == 0)
  21. #define INI_FILEPOS long int
  22. #define ini_tell(file,pos) (*(pos) = ftell(*(file)))
  23. #define ini_seek(file,pos) (fseek(*(file), *(pos), SEEK_SET) == 0)
  24. /* for floating-point support, define additional types and functions */
  25. #define INI_REAL float
  26. #define ini_ftoa(string,value) sprintf((string),"%f",(value))
  27. #define ini_atof(string) (INI_REAL)strtod((string),NULL)