Sun, 17 Jul 2011 03:57:21 +0000
Replace numerous strcpy() invocations with strlcpy() in Zephyr.
Thanks to the Electronic Frontier Foundation (http://www.eff.org/) for
this patch.
| 2086 | 1 | #ifndef __INTERNAL_H__ |
| 2 | #define __INTERNAL_H__ | |
| 3 | ||
| 4 | #include <sysdep.h> | |
| 10867 | 5 | |
|
23315
934db4b32b9f
When compiling against an external libzephyr, we need to use its zephyr.h,
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
6 | #ifdef LIBZEPHYR_EXT |
|
934db4b32b9f
When compiling against an external libzephyr, we need to use its zephyr.h,
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
7 | #include <zephyr/zephyr.h> |
|
934db4b32b9f
When compiling against an external libzephyr, we need to use its zephyr.h,
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
8 | #else |
|
934db4b32b9f
When compiling against an external libzephyr, we need to use its zephyr.h,
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
9 | #include <zephyr_internal.h> |
|
934db4b32b9f
When compiling against an external libzephyr, we need to use its zephyr.h,
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
10 | #endif |
|
934db4b32b9f
When compiling against an external libzephyr, we need to use its zephyr.h,
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
11 | |
| 10867 | 12 | #ifndef WIN32 |
| 2086 | 13 | #include <netdb.h> |
| 10867 | 14 | #endif |
| 15 | ||
| 16 | ||
| 17 | ||
| 18 | #ifdef WIN32 | |
| 19 | ||
| 20 | #ifndef MAXHOSTNAMELEN | |
| 21 | #define MAXHOSTNAMELEN 512 | |
| 22 | #endif | |
| 23 | ||
| 24 | #define ETIMEDOUT WSAETIMEDOUT | |
| 25 | #define EADDRINUSE WSAEADDRINUSE | |
|
28067
086aa4d8d4a4
zephyr: Build properly on Hurd.
Marc Dequènes <duck@hurdfr.org>
parents:
23315
diff
changeset
|
26 | #else /* !WIN32 */ |
|
086aa4d8d4a4
zephyr: Build properly on Hurd.
Marc Dequènes <duck@hurdfr.org>
parents:
23315
diff
changeset
|
27 | |
|
086aa4d8d4a4
zephyr: Build properly on Hurd.
Marc Dequènes <duck@hurdfr.org>
parents:
23315
diff
changeset
|
28 | #ifndef MAXHOSTNAMELEN |
|
086aa4d8d4a4
zephyr: Build properly on Hurd.
Marc Dequènes <duck@hurdfr.org>
parents:
23315
diff
changeset
|
29 | #define MAXHOSTNAMELEN 4096 |
|
086aa4d8d4a4
zephyr: Build properly on Hurd.
Marc Dequènes <duck@hurdfr.org>
parents:
23315
diff
changeset
|
30 | #endif |
|
086aa4d8d4a4
zephyr: Build properly on Hurd.
Marc Dequènes <duck@hurdfr.org>
parents:
23315
diff
changeset
|
31 | |
| 10867 | 32 | #endif |
| 2086 | 33 | |
| 34 | #ifdef ZEPHYR_USES_HESIOD | |
| 35 | #include <hesiod.h> | |
| 36 | #endif | |
| 37 | ||
| 38 | #ifndef ZEPHYR_USES_KERBEROS | |
| 39 | #define REALM_SZ MAXHOSTNAMELEN | |
| 40 | #define INST_SZ 0 /* no instances w/o Kerberos */ | |
| 41 | #define ANAME_SZ 9 /* size of a username + null */ | |
| 42 | #define CLOCK_SKEW 300 /* max time to cache packet ids */ | |
| 43 | #endif | |
| 44 | ||
| 45 | #define SERVER_SVC_FALLBACK htons((unsigned short) 2103) | |
| 46 | #define HM_SVC_FALLBACK htons((unsigned short) 2104) | |
| 47 | #define HM_SRV_SVC_FALLBACK htons((unsigned short) 2105) | |
| 48 | ||
| 49 | #define ZAUTH_CKSUM_FAILED (-2) /* Used only by server. */ | |
| 50 | #define ZAUTH_UNSET (-3) /* Internal to client library. */ | |
| 51 | #define Z_MAXFRAGS 500 /* Max number of packet fragments */ | |
| 52 | #define Z_MAXNOTICESIZE 400000 /* Max size of incoming notice */ | |
| 53 | #define Z_MAXQUEUESIZE 1500000 /* Max size of input queue notices */ | |
| 54 | #define Z_FRAGFUDGE 13 /* Room to for multinotice field */ | |
| 55 | #define Z_NOTICETIMELIMIT 30 /* Time to wait for fragments */ | |
| 56 | #define Z_INITFILTERSIZE 30 /* Starting size of uid filter */ | |
| 57 | ||
| 58 | struct _Z_Hole { | |
| 59 | struct _Z_Hole *next; | |
| 60 | int first; | |
| 61 | int last; | |
| 62 | }; | |
| 63 | ||
| 64 | struct _Z_InputQ { | |
| 65 | struct _Z_InputQ *next; | |
| 66 | struct _Z_InputQ *prev; | |
| 67 | ZNotice_Kind_t kind; | |
| 68 | unsigned ZEPHYR_INT32 timep; | |
| 69 | int packet_len; | |
| 70 | char *packet; | |
| 71 | int complete; | |
| 72 | struct sockaddr_in from; | |
| 73 | struct _Z_Hole *holelist; | |
| 74 | ZUnique_Id_t uid; | |
| 75 | int auth; | |
| 76 | int header_len; | |
| 77 | char *header; | |
| 78 | int msg_len; | |
| 79 | char *msg; | |
| 80 | }; | |
| 81 | ||
| 82 | extern struct _Z_InputQ *__Q_Head, *__Q_Tail; | |
| 83 | ||
| 84 | extern int __Zephyr_open; /* 0 if FD opened, 1 otherwise */ | |
| 85 | extern int __HM_set; /* 0 if dest addr set, 1 otherwise */ | |
| 86 | extern int __Zephyr_server; /* 0 if normal client, 1 if server or zhm */ | |
| 87 | ||
| 88 | extern ZLocations_t *__locate_list; | |
| 89 | extern int __locate_num; | |
| 90 | extern int __locate_next; | |
| 91 | ||
| 92 | extern ZSubscription_t *__subscriptions_list; | |
| 93 | extern int __subscriptions_num; | |
| 94 | extern int __subscriptions_next; | |
| 95 | ||
| 96 | extern int __Zephyr_port; /* Port number */ | |
| 2419 | 97 | extern struct in_addr __My_addr; |
| 2086 | 98 | |
| 99 | typedef Code_t (*Z_SendProc) __P((ZNotice_t *, char *, int, int)); | |
| 100 | ||
| 101 | struct _Z_InputQ *Z_GetFirstComplete __P((void)); | |
| 102 | struct _Z_InputQ *Z_GetNextComplete __P((struct _Z_InputQ *)); | |
| 103 | Code_t Z_XmitFragment __P((ZNotice_t*, char *,int,int)); | |
| 104 | void Z_RemQueue __P((struct _Z_InputQ *)); | |
| 105 | Code_t Z_AddNoticeToEntry __P((struct _Z_InputQ*, ZNotice_t*, int)); | |
| 106 | Code_t Z_FormatAuthHeader __P((ZNotice_t *, char *, int, int *, Z_AuthProc)); | |
| 107 | Code_t Z_FormatHeader __P((ZNotice_t *, char *, int, int *, Z_AuthProc)); | |
| 108 | Code_t Z_FormatRawHeader __P((ZNotice_t *, char*, int, | |
| 109 | int*, char **, char **)); | |
| 110 | Code_t Z_ReadEnqueue __P((void)); | |
| 111 | Code_t Z_ReadWait __P((void)); | |
| 112 | Code_t Z_SendLocation __P((char*, char*, Z_AuthProc, char*)); | |
| 113 | Code_t Z_SendFragmentedNotice __P((ZNotice_t *notice, int len, | |
| 114 | Z_AuthProc cert_func, | |
| 115 | Z_SendProc send_func)); | |
| 116 | Code_t Z_WaitForComplete __P((void)); | |
| 117 | Code_t Z_WaitForNotice __P((ZNotice_t *notice, | |
| 118 | int (*pred) __P((ZNotice_t *, void *)), void *arg, | |
| 119 | int timeout)); | |
| 120 | ||
| 121 | #endif /* __INTERNAL_H__ */ | |
| 122 |