includes.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. #ifndef _INCLUDES_H
  2. #define _INCLUDES_H
  3. /*
  4. Unix SMB/Netbios implementation.
  5. Version 1.9.
  6. Machine customisation and include handling
  7. Copyright (C) Andrew Tridgell 1994-1998
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef NO_CONFIG_H /* for some tests */
  21. #include "config.h"
  22. #endif
  23. #include "local.h"
  24. #ifdef AIX
  25. #define DEFAULT_PRINTING PRINT_AIX
  26. #define PRINTCAP_NAME "/etc/qconfig"
  27. #endif
  28. #ifdef HPUX
  29. #define DEFAULT_PRINTING PRINT_HPUX
  30. #endif
  31. #ifdef QNX
  32. #define DEFAULT_PRINTING PRINT_QNX
  33. #endif
  34. #include <sys/types.h>
  35. #include <fcntl.h>
  36. #include <sys/stat.h>
  37. #include <sys/time.h>
  38. #include <time.h>
  39. #include <unistd.h>
  40. #include <stdio.h>
  41. #include <stddef.h>
  42. #include <stdlib.h>
  43. #include <signal.h>
  44. #include <sys/wait.h>
  45. #ifdef HAVE_SYS_RESOURCE_H
  46. #include <sys/resource.h>
  47. #endif
  48. #ifdef HAVE_SYS_PARAM_H
  49. #include <sys/param.h>
  50. #endif
  51. #ifdef HAVE_SYS_SOCKET_H
  52. #include <sys/socket.h>
  53. #endif
  54. #ifdef HAVE_SYS_SYSCALL_H
  55. #include <sys/syscall.h>
  56. #elif HAVE_SYSCALL_H
  57. #include <syscall.h>
  58. #endif
  59. #ifdef HAVE_STRING_H
  60. #include <string.h>
  61. #endif
  62. #ifdef HAVE_STRINGS_H
  63. #include <strings.h>
  64. #endif
  65. #ifdef HAVE_MEMORY_H
  66. #include <memory.h>
  67. #endif
  68. #ifdef MEM_MAN
  69. #include "../mem_man/mem_man.h"
  70. #else
  71. #ifdef HAVE_MALLOC_H
  72. #include <malloc.h>
  73. #endif
  74. #endif
  75. #ifdef HAVE_LIMITS_H
  76. #include <limits.h>
  77. #endif
  78. #ifdef HAVE_SYS_IOCTL_H
  79. #include <sys/ioctl.h>
  80. #endif
  81. #ifdef HAVE_SYS_FILIO_H
  82. #include <sys/filio.h>
  83. #endif
  84. #ifdef HAVE_CTYPE_H
  85. #include <ctype.h>
  86. #endif
  87. #include <grp.h>
  88. #ifdef HAVE_SYS_ID_H
  89. #include <sys/id.h>
  90. #endif
  91. /* AIX 4.1 and previous needs this for setpriv */
  92. #if defined(HAVE_SETPRIV) && defined(HAVE_SYS_PRIV_H)
  93. #include <sys/priv.h>
  94. #endif
  95. #include <errno.h>
  96. #ifdef HAVE_UTIME_H
  97. #include <utime.h>
  98. #endif
  99. #ifdef HAVE_SYS_SELECT_H
  100. #include <sys/select.h>
  101. #endif
  102. #ifdef HAVE_SYS_MODE_H
  103. /* apparently AIX needs this for S_ISLNK */
  104. #ifndef S_ISLNK
  105. #include <sys/mode.h>
  106. #endif
  107. #endif
  108. #ifdef HAVE_GLOB_H
  109. #include <glob.h>
  110. #endif
  111. #include <pwd.h>
  112. #ifdef HAVE_STDARG_H
  113. #include <stdarg.h>
  114. #else
  115. #include <varargs.h>
  116. #endif
  117. #include <netinet/in.h>
  118. #include <arpa/inet.h>
  119. #include <netdb.h>
  120. #include <syslog.h>
  121. #include <sys/file.h>
  122. #ifdef HAVE_NETINET_TCP_H
  123. #include <netinet/tcp.h>
  124. #endif
  125. /*
  126. * The next two defines are needed to the IPTOS_* options
  127. * on some systems.
  128. */
  129. #ifdef HAVE_NETINET_IN_SYSTM_H
  130. #include <netinet/in_systm.h>
  131. #endif
  132. #ifdef HAVE_NETINET_IN_IP_H
  133. #include <netinet/ip.h>
  134. #endif
  135. /* POSIX terminal handling. */
  136. #include <termios.h>
  137. # include <dirent.h>
  138. #ifdef HAVE_SYS_MMAN_H
  139. #include <sys/mman.h>
  140. #endif
  141. #ifdef HAVE_SYSV_IPC
  142. #include <sys/ipc.h>
  143. #include <sys/shm.h>
  144. #include <sys/sem.h>
  145. #endif
  146. #ifdef HAVE_NET_IF_H
  147. #include <net/if.h>
  148. #endif
  149. #ifdef HAVE_SYS_MOUNT_H
  150. #include <sys/mount.h>
  151. #endif
  152. #ifdef HAVE_SYS_VFS_H
  153. #include <sys/vfs.h>
  154. #endif
  155. #ifdef HAVE_SYS_ACL_H
  156. #include <sys/acl.h>
  157. #endif
  158. #ifdef HAVE_SYS_FS_S5PARAM_H
  159. #include <sys/fs/s5param.h>
  160. #endif
  161. #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
  162. #include <sys/filsys.h>
  163. #endif
  164. #ifdef HAVE_SYS_STATFS_H
  165. # include <sys/statfs.h>
  166. #endif
  167. #ifdef HAVE_DUSTAT_H
  168. #include <sys/dustat.h>
  169. #endif
  170. #ifdef HAVE_SYS_STATVFS_H
  171. #include <sys/statvfs.h>
  172. #endif
  173. #ifdef HAVE_SHADOW_H
  174. #include <shadow.h>
  175. #endif
  176. #ifdef HAVE_GETPWANAM
  177. #include <sys/label.h>
  178. #include <sys/audit.h>
  179. #include <pwdadj.h>
  180. #endif
  181. #ifdef HAVE_SYS_SECURITY_H
  182. #include <sys/security.h>
  183. #include <prot.h>
  184. #define PASSWORD_LENGTH 16
  185. #endif /* HAVE_SYS_SECURITY_H */
  186. #ifdef HAVE_COMPAT_H
  187. #include <compat.h>
  188. #endif
  189. #ifdef HAVE_STROPTS_H
  190. #include <stropts.h>
  191. #endif
  192. #ifdef HAVE_POLL_H
  193. #include <poll.h>
  194. #endif
  195. #if defined(HAVE_RPC_RPC_H)
  196. /*
  197. * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
  198. */
  199. #if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
  200. #undef AUTH_ERROR
  201. #endif
  202. #include <rpc/rpc.h>
  203. #endif
  204. #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
  205. #define HAVE_NETGROUP 1
  206. #endif
  207. #if defined (HAVE_NETGROUP)
  208. #if defined(HAVE_RPCSVC_YP_PROT_H)
  209. #include <rpcsvc/yp_prot.h>
  210. #endif
  211. #if defined(HAVE_RPCSVC_YPCLNT_H)
  212. #include <rpcsvc/ypclnt.h>
  213. #endif
  214. #endif /* HAVE_NETGROUP */
  215. #ifndef uchar
  216. #define uchar unsigned char
  217. #endif
  218. #define schar signed char
  219. /*
  220. Samba needs type definitions for int16, int32, uint16 and uint32.
  221. Normally these are signed and unsigned 16 and 32 bit integers, but
  222. they actually only need to be at least 16 and 32 bits
  223. respectively. Thus if your word size is 8 bytes just defining them
  224. as signed and unsigned int will work.
  225. */
  226. #ifndef uint8
  227. #define uint8 unsigned char
  228. #endif
  229. #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
  230. #if (SIZEOF_SHORT == 4)
  231. #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
  232. #else /* SIZEOF_SHORT != 4 */
  233. #define int16 short
  234. #endif /* SIZEOF_SHORT != 4 */
  235. #endif
  236. /*
  237. * Note we duplicate the size tests in the unsigned
  238. * case as int16 may be a typedef from rpc/rpc.h
  239. */
  240. #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
  241. #if (SIZEOF_SHORT == 4)
  242. #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
  243. #else /* SIZEOF_SHORT != 4 */
  244. #define uint16 unsigned short
  245. #endif /* SIZEOF_SHORT != 4 */
  246. #endif
  247. #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
  248. #if (SIZEOF_INT == 4)
  249. #define int32 int
  250. #elif (SIZEOF_LONG == 4)
  251. #define int32 long
  252. #elif (SIZEOF_SHORT == 4)
  253. #define int32 short
  254. #endif
  255. #endif
  256. /*
  257. * Note we duplicate the size tests in the unsigned
  258. * case as int32 may be a typedef from rpc/rpc.h
  259. */
  260. #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
  261. #if (SIZEOF_INT == 4)
  262. #define uint32 unsigned int
  263. #elif (SIZEOF_LONG == 4)
  264. #define uint32 unsigned long
  265. #elif (SIZEOF_SHORT == 4)
  266. #define uint32 unsigned short
  267. #endif
  268. #endif
  269. /*
  270. * Types for devices, inodes and offsets.
  271. */
  272. #ifndef SMB_DEV_T
  273. #define SMB_DEV_T dev_t
  274. #endif
  275. /*
  276. * Setup the correctly sized inode type.
  277. */
  278. #ifndef SMB_INO_T
  279. # define SMB_INO_T ino_t
  280. #endif
  281. #ifndef LARGE_SMB_INO_T
  282. # if defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8)
  283. # define LARGE_SMB_INO_T 1
  284. # endif
  285. #endif
  286. #ifdef LARGE_SMB_INO_T
  287. #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
  288. #else
  289. #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
  290. #endif
  291. #ifndef SMB_OFF_T
  292. # define SMB_OFF_T off_t
  293. #endif
  294. #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
  295. /*
  296. * Set the define that tells us if we can do 64 bit
  297. * NT SMB calls.
  298. */
  299. #ifndef LARGE_SMB_OFF_T
  300. # if defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)
  301. # define LARGE_SMB_OFF_T 1
  302. # endif
  303. #endif
  304. #ifdef LARGE_SMB_OFF_T
  305. #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
  306. #else
  307. #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
  308. #endif
  309. /*
  310. * Type for stat structure.
  311. */
  312. #ifndef SMB_STRUCT_STAT
  313. # define SMB_STRUCT_STAT struct stat
  314. #endif
  315. /*
  316. * Type for dirent structure.
  317. */
  318. #ifndef SMB_STRUCT_DIRENT
  319. # define SMB_STRUCT_DIRENT struct dirent
  320. #endif
  321. /*
  322. * Defines for 64 bit fcntl locks.
  323. */
  324. #ifndef SMB_STRUCT_FLOCK
  325. # define SMB_STRUCT_FLOCK struct flock
  326. #endif
  327. #ifndef SMB_F_SETLKW
  328. # define SMB_F_SETLKW F_SETLKW
  329. #endif
  330. #ifndef SMB_F_SETLK
  331. # define SMB_F_SETLK F_SETLK
  332. #endif
  333. #ifndef SMB_F_GETLK
  334. # define SMB_F_GETLK F_GETLK
  335. #endif
  336. #if defined(HAVE_LONGLONG)
  337. #define SMB_BIG_UINT unsigned long long
  338. #define SMB_BIG_INT long long
  339. #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
  340. #else
  341. #define SMB_BIG_UINT unsigned long
  342. #define SMB_BIG_INT long
  343. #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
  344. #endif
  345. #ifndef MIN
  346. #define MIN(a,b) ((a)<(b)?(a):(b))
  347. #endif
  348. #ifndef MAX
  349. #define MAX(a,b) ((a)>(b)?(a):(b))
  350. #endif
  351. #ifdef HAVE_BROKEN_GETGROUPS
  352. #define GID_T int
  353. #else
  354. #define GID_T gid_t
  355. #endif
  356. #include "version.h"
  357. #include "smb.h"
  358. #include "nameserv.h"
  359. #include "byteorder.h"
  360. #include "kanji.h"
  361. #include "charset.h"
  362. #include "nterr.h"
  363. #ifndef MAXCODEPAGELINES
  364. #define MAXCODEPAGELINES 256
  365. #endif
  366. /***** automatically generated prototypes *****/
  367. #include "proto.h"
  368. #ifdef sprintf
  369. #undef sprintf
  370. #endif /* sprintf */
  371. #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
  372. #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
  373. #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
  374. #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
  375. #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
  376. #ifdef __COMPAR_FN_T
  377. #define QSORT_CAST (__compar_fn_t)
  378. #endif
  379. #ifndef QSORT_CAST
  380. #define QSORT_CAST (int (*)(const void *, const void *))
  381. #endif
  382. /* this guess needs to be improved (tridge) */
  383. #if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
  384. #define SYSV 1
  385. #endif
  386. #ifndef DEFAULT_PRINTING
  387. #ifdef SYSV
  388. #define DEFAULT_PRINTING PRINT_SYSV
  389. #define PRINTCAP_NAME "lpstat"
  390. #else
  391. #define DEFAULT_PRINTING PRINT_BSD
  392. #define PRINTCAP_NAME "/etc/printcap"
  393. #endif
  394. #endif
  395. #ifndef PRINTCAP_NAME
  396. #define PRINTCAP_NAME "/etc/printcap"
  397. #endif
  398. #ifndef SIGCLD
  399. #define SIGCLD SIGCHLD
  400. #endif
  401. #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
  402. #define FAST_SHARE_MODES 1
  403. #endif
  404. #ifndef MAP_FILE
  405. #define MAP_FILE 0
  406. #endif
  407. #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
  408. #define USE_SMBPASS_DB 1
  409. #endif
  410. #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
  411. #define OSF1_ENH_SEC 1
  412. #endif
  413. #ifndef ALLOW_CHANGE_PASSWORD
  414. #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
  415. #define ALLOW_CHANGE_PASSWORD 1
  416. #endif
  417. #endif
  418. /* what is the longest significant password available on your system?
  419. Knowing this speeds up password searches a lot */
  420. #ifndef PASSWORD_LENGTH
  421. #define PASSWORD_LENGTH 8
  422. #endif
  423. #ifndef HAVE_PIPE
  424. #define SYNC_DNS 1
  425. #endif
  426. #ifndef MAXPATHLEN
  427. #define MAXPATHLEN 256
  428. #endif
  429. #ifndef SEEK_SET
  430. #define SEEK_SET 0
  431. #endif
  432. #ifndef INADDR_LOOPBACK
  433. #define INADDR_LOOPBACK 0x7f000001
  434. #endif
  435. #ifndef INADDR_NONE
  436. #define INADDR_NONE 0xffffffff
  437. #endif
  438. #ifndef O_ACCMODE
  439. #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
  440. #endif
  441. #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
  442. #define ULTRIX_AUTH 1
  443. #endif
  444. #ifndef HAVE_INITGROUPS
  445. int initgroups(char *name,gid_t id);
  446. #endif
  447. #ifndef HAVE_RENAME
  448. int rename(const char *zfrom, const char *zto);
  449. #endif
  450. #ifndef HAVE_MKTIME
  451. time_t mktime(struct tm *t);
  452. #endif
  453. #ifndef HAVE_STRTOUL
  454. unsigned long strtoul(const char *nptr, char **endptr, int base);
  455. #endif
  456. #ifdef REPLACE_GETPASS
  457. #define getpass(prompt) getsmbpass((prompt))
  458. #endif
  459. /*
  460. * Some older systems seem not to have MAXHOSTNAMELEN
  461. * defined.
  462. */
  463. #ifndef MAXHOSTNAMELEN
  464. #define MAXHOSTNAMELEN 254
  465. #endif
  466. /* yuck, I'd like a better way of doing this */
  467. #define DIRP_SIZE (256 + 32)
  468. #endif /* _INCLUDES_H */