includes.h 13 KB

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