home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libreg / src / vr_stubs.h < prev   
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.8 KB  |  135 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /* vr_stubs.h
  19.  *
  20.  * XP code stubs for stand-alone registry library
  21.  *
  22.  */
  23.  
  24. #ifndef _VR_STUBS_H_
  25. #define _VR_STUBS_H_
  26.  
  27. #include <errno.h>
  28.  
  29. #ifdef XP_MAC
  30. #include <stat.h>
  31. #else
  32. #if defined(BSDI) && !defined(BSDI_2)
  33. #include <sys/types.h>
  34. #endif
  35. #include <sys/stat.h>
  36. #endif
  37.  
  38. #ifndef FALSE
  39. #define FALSE 0
  40. #endif
  41. #ifndef TRUE
  42. #define TRUE 1
  43. #endif
  44.  
  45. #ifdef XP_MAC
  46. #define EMFILE 23
  47. #define EBADF  24
  48. #endif
  49.  
  50. #define XP_FILE_READ             "r"
  51. #define XP_FILE_READ_BIN         "rb"
  52. #define XP_FILE_WRITE            "w"
  53. #define XP_FILE_WRITE_BIN        "wb"
  54. #define XP_FILE_UPDATE           "r+"
  55. #define XP_FILE_TRUNCATE         "w+"
  56. #ifdef SUNOS4
  57. /* XXX SunOS4 hack -- make this universal by using r+b and w+b */
  58. #define XP_FILE_UPDATE_BIN       "r+"
  59. #define XP_FILE_TRUNCATE_BIN     "w+"
  60. #else
  61. #define XP_FILE_UPDATE_BIN       "rb+"
  62. #define XP_FILE_TRUNCATE_BIN     "wb+"
  63. #endif
  64.  
  65. #define XP_FileSeek(file,offset,whence) fseek ((file), (offset), (whence))
  66. #define XP_FileRead(dest,count,file)    fread ((dest), 1, (count), (file))
  67. #define XP_FileWrite(src,count,file)    fwrite ((src), 1, (count), (file))
  68. #define XP_FileTell(file)               ftell(file)
  69. #define XP_FileFlush(file)              fflush(file)
  70. #define XP_FileClose(file)              fclose(file)
  71.  
  72. #define XP_FileOpen(name,type,mode)     VR_StubOpen((mode))
  73.  
  74. #define XP_BEGIN_PROTOS
  75. #define XP_END_PROTOS
  76.  
  77. #define XP_ASSERT(x)        ((void)0)
  78. #define XP_STRCPY(a,b)      strcpy((a),(b))
  79. #define XP_STRLEN(x)        strlen(x)
  80. #define XP_SPRINTF          sprintf
  81. #define XP_FREE(x)          free((x))
  82. #define XP_ALLOC(x)         malloc((x))
  83. #define XP_FREEIF(x)        if ((x)) free((x))
  84. #define XP_STRCMP(x,y)      strcmp((x),(y))
  85. #define XP_STRNCMP(x,y,n)   strncmp((x),(y),(n))
  86. #define XP_STRDUP(s)        strdup((s))
  87. #define XP_MEMCPY(d, s, l)    memcpy((d), (s), (l))
  88. #define XP_MEMSET(d, c, l)      memset((d), (c), (l))
  89.  
  90. #ifdef XP_PC
  91. #define XP_STRCASECMP(x,y)  strcmpi((x),(y))
  92.  
  93. #ifdef XP_OS2
  94. #define XP_STRNCASECMP(x,y,n) strnicmp((x),(y),(n))
  95. #else
  96. #define XP_STRNCASECMP(x,y,n) strncmpi((x),(y),(n))
  97. #endif
  98.  
  99. #endif
  100.  
  101. #ifdef XP_MAC
  102. #define XP_STRCASECMP(x,y)  strcasecmp((x),(y))
  103. #define XP_STRNCASECMP(x,y,n) strncasecmp((x),(y),(n))
  104. extern int strcasecmp(const char *str1, const char *str2);
  105. extern int strncasecmp(const char *str1, const char *str2, int length);
  106. #endif
  107.  
  108. #ifdef XP_UNIX
  109. #define XP_STRCASECMP    strcasecomp   /* from libxp.a */
  110. #endif
  111.  
  112. typedef FILE          * XP_File;
  113.  
  114. typedef long            int32;
  115. typedef unsigned long   uint32;
  116. typedef short           int16;
  117. typedef unsigned short  uint16;
  118. typedef unsigned char   uint8;
  119.  
  120. typedef char            Bool;
  121. typedef int             XP_Bool;
  122.  
  123. #ifdef XP_WIN
  124.  typedef struct _stat   XP_StatStruct;
  125.  #define XP_Stat(file,data,type)     _stat((file),(data))
  126. #else
  127.  typedef struct stat    XP_StatStruct;
  128. #define  XP_Stat(file,data,type)     stat((file),(data))
  129. #endif
  130.  
  131. extern XP_File VR_StubOpen (const char * mode);
  132.  
  133.  
  134. #endif /* _VR_STUBS_H_ */
  135.