includes.h 12 KB

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