cmdlib.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. //
  19. // start of shared cmdlib stuff
  20. //
  21. #ifndef __CMDLIB__
  22. #define __CMDLIB__
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <stdlib.h>
  26. #include <errno.h>
  27. #include <ctype.h>
  28. #include <time.h>
  29. #include <stdarg.h>
  30. #ifndef __BYTEBOOL__
  31. #define __BYTEBOOL__
  32. #ifndef __cplusplus
  33. typedef enum {false, true} boolean;
  34. #else
  35. typedef unsigned char boolean;
  36. #endif
  37. typedef unsigned char byte;
  38. //typedef unsigned char byte;
  39. #endif
  40. FILE *SafeOpenWrite (const char *filename);
  41. FILE *SafeOpenRead (const char *filename);
  42. void SafeRead (FILE *f, void *buffer, int count);
  43. void SafeWrite (FILE *f, const void *buffer, int count);
  44. int LoadFile (const char *filename, void **bufferptr);
  45. int LoadFileNoCrash (const char *filename, void **bufferptr);
  46. void SaveFile (const char *filename, void *buffer, int count);
  47. void DefaultExtension (char *path, char *extension);
  48. void DefaultPath (char *path, char *basepath);
  49. void StripFilename (char *path);
  50. void StripExtension (char *path);
  51. void ExtractFilePath (const char *path, char *dest);
  52. void ExtractFileName (const char *path, char *dest);
  53. void ExtractFileBase (const char *path, char *dest);
  54. void ExtractFileExtension (const char *path, char *dest);
  55. short BigShort (short l);
  56. short LittleShort (short l);
  57. int BigLong (int l);
  58. int LittleLong (int l);
  59. float BigFloat (float l);
  60. float LittleFloat (float l);
  61. void *qmalloc (size_t size);
  62. void* qblockmalloc(size_t nSize);
  63. // error and printf functions
  64. typedef void (PFN_ERR)(const char *pFormat, ...);
  65. typedef void (PFN_PRINTF)(const char *pFormat, ...);
  66. typedef void (PFN_ERR_NUM)(int nNum, const char *pFormat, ...);
  67. typedef void (PFN_PRINTF_NUM)(int nNum, const char *pFormat, ...);
  68. void Error(const char *pFormat, ...);
  69. void Printf(const char *pFormat, ...);
  70. void ErrorNum(int n, const char *pFormat, ...);
  71. void PrintfNum(int n, const char *pFormat, ...);
  72. void SetErrorHandler(PFN_ERR pe);
  73. void SetPrintfHandler(PFN_PRINTF pe);
  74. void SetErrorHandlerNum(PFN_ERR_NUM pe);
  75. void SetPrintfHandlerNum(PFN_PRINTF_NUM pe);
  76. void ConvertDOSToUnixName( char *dst, const char *src );
  77. char* StrDup(char* pStr);
  78. char* StrDup(const char* pStr);
  79. #endif