file.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. #ifndef BASE_FILE_H
  42. #define BASE_FILE_H
  43. #ifndef NOINTNSAPI
  44. #define INTNSAPI
  45. #endif /* !NOINTNSAPI */
  46. /* GLOBAL FUNCTIONS:
  47. * DESCRIPTION:
  48. * system-specific functions for reading/writing files
  49. */
  50. #ifndef NETSITE_H
  51. #include "../netsite.h"
  52. #endif /* !NETSITE_H */
  53. /* --- Begin function prototypes --- */
  54. #ifdef INTNSAPI
  55. NSPR_BEGIN_EXTERN_C
  56. void INTsystem_errmsg_init(void);
  57. NSAPI_PUBLIC SYS_FILE INTsystem_fopenRO(char *path);
  58. NSAPI_PUBLIC SYS_FILE INTsystem_fopenWA(char *path);
  59. NSAPI_PUBLIC SYS_FILE INTsystem_fopenRW(char *path);
  60. NSAPI_PUBLIC SYS_FILE INTsystem_fopenWT(char *path);
  61. NSAPI_PUBLIC int INTsystem_fread(SYS_FILE fd, char *buf, int sz);
  62. NSAPI_PUBLIC int INTsystem_fwrite(SYS_FILE fd,char *buf,int sz);
  63. NSAPI_PUBLIC int INTsystem_fwrite_atomic(SYS_FILE fd, char *buf, int sz);
  64. NSAPI_PUBLIC int INTsystem_lseek(SYS_FILE fd, int off, int wh);
  65. NSAPI_PUBLIC int INTsystem_fclose(SYS_FILE fd);
  66. NSAPI_PUBLIC int INTsystem_stat(char *name, struct stat *finfo);
  67. NSAPI_PUBLIC int INTsystem_rename(char *oldpath, char *newpath);
  68. NSAPI_PUBLIC int INTsystem_unlink(char *path);
  69. NSAPI_PUBLIC int INTsystem_tlock(SYS_FILE fd);
  70. NSAPI_PUBLIC int INTsystem_flock(SYS_FILE fd);
  71. NSAPI_PUBLIC int INTsystem_ulock(SYS_FILE fd);
  72. #ifdef XP_WIN32
  73. NSAPI_PUBLIC SYS_DIR INTdir_open(char *path);
  74. NSAPI_PUBLIC SYS_DIRENT *INTdir_read(SYS_DIR ds);
  75. NSAPI_PUBLIC void INTdir_close(SYS_DIR ds);
  76. #endif /* XP_WIN32 */
  77. NSAPI_PUBLIC int INTdir_create_all(char *dir);
  78. /* --- OBSOLETE ----------------------------------------------------------
  79. * The following macros/functions are obsolete and are only maintained for
  80. * compatibility. Do not use them. 11-19-96
  81. * -----------------------------------------------------------------------
  82. */
  83. #ifdef XP_WIN32
  84. NSAPI_PUBLIC char *INTsystem_winsockerr(void);
  85. NSAPI_PUBLIC char *INTsystem_winerr(void);
  86. NSAPI_PUBLIC int INTsystem_pread(SYS_FILE fd, char *buf, int sz);
  87. NSAPI_PUBLIC int INTsystem_pwrite(SYS_FILE fd, char *buf, int sz);
  88. NSAPI_PUBLIC void INTfile_unix2local(char *path, char *p2);
  89. #endif /* XP_WIN32 */
  90. NSAPI_PUBLIC int INTsystem_nocoredumps(void);
  91. NSAPI_PUBLIC int INTfile_setinherit(SYS_FILE fd, int value);
  92. NSAPI_PUBLIC int INTfile_notfound(void);
  93. NSAPI_PUBLIC char *INTsystem_errmsg(void);
  94. NSAPI_PUBLIC int INTsystem_errmsg_fn(char **buff, size_t maxlen);
  95. NSPR_END_EXTERN_C
  96. #define system_errmsg_init INTsystem_errmsg_init
  97. #define system_fopenRO INTsystem_fopenRO
  98. #define system_fopenWA INTsystem_fopenWA
  99. #define system_fopenRW INTsystem_fopenRW
  100. #define system_fopenWT INTsystem_fopenWT
  101. #define system_fread INTsystem_fread
  102. #define system_fwrite INTsystem_fwrite
  103. #define system_fwrite_atomic INTsystem_fwrite_atomic
  104. #define system_lseek INTsystem_lseek
  105. #define system_fclose INTsystem_fclose
  106. #define system_stat INTsystem_stat
  107. #define system_rename INTsystem_rename
  108. #define system_unlink INTsystem_unlink
  109. #define system_tlock INTsystem_tlock
  110. #define system_flock INTsystem_flock
  111. #define system_ulock INTsystem_ulock
  112. #ifdef XP_WIN32
  113. #define dir_open INTdir_open
  114. #define dir_read INTdir_read
  115. #define dir_close INTdir_close
  116. #endif /* XP_WIN32 */
  117. #define dir_create_all INTdir_create_all
  118. /* Obsolete */
  119. #ifdef XP_WIN32
  120. #define system_winsockerr INTsystem_winsockerr
  121. #define system_winerr INTsystem_winerr
  122. #define system_pread INTsystem_pread
  123. #define system_pwrite INTsystem_pwrite
  124. #define file_unix2local INTfile_unix2local
  125. #endif /* XP_WIN32 */
  126. #define system_nocoredumps INTsystem_nocoredumps
  127. #define file_setinherit INTfile_setinherit
  128. #define file_notfound INTfile_notfound
  129. #define rtfile_notfound INTfile_notfound
  130. #define system_errmsg INTsystem_errmsg
  131. #define system_errmsg_fn INTsystem_errmsg_fn
  132. #endif /* INTNSAPI */
  133. #endif /* BASE_FILE_H */