diff --git a/lib/roken/Makefile.am b/lib/roken/Makefile.am index 41f1c5998..b6759ace1 100644 --- a/lib/roken/Makefile.am +++ b/lib/roken/Makefile.am @@ -8,6 +8,7 @@ CLEANFILES = roken.h make-roken.c $(XHEADERS) lib_LTLIBRARIES = libroken.la libroken_la_LDFLAGS = -version-info 17:0:1 +libroken_la_CPPFLAGS = -DBUILD_ROKEN_LIB noinst_PROGRAMS = make-roken snprintf-test resolve-test diff --git a/lib/roken/base64.c b/lib/roken/base64.c index 187a7c2b6..cba232e2a 100644 --- a/lib/roken/base64.c +++ b/lib/roken/base64.c @@ -52,7 +52,7 @@ pos(char c) return -1; } -int +int ROKEN_LIB_FUNCTION base64_encode(const void *data, int size, char **str) { char *s, *p; @@ -114,7 +114,7 @@ token_decode(const char *token) return (marker << 24) | val; } -int +int ROKEN_LIB_FUNCTION base64_decode(const char *str, void *data) { const char *p; diff --git a/lib/roken/base64.h b/lib/roken/base64.h index bf244e6a5..de8936479 100644 --- a/lib/roken/base64.h +++ b/lib/roken/base64.h @@ -36,7 +36,18 @@ #ifndef _BASE64_H_ #define _BASE64_H_ -int base64_encode(const void *data, int size, char **str); -int base64_decode(const char *str, void *data); +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + +int ROKEN_LIB_FUNCTION +base64_encode(const void *data, int size, char **str); + +int ROKEN_LIB_FUNCTION +base64_decode(const char *str, void *data); #endif diff --git a/lib/roken/bswap.c b/lib/roken/bswap.c index c3e47d8a9..0f42fc316 100644 --- a/lib/roken/bswap.c +++ b/lib/roken/bswap.c @@ -40,7 +40,7 @@ RCSID("$Id$"); #ifndef HAVE_BSWAP32 -unsigned int +unsigned int ROKEN_LIB_FUNCTION bswap32 (unsigned int val) { return (val & 0xff) << 24 | @@ -52,7 +52,7 @@ bswap32 (unsigned int val) #ifndef HAVE_BSWAP16 -unsigned short +unsigned short ROKEN_LIB_FUNCTION bswap16 (unsigned short val) { return (val & 0xff) << 8 | diff --git a/lib/roken/chown.c b/lib/roken/chown.c index cb6f56385..81727ddb4 100644 --- a/lib/roken/chown.c +++ b/lib/roken/chown.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -int +int ROKEN_LIB_FUNCTION chown(const char *path, uid_t owner, gid_t group) { return 0; diff --git a/lib/roken/concat.c b/lib/roken/concat.c index 9828c4336..b6bf23040 100644 --- a/lib/roken/concat.c +++ b/lib/roken/concat.c @@ -37,7 +37,7 @@ RCSID("$Id$"); #endif #include "roken.h" -int +int ROKEN_LIB_FUNCTION roken_concat (char *s, size_t len, ...) { int ret; @@ -49,7 +49,7 @@ roken_concat (char *s, size_t len, ...) return ret; } -int +int ROKEN_LIB_FUNCTION roken_vconcat (char *s, size_t len, va_list args) { const char *a; @@ -67,7 +67,7 @@ roken_vconcat (char *s, size_t len, va_list args) return 0; } -size_t +size_t ROKEN_LIB_FUNCTION roken_vmconcat (char **s, size_t max_len, va_list args) { const char *a; @@ -99,7 +99,7 @@ roken_vmconcat (char **s, size_t max_len, va_list args) return len; } -size_t +size_t ROKEN_LIB_FUNCTION roken_mconcat (char **s, size_t max_len, ...) { int ret; diff --git a/lib/roken/copyhostent.c b/lib/roken/copyhostent.c index 024dbef48..4999bbab8 100644 --- a/lib/roken/copyhostent.c +++ b/lib/roken/copyhostent.c @@ -42,7 +42,7 @@ RCSID("$Id$"); * return a malloced copy of `h' */ -struct hostent * +struct hostent * ROKEN_LIB_FUNCTION copyhostent (const struct hostent *h) { struct hostent *res; diff --git a/lib/roken/daemon.c b/lib/roken/daemon.c index 4af7a7396..6a06a686a 100644 --- a/lib/roken/daemon.c +++ b/lib/roken/daemon.c @@ -51,7 +51,7 @@ RCSID("$Id$"); #include "roken.h" -int +int ROKEN_LIB_FUNCTION daemon(int nochdir, int noclose) { int fd; diff --git a/lib/roken/ecalloc.c b/lib/roken/ecalloc.c index 8b3324fed..d0439d361 100644 --- a/lib/roken/ecalloc.c +++ b/lib/roken/ecalloc.c @@ -45,7 +45,7 @@ RCSID("$Id$"); * Like calloc but never fails. */ -void * +void * ROKEN_LIB_FUNCTION ecalloc (size_t number, size_t size) { void *tmp = calloc (number, size); diff --git a/lib/roken/emalloc.c b/lib/roken/emalloc.c index 51de60a37..8b8e1f8f7 100644 --- a/lib/roken/emalloc.c +++ b/lib/roken/emalloc.c @@ -45,7 +45,7 @@ RCSID("$Id$"); * Like malloc but never fails. */ -void * +void * ROKEN_LIB_FUNCTION emalloc (size_t sz) { void *tmp = malloc (sz); diff --git a/lib/roken/environment.c b/lib/roken/environment.c index b5242d1d5..fcdc0c2a1 100644 --- a/lib/roken/environment.c +++ b/lib/roken/environment.c @@ -46,7 +46,7 @@ RCSID("$Id$"); * list of malloced strings in `env' */ -int +int ROKEN_LIB_FUNCTION read_environment(const char *file, char ***env) { int i, k; diff --git a/lib/roken/eread.c b/lib/roken/eread.c index 40ba66202..d370b40f5 100644 --- a/lib/roken/eread.c +++ b/lib/roken/eread.c @@ -45,7 +45,7 @@ RCSID("$Id$"); * Like read but never fails (and never returns partial data). */ -ssize_t +ssize_t ROKEN_LIB_FUNCTION eread (int fd, void *buf, size_t nbytes) { ssize_t ret; diff --git a/lib/roken/erealloc.c b/lib/roken/erealloc.c index 84c9aaadc..d684481da 100644 --- a/lib/roken/erealloc.c +++ b/lib/roken/erealloc.c @@ -45,7 +45,7 @@ RCSID("$Id$"); * Like realloc but never fails. */ -void * +void * ROKEN_LIB_FUNCTION erealloc (void *ptr, size_t sz) { void *tmp = realloc (ptr, sz); diff --git a/lib/roken/err.c b/lib/roken/err.c index cc1b03178..d3ebfe50b 100644 --- a/lib/roken/err.c +++ b/lib/roken/err.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "err.h" -void +void ROKEN_LIB_FUNCTION err(int eval, const char *fmt, ...) { va_list ap; diff --git a/lib/roken/err.hin b/lib/roken/err.hin index 890d7c5a3..7abf4a9e1 100644 --- a/lib/roken/err.hin +++ b/lib/roken/err.hin @@ -46,21 +46,43 @@ #define __attribute__(x) #endif -void verr(int eval, const char *fmt, va_list ap) +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + +void ROKEN_LIB_FUNCTION +verr(int eval, const char *fmt, va_list ap) __attribute__ ((noreturn, format (printf, 2, 0))); -void err(int eval, const char *fmt, ...) + +void ROKEN_LIB_FUNCTION +err(int eval, const char *fmt, ...) __attribute__ ((noreturn, format (printf, 2, 3))); -void verrx(int eval, const char *fmt, va_list ap) + +void ROKEN_LIB_FUNCTION +verrx(int eval, const char *fmt, va_list ap) __attribute__ ((noreturn, format (printf, 2, 0))); -void errx(int eval, const char *fmt, ...) + +void ROKEN_LIB_FUNCTION +errx(int eval, const char *fmt, ...) __attribute__ ((noreturn, format (printf, 2, 3))); -void vwarn(const char *fmt, va_list ap) +void ROKEN_LIB_FUNCTION +vwarn(const char *fmt, va_list ap) __attribute__ ((format (printf, 1, 0))); -void warn(const char *fmt, ...) + +void ROKEN_LIB_FUNCTION +warn(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); -void vwarnx(const char *fmt, va_list ap) + +void ROKEN_LIB_FUNCTION +vwarnx(const char *fmt, va_list ap) __attribute__ ((format (printf, 1, 0))); -void warnx(const char *fmt, ...) + +void ROKEN_LIB_FUNCTION +warnx(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); #endif /* __ERR_H__ */ diff --git a/lib/roken/errx.c b/lib/roken/errx.c index da47e4da6..b26318af4 100644 --- a/lib/roken/errx.c +++ b/lib/roken/errx.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "err.h" -void +void ROKEN_LIB_FUNCTION errx(int eval, const char *fmt, ...) { va_list ap; diff --git a/lib/roken/esetenv.c b/lib/roken/esetenv.c index 66b6607ce..5950bb2a1 100644 --- a/lib/roken/esetenv.c +++ b/lib/roken/esetenv.c @@ -40,7 +40,7 @@ RCSID("$Id$"); #include -void +void ROKEN_LIB_FUNCTION esetenv(const char *var, const char *val, int rewrite) { if (setenv ((char *)var, (char *)val, rewrite)) diff --git a/lib/roken/estrdup.c b/lib/roken/estrdup.c index 86b8d415d..0c6200c4b 100644 --- a/lib/roken/estrdup.c +++ b/lib/roken/estrdup.c @@ -45,7 +45,7 @@ RCSID("$Id$"); * Like strdup but never fails. */ -char * +char * ROKEN_LIB_FUNCTION estrdup (const char *str) { char *tmp = strdup (str); diff --git a/lib/roken/ewrite.c b/lib/roken/ewrite.c index a7dc68926..d58ceb563 100644 --- a/lib/roken/ewrite.c +++ b/lib/roken/ewrite.c @@ -45,7 +45,7 @@ RCSID("$Id$"); * Like write but never fails (and never returns partial data). */ -ssize_t +ssize_t ROKEN_LIB_FUNCTION ewrite (int fd, const void *buf, size_t nbytes) { ssize_t ret; diff --git a/lib/roken/fchown.c b/lib/roken/fchown.c index 6254f3e01..e7165ef8b 100644 --- a/lib/roken/fchown.c +++ b/lib/roken/fchown.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -int +int ROKEN_LIB_FUNCTION fchown(int fd, uid_t owner, gid_t group) { return 0; diff --git a/lib/roken/flock.c b/lib/roken/flock.c index ef1136f0d..d6766a08c 100644 --- a/lib/roken/flock.c +++ b/lib/roken/flock.c @@ -43,7 +43,7 @@ RCSID("$Id$"); #define OP_MASK (LOCK_SH | LOCK_EX | LOCK_UN) -int +int ROKEN_LIB_FUNCTION flock(int fd, int operation) { #if defined(HAVE_FCNTL) && defined(F_SETLK) diff --git a/lib/roken/fnmatch.c b/lib/roken/fnmatch.c index e8bb44c87..d3620cac0 100644 --- a/lib/roken/fnmatch.c +++ b/lib/roken/fnmatch.c @@ -52,7 +52,7 @@ static char rcsid[] = "$NetBSD: fnmatch.c,v 1.11 1995/02/27 03:43:06 cgd Exp $"; static const char *rangematch (const char *, int, int); -int +int ROKEN_LIB_FUNCTION fnmatch(const char *pattern, const char *string, int flags) { const char *stringstart; diff --git a/lib/roken/fnmatch.hin b/lib/roken/fnmatch.hin index 41df392c2..47beb8d49 100644 --- a/lib/roken/fnmatch.hin +++ b/lib/roken/fnmatch.hin @@ -34,12 +34,21 @@ #ifndef _FNMATCH_H_ #define _FNMATCH_H_ +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + #define FNM_NOMATCH 1 /* Match failed. */ #define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ #define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ #define FNM_PERIOD 0x04 /* Period must be matched by period. */ -int fnmatch (const char *, const char *, int); +int ROKEN_LIB_FUNCTION +fnmatch (const char *, const char *, int); #endif /* !_FNMATCH_H_ */ diff --git a/lib/roken/freeaddrinfo.c b/lib/roken/freeaddrinfo.c index 256af90cc..a350edcca 100644 --- a/lib/roken/freeaddrinfo.c +++ b/lib/roken/freeaddrinfo.c @@ -42,7 +42,7 @@ RCSID("$Id$"); * free the list of `struct addrinfo' starting at `ai' */ -void +void ROKEN_LIB_FUNCTION freeaddrinfo(struct addrinfo *ai) { struct addrinfo *tofree; diff --git a/lib/roken/freehostent.c b/lib/roken/freehostent.c index 7fa5ac108..ca43cf10f 100644 --- a/lib/roken/freehostent.c +++ b/lib/roken/freehostent.c @@ -42,7 +42,7 @@ RCSID("$Id$"); * free a malloced hostent */ -void +void ROKEN_LIB_FUNCTION freehostent (struct hostent *h) { char **p; diff --git a/lib/roken/gai_strerror.c b/lib/roken/gai_strerror.c index d64391b11..15dbdb537 100644 --- a/lib/roken/gai_strerror.c +++ b/lib/roken/gai_strerror.c @@ -65,7 +65,7 @@ static struct gai_error { * */ -char * +char * ROKEN_LIB_FUNCTION gai_strerror(int ecode) { struct gai_error *g; diff --git a/lib/roken/get_default_username.c b/lib/roken/get_default_username.c index 8b970a76e..ef22c4982 100644 --- a/lib/roken/get_default_username.c +++ b/lib/roken/get_default_username.c @@ -43,7 +43,7 @@ RCSID("$Id$"); * NULL if we can't guess at all. */ -const char * +const char * ROKEN_LIB_FUNCTION get_default_username (void) { const char *user; diff --git a/lib/roken/get_window_size.c b/lib/roken/get_window_size.c index ae3c2bb62..053e7e4f8 100644 --- a/lib/roken/get_window_size.c +++ b/lib/roken/get_window_size.c @@ -60,7 +60,7 @@ RCSID("$Id$"); #include -int +int ROKEN_LIB_FUNCTION get_window_size(int fd, struct winsize *wp) { int ret = -1; diff --git a/lib/roken/getaddrinfo.c b/lib/roken/getaddrinfo.c index 2f50ae5fb..c766ca2cf 100644 --- a/lib/roken/getaddrinfo.c +++ b/lib/roken/getaddrinfo.c @@ -368,7 +368,7 @@ get_nodes (const char *nodename, * }; */ -int +int ROKEN_LIB_FUNCTION getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, diff --git a/lib/roken/getaddrinfo_hostspec.c b/lib/roken/getaddrinfo_hostspec.c index 67e8da01c..be21210ae 100644 --- a/lib/roken/getaddrinfo_hostspec.c +++ b/lib/roken/getaddrinfo_hostspec.c @@ -40,7 +40,7 @@ RCSID("$Id$"); /* getaddrinfo via string specifying host and port */ -int +int ROKEN_LIB_FUNCTION roken_getaddrinfo_hostspec2(const char *hostspec, int socktype, int port, @@ -95,7 +95,7 @@ roken_getaddrinfo_hostspec2(const char *hostspec, return getaddrinfo (host, portstr, &hints, ai); } -int +int ROKEN_LIB_FUNCTION roken_getaddrinfo_hostspec(const char *hostspec, int port, struct addrinfo **ai) diff --git a/lib/roken/getarg.c b/lib/roken/getarg.c index 8d1b72d7c..4455e9f1e 100644 --- a/lib/roken/getarg.c +++ b/lib/roken/getarg.c @@ -198,7 +198,7 @@ check_column(FILE *f, int col, int len, int columns) return col; } -void +void ROKEN_LIB_FUNCTION arg_printusage (struct getargs *args, size_t num_args, const char *progname, @@ -523,7 +523,7 @@ arg_match_short (struct getargs *args, size_t num_args, return 0; } -int +int ROKEN_LIB_FUNCTION getarg(struct getargs *args, size_t num_args, int argc, char **argv, int *goptind) { @@ -559,7 +559,7 @@ getarg(struct getargs *args, size_t num_args, return ret; } -void +void ROKEN_LIB_FUNCTION free_getarg_strings (getarg_strings *s) { free (s->strings); diff --git a/lib/roken/getarg.h b/lib/roken/getarg.h index 047e0e686..b5a909ef5 100644 --- a/lib/roken/getarg.h +++ b/lib/roken/getarg.h @@ -78,14 +78,17 @@ typedef struct getarg_collect_info { void *data; } getarg_collect_info; -int getarg(struct getargs *args, size_t num_args, - int argc, char **argv, int *goptind); +int ROKEN_LIB_FUNCTION +getarg(struct getargs *args, size_t num_args, + int argc, char **argv, int *goptind); -void arg_printusage (struct getargs *args, - size_t num_args, - const char *progname, - const char *extra_string); +void ROKEN_LIB_FUNCTION +arg_printusage (struct getargs *args, + size_t num_args, + const char *progname, + const char *extra_string); -void free_getarg_strings (getarg_strings *); +void ROKEN_LIB_FUNCTION +free_getarg_strings (getarg_strings *); #endif /* __GETARG_H__ */ diff --git a/lib/roken/getcap.c b/lib/roken/getcap.c index 13509be8e..016a48530 100644 --- a/lib/roken/getcap.c +++ b/lib/roken/getcap.c @@ -80,24 +80,24 @@ static int getent (char **, size_t *, char **, int, const char *, int, char *); static int nfcmp (char *, char *); -int cgetset(const char *ent); -char *cgetcap(char *buf, const char *cap, int type); -int cgetent(char **buf, char **db_array, const char *name); -int cgetmatch(const char *buf, const char *name); -int cgetclose(void); +int ROKEN_LIB_FUNCTION cgetset(const char *ent); +char *ROKEN_LIB_FUNCTION cgetcap(char *buf, const char *cap, int type); +int ROKEN_LIB_FUNCTION cgetent(char **buf, char **db_array, const char *name); +int ROKEN_LIB_FUNCTION cgetmatch(const char *buf, const char *name); +int ROKEN_LIB_FUNCTION cgetclose(void); #if 0 int cgetfirst(char **buf, char **db_array); int cgetnext(char **bp, char **db_array); #endif -int cgetstr(char *buf, const char *cap, char **str); -int cgetustr(char *buf, const char *cap, char **str); -int cgetnum(char *buf, const char *cap, long *num); +int ROKEN_LIB_FUNCTION cgetstr(char *buf, const char *cap, char **str); +int ROKEN_LIB_FUNCTION cgetustr(char *buf, const char *cap, char **str); +int ROKEN_LIB_FUNCTION cgetnum(char *buf, const char *cap, long *num); /* * Cgetset() allows the addition of a user specified buffer to be added * to the database array, in effect "pushing" the buffer on top of the * virtual database. 0 is returned on success, -1 on failure. */ -int +int ROKEN_LIB_FUNCTION cgetset(const char *ent) { const char *source, *check; @@ -150,7 +150,7 @@ cgetset(const char *ent) * If (cap, '@') or (cap, terminator, '@') is found before (cap, terminator) * return NULL. */ -char * +char * ROKEN_LIB_FUNCTION cgetcap(char *buf, const char *cap, int type) { char *bp; @@ -201,7 +201,7 @@ cgetcap(char *buf, const char *cap, int type) * encountered (couldn't open/read a file, etc.), and -3 if a potential * reference loop is detected. */ -int +int ROKEN_LIB_FUNCTION cgetent(char **buf, char **db_array, const char *name) { size_t dummy; @@ -695,7 +695,7 @@ static FILE *pfp; static int slash; static char **dbp; -int +int ROKEN_LIB_FUNCTION cgetclose(void) { if (pfp != NULL) { @@ -842,7 +842,7 @@ cgetnext(char **bp, char **db_array) * couldn't be found, -2 if a system error was encountered (storage * allocation failure). */ -int +int ROKEN_LIB_FUNCTION cgetstr(char *buf, const char *cap, char **str) { u_int m_room; @@ -966,7 +966,7 @@ cgetstr(char *buf, const char *cap, char **str) * -1 if the requested string capability couldn't be found, -2 if a system * error was encountered (storage allocation failure). */ -int +int ROKEN_LIB_FUNCTION cgetustr(char *buf, const char *cap, char **str) { u_int m_room; @@ -1035,7 +1035,7 @@ cgetustr(char *buf, const char *cap, char **str) * the long pointed to by num. 0 is returned on success, -1 if the requested * numeric capability couldn't be found. */ -int +int ROKEN_LIB_FUNCTION cgetnum(char *buf, const char *cap, long *num) { long n; diff --git a/lib/roken/getcwd.c b/lib/roken/getcwd.c index 4ecaa7491..f52b26870 100644 --- a/lib/roken/getcwd.c +++ b/lib/roken/getcwd.c @@ -45,7 +45,7 @@ RCSID("$Id$"); #include "roken.h" -char* +char* ROKEN_LIB_FUNCTION getcwd(char *path, size_t size) { char xxx[MaxPathLen]; diff --git a/lib/roken/getdtablesize.c b/lib/roken/getdtablesize.c index 999e72ca5..af40e2573 100644 --- a/lib/roken/getdtablesize.c +++ b/lib/roken/getdtablesize.c @@ -64,7 +64,8 @@ RCSID("$Id$"); #include #endif -int getdtablesize(void) +int ROKEN_LIB_FUNCTION +getdtablesize(void) { int files = -1; #if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX) diff --git a/lib/roken/getegid.c b/lib/roken/getegid.c index f73a7c0ac..05833b4c8 100644 --- a/lib/roken/getegid.c +++ b/lib/roken/getegid.c @@ -40,7 +40,8 @@ RCSID("$Id$"); -int getegid(void) +int ROKEN_LIB_FUNCTION +getegid(void) { return getgid(); } diff --git a/lib/roken/geteuid.c b/lib/roken/geteuid.c index 4c6b6c712..e6536b20d 100644 --- a/lib/roken/geteuid.c +++ b/lib/roken/geteuid.c @@ -40,7 +40,8 @@ RCSID("$Id$"); -int geteuid(void) +int ROKEN_LIB_FUNCTION +geteuid(void) { return getuid(); } diff --git a/lib/roken/getgid.c b/lib/roken/getgid.c index 590d9d93a..ee2dd92b5 100644 --- a/lib/roken/getgid.c +++ b/lib/roken/getgid.c @@ -40,7 +40,8 @@ RCSID("$Id$"); -int getgid(void) +int ROKEN_LIB_FUNCTION +getgid(void) { return 17; } diff --git a/lib/roken/gethostname.c b/lib/roken/gethostname.c index 753ba9f1b..f291ce2cb 100644 --- a/lib/roken/gethostname.c +++ b/lib/roken/gethostname.c @@ -49,7 +49,7 @@ * interface is identical to gethostname(2).) */ -int +int ROKEN_LIB_FUNCTION gethostname(char *name, int namelen) { #if defined(HAVE_UNAME) diff --git a/lib/roken/getifaddrs.c b/lib/roken/getifaddrs.c index 29ce18625..3c82eb902 100644 --- a/lib/roken/getifaddrs.c +++ b/lib/roken/getifaddrs.c @@ -466,7 +466,8 @@ nl_open(void) } /* ====================================================================== */ -int getifaddrs(struct ifaddrs **ifap) +int ROKEN_LIB_FUNCTION +getifaddrs(struct ifaddrs **ifap) { int sd; struct nlmsg_list *nlmsg_list, *nlmsg_end, *nlm; @@ -819,7 +820,7 @@ int getifaddrs(struct ifaddrs **ifap) } /* ---------------------------------------------------------------------- */ -void +void ROKEN_LIB_FUNCTION freeifaddrs(struct ifaddrs *ifa) { free(ifa); @@ -1082,7 +1083,7 @@ getlifaddrs2(struct ifaddrs **ifap, } #endif /* defined(HAVE_IPV6) && defined(SIOCGLIFCONF) && defined(SIOCGLIFFLAGS) */ -int +int ROKEN_LIB_FUNCTION getifaddrs(struct ifaddrs **ifap) { int ret = -1; @@ -1110,7 +1111,7 @@ getifaddrs(struct ifaddrs **ifap) return ret; } -void +void ROKEN_LIB_FUNCTION freeifaddrs(struct ifaddrs *ifp) { struct ifaddrs *p, *q; diff --git a/lib/roken/getipnodebyaddr.c b/lib/roken/getipnodebyaddr.c index b613a578b..69195d305 100644 --- a/lib/roken/getipnodebyaddr.c +++ b/lib/roken/getipnodebyaddr.c @@ -43,7 +43,7 @@ RCSID("$Id$"); * to a malloced struct hostent or NULL. */ -struct hostent * +struct hostent * ROKEN_LIB_FUNCTION getipnodebyaddr (const void *src, size_t len, int af, int *error_num) { struct hostent *tmp; diff --git a/lib/roken/getipnodebyname.c b/lib/roken/getipnodebyname.c index 2d893ce1f..e8f6a1fdb 100644 --- a/lib/roken/getipnodebyname.c +++ b/lib/roken/getipnodebyname.c @@ -47,7 +47,7 @@ static int h_errno = NO_RECOVERY; * to a malloced struct hostent or NULL. */ -struct hostent * +struct hostent * ROKEN_LIB_FUNCTION getipnodebyname (const char *name, int af, int flags, int *error_num) { struct hostent *tmp; diff --git a/lib/roken/getnameinfo.c b/lib/roken/getnameinfo.c index e7f8e9121..3950093f1 100644 --- a/lib/roken/getnameinfo.c +++ b/lib/roken/getnameinfo.c @@ -94,7 +94,7 @@ doit (int af, * */ -int +int ROKEN_LIB_FUNCTION getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, diff --git a/lib/roken/getnameinfo_verified.c b/lib/roken/getnameinfo_verified.c index 1e9764531..e51de8561 100644 --- a/lib/roken/getnameinfo_verified.c +++ b/lib/roken/getnameinfo_verified.c @@ -46,7 +46,7 @@ RCSID("$Id$"); * NI_NAMEREQD flag is set or return the numeric address as a string. */ -int +int ROKEN_LIB_FUNCTION getnameinfo_verified(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, diff --git a/lib/roken/getopt.c b/lib/roken/getopt.c index d935c6555..12bf138d0 100644 --- a/lib/roken/getopt.c +++ b/lib/roken/getopt.c @@ -51,7 +51,7 @@ char *optarg; /* argument associated with option */ #define BADARG (int)':' #define EMSG "" -int +int ROKEN_LIB_FUNCTION getopt(nargc, nargv, ostr) int nargc; char * const *nargv; diff --git a/lib/roken/getprogname.c b/lib/roken/getprogname.c index b8ae27899..1f365fc84 100644 --- a/lib/roken/getprogname.c +++ b/lib/roken/getprogname.c @@ -43,7 +43,7 @@ const char *__progname; #endif #ifndef HAVE_GETPROGNAME -const char * +const char * ROKEN_LIB_FUNCTION getprogname(void) { return __progname; diff --git a/lib/roken/gettimeofday.c b/lib/roken/gettimeofday.c index 46aa7a5c2..3468aef34 100644 --- a/lib/roken/gettimeofday.c +++ b/lib/roken/gettimeofday.c @@ -42,7 +42,7 @@ RCSID("$Id$"); /* * Simple gettimeofday that only returns seconds. */ -int +int ROKEN_LIB_FUNCTION gettimeofday (struct timeval *tp, void *ignore) { time_t t; diff --git a/lib/roken/getuid.c b/lib/roken/getuid.c index 4289e383b..b0b8d1649 100644 --- a/lib/roken/getuid.c +++ b/lib/roken/getuid.c @@ -40,7 +40,8 @@ RCSID("$Id$"); -int getuid(void) +int ROKEN_LIB_FUNCTION +getuid(void) { return 17; } diff --git a/lib/roken/getusershell.c b/lib/roken/getusershell.c index 6ef9cfcb1..3df17ecb9 100644 --- a/lib/roken/getusershell.c +++ b/lib/roken/getusershell.c @@ -84,7 +84,7 @@ static char **initshells (void); /* * Get a list of shells from _PATH_SHELLS, if it exists. */ -char * +char * ROKEN_LIB_FUNCTION getusershell() { char *ret; @@ -97,7 +97,7 @@ getusershell() return (ret); } -void +void ROKEN_LIB_FUNCTION endusershell() { if (shells != NULL) @@ -109,7 +109,7 @@ endusershell() curshell = NULL; } -void +void ROKEN_LIB_FUNCTION setusershell() { curshell = initshells(); diff --git a/lib/roken/glob.c b/lib/roken/glob.c index 55767ce78..803eda17d 100644 --- a/lib/roken/glob.c +++ b/lib/roken/glob.c @@ -166,7 +166,7 @@ static int match (Char *, Char *, Char *); static void qprintf (const char *, Char *); #endif -int +int ROKEN_LIB_FUNCTION glob(const char *pattern, int flags, int (*errfunc)(const char *, int), @@ -741,7 +741,7 @@ match(Char *name, Char *pat, Char *patend) } /* Free allocated data belonging to a glob_t structure. */ -void +void ROKEN_LIB_FUNCTION globfree(glob_t *pglob) { int i; diff --git a/lib/roken/glob.hin b/lib/roken/glob.hin index a86fc69f5..8e33fd49b 100644 --- a/lib/roken/glob.hin +++ b/lib/roken/glob.hin @@ -79,7 +79,10 @@ typedef struct { #define GLOB_NOSPACE (-1) /* Malloc call failed. */ #define GLOB_ABEND (-2) /* Unignored error. */ -int glob (const char *, int, int (*)(const char *, int), glob_t *); -void globfree (glob_t *); +int ROKEN_LIB_FUNCTION +glob (const char *, int, int (*)(const char *, int), glob_t *); + +void ROKEN_LIB_FUNCTION +globfree (glob_t *); #endif /* !_GLOB_H_ */ diff --git a/lib/roken/hex.c b/lib/roken/hex.c index 1f0742b91..eaa9da33b 100644 --- a/lib/roken/hex.c +++ b/lib/roken/hex.c @@ -53,7 +53,7 @@ pos(char c) return -1; } -ssize_t +ssize_t ROKEN_LIB_FUNCTION hex_encode(const void *data, size_t size, char **str) { const unsigned char *q = data; @@ -79,7 +79,7 @@ hex_encode(const void *data, size_t size, char **str) return i * 2; } -ssize_t +ssize_t ROKEN_LIB_FUNCTION hex_decode(const char *str, void *data, size_t len) { size_t l; diff --git a/lib/roken/hex.h b/lib/roken/hex.h index c44739da2..037bf650d 100644 --- a/lib/roken/hex.h +++ b/lib/roken/hex.h @@ -36,10 +36,20 @@ #ifndef _rk_HEX_H_ #define _rk_HEX_H_ 1 +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + #define hex_encode rk_hex_encode #define hex_decode rk_hex_decode -ssize_t hex_encode(const void *, size_t, char **); -ssize_t hex_decode(const char *, void *, size_t); +ssize_t ROKEN_LIB_FUNCTION + hex_encode(const void *, size_t, char **); +ssize_t ROKEN_LIB_FUNCTION + hex_decode(const char *, void *, size_t); #endif /* _rk_HEX_H_ */ diff --git a/lib/roken/hostent_find_fqdn.c b/lib/roken/hostent_find_fqdn.c index 0de88c174..60d9428cc 100644 --- a/lib/roken/hostent_find_fqdn.c +++ b/lib/roken/hostent_find_fqdn.c @@ -42,7 +42,7 @@ RCSID("$Id$"); * Try to find a fqdn (with `.') in he if possible, else return h_name */ -const char * +const char * ROKEN_LIB_FUNCTION hostent_find_fqdn (const struct hostent *he) { const char *ret = he->h_name; diff --git a/lib/roken/hstrerror.c b/lib/roken/hstrerror.c index 08d7d0862..e3ffbde82 100644 --- a/lib/roken/hstrerror.c +++ b/lib/roken/hstrerror.c @@ -67,7 +67,7 @@ extern int h_nerr; #endif -const char * +const char * ROKEN_LIB_FUNCTION hstrerror(int herr) { if (0 <= herr && herr < h_nerr) diff --git a/lib/roken/ifaddrs.hin b/lib/roken/ifaddrs.hin index a13f6e239..084dfc7b3 100644 --- a/lib/roken/ifaddrs.hin +++ b/lib/roken/ifaddrs.hin @@ -36,6 +36,14 @@ #ifndef __ifaddrs_h__ #define __ifaddrs_h__ +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + /* * the interface is defined in terms of the fields below, and this is * sometimes #define'd, so there seems to be no simple way of solving @@ -57,8 +65,10 @@ struct ifaddrs { #define ifa_broadaddr ifa_dstaddr #endif -int getifaddrs(struct ifaddrs**); +int ROKEN_LIB_FUNCTION +getifaddrs(struct ifaddrs**); -void freeifaddrs(struct ifaddrs*); +void ROKEN_LIB_FUNCTION +freeifaddrs(struct ifaddrs*); #endif /* __ifaddrs_h__ */ diff --git a/lib/roken/inet_aton.c b/lib/roken/inet_aton.c index c526126c9..79af5e57b 100644 --- a/lib/roken/inet_aton.c +++ b/lib/roken/inet_aton.c @@ -41,7 +41,7 @@ RCSID("$Id$"); /* Minimal implementation of inet_aton. * Cannot distinguish between failure and a local broadcast address. */ -int +int ROKEN_LIB_FUNCTION inet_aton(const char *cp, struct in_addr *addr) { addr->s_addr = inet_addr(cp); diff --git a/lib/roken/inet_ntop.c b/lib/roken/inet_ntop.c index 111703448..997e81245 100644 --- a/lib/roken/inet_ntop.c +++ b/lib/roken/inet_ntop.c @@ -116,7 +116,7 @@ inet_ntop_v6 (const void *src, char *dst, size_t size) } #endif /* HAVE_IPV6 */ -const char * +const char * ROKEN_LIB_FUNCTION inet_ntop(int af, const void *src, char *dst, size_t size) { switch (af) { diff --git a/lib/roken/inet_pton.c b/lib/roken/inet_pton.c index 255eaee18..2ba8419df 100644 --- a/lib/roken/inet_pton.c +++ b/lib/roken/inet_pton.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include -int +int ROKEN_LIB_FUNCTION inet_pton(int af, const char *src, void *dst) { if (af != AF_INET) { diff --git a/lib/roken/initgroups.c b/lib/roken/initgroups.c index 7fab3ff77..b8231a712 100644 --- a/lib/roken/initgroups.c +++ b/lib/roken/initgroups.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -int +int ROKEN_LIB_FUNCTION initgroups(const char *name, gid_t basegid) { return 0; diff --git a/lib/roken/innetgr.c b/lib/roken/innetgr.c index 1ecc13ebd..b36311dc9 100644 --- a/lib/roken/innetgr.c +++ b/lib/roken/innetgr.c @@ -39,7 +39,7 @@ RCSID("$Id$"); -int +int ROKEN_LIB_FUNCTION innetgr(const char *netgroup, const char *machine, const char *user, const char *domain) { diff --git a/lib/roken/iruserok.c b/lib/roken/iruserok.c index 8e6468fd5..6bf7282e3 100644 --- a/lib/roken/iruserok.c +++ b/lib/roken/iruserok.c @@ -217,7 +217,7 @@ __ivaliduser(FILE *hostf, unsigned raddr, const char *luser, * * Returns 0 if ok, -1 if not ok. */ -int +int ROKEN_LIB_FUNCTION iruserok(unsigned raddr, int superuser, const char *ruser, const char *luser) { char *cp; diff --git a/lib/roken/issuid.c b/lib/roken/issuid.c index 9e0415cd3..3b253b857 100644 --- a/lib/roken/issuid.c +++ b/lib/roken/issuid.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -int +int ROKEN_LIB_FUNCTION issuid(void) { #if defined(HAVE_ISSETUGID) diff --git a/lib/roken/k_getpwnam.c b/lib/roken/k_getpwnam.c index eb760d9d2..e3bd27ed1 100644 --- a/lib/roken/k_getpwnam.c +++ b/lib/roken/k_getpwnam.c @@ -41,7 +41,7 @@ RCSID("$Id$"); #include #endif -struct passwd * +struct passwd * ROKEN_LIB_FUNCTION k_getpwnam (const char *user) { struct passwd *p; diff --git a/lib/roken/k_getpwuid.c b/lib/roken/k_getpwuid.c index 2e065aaf2..be7528f02 100644 --- a/lib/roken/k_getpwuid.c +++ b/lib/roken/k_getpwuid.c @@ -41,7 +41,7 @@ RCSID("$Id$"); #include #endif -struct passwd * +struct passwd * ROKEN_LIB_FUNCTION k_getpwuid (uid_t uid) { struct passwd *p; diff --git a/lib/roken/localtime_r.c b/lib/roken/localtime_r.c index 36fcfc9b6..080f3bf03 100644 --- a/lib/roken/localtime_r.c +++ b/lib/roken/localtime_r.c @@ -42,7 +42,7 @@ RCSID("$Id$"); #ifndef HAVE_LOCALTIME_R -struct tm * +struct tm * ROKEN_LIB_FUNCTION localtime_r(const time_t *timer, struct tm *result) { struct tm *tm; diff --git a/lib/roken/lstat.c b/lib/roken/lstat.c index 79b497751..9295c8b3e 100644 --- a/lib/roken/lstat.c +++ b/lib/roken/lstat.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -int +int ROKEN_LIB_FUNCTION lstat(const char *path, struct stat *buf) { return stat(path, buf); diff --git a/lib/roken/memmove.c b/lib/roken/memmove.c index 4f337a0c3..7b7ff7c37 100644 --- a/lib/roken/memmove.c +++ b/lib/roken/memmove.c @@ -44,7 +44,8 @@ RCSID("$Id$"); #include #endif -void* memmove(void *s1, const void *s2, size_t n) +void* ROKEN_LIB_FUNCTION +memmove(void *s1, const void *s2, size_t n) { char *s=(char*)s2, *d=(char*)s1; diff --git a/lib/roken/mini_inetd.c b/lib/roken/mini_inetd.c index 2d328f322..df00ec960 100644 --- a/lib/roken/mini_inetd.c +++ b/lib/roken/mini_inetd.c @@ -62,7 +62,7 @@ accept_it (int s) * Listen on a specified port, emulating inetd. */ -void +void ROKEN_LIB_FUNCTION mini_inetd_addrinfo (struct addrinfo *ai) { int ret; @@ -124,7 +124,7 @@ mini_inetd_addrinfo (struct addrinfo *ai) abort (); } -void +void ROKEN_LIB_FUNCTION mini_inetd (int port) { int error; diff --git a/lib/roken/mkstemp.c b/lib/roken/mkstemp.c index a253198c5..c71f52166 100644 --- a/lib/roken/mkstemp.c +++ b/lib/roken/mkstemp.c @@ -48,7 +48,7 @@ RCSID("$Id$"); #ifndef HAVE_MKSTEMP -int +int ROKEN_LIB_FUNCTION mkstemp(char *template) { int start, i; diff --git a/lib/roken/ndbm_wrap.c b/lib/roken/ndbm_wrap.c index 532c6c9b0..fdf2fb8ca 100644 --- a/lib/roken/ndbm_wrap.c +++ b/lib/roken/ndbm_wrap.c @@ -63,7 +63,7 @@ static DBC *cursor; #define D(X) ((DB*)(X)) -void +void ROKEN_LIB_FUNCTION dbm_close (DBM *db) { #ifdef HAVE_DB3 @@ -74,7 +74,7 @@ dbm_close (DBM *db) #endif } -int +int ROKEN_LIB_FUNCTION dbm_delete (DBM *db, datum dkey) { DBT key; @@ -129,19 +129,19 @@ dbm_get (DB *db, int flags) #define DB_KEYEXIST 1 #endif -datum +datum ROKEN_LIB_FUNCTION dbm_firstkey (DBM *db) { return dbm_get(D(db), DB_FIRST); } -datum +datum ROKEN_LIB_FUNCTION dbm_nextkey (DBM *db) { return dbm_get(D(db), DB_NEXT); } -DBM* +DBM* ROKEN_LIB_FUNCTION dbm_open (const char *file, int flags, mode_t mode) { DB *db; @@ -184,7 +184,7 @@ dbm_open (const char *file, int flags, mode_t mode) return (DBM*)db; } -int +int ROKEN_LIB_FUNCTION dbm_store (DBM *db, datum dkey, datum dvalue, int flags) { int ret; @@ -204,13 +204,13 @@ dbm_store (DBM *db, datum dkey, datum dvalue, int flags) RETURN(ret); } -int +int ROKEN_LIB_FUNCTION dbm_error (DBM *db) { return 0; } -int +int ROKEN_LIB_FUNCTION dbm_clearerr (DBM *db) { return 0; diff --git a/lib/roken/ndbm_wrap.h b/lib/roken/ndbm_wrap.h index 9c15a1985..38b02bbbb 100644 --- a/lib/roken/ndbm_wrap.h +++ b/lib/roken/ndbm_wrap.h @@ -39,6 +39,14 @@ #include #include +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + #ifndef dbm_rename #define dbm_rename(X) __roken_ ## X #endif @@ -70,14 +78,14 @@ typedef struct { } DBM; #endif -int dbm_clearerr (DBM*); -void dbm_close (DBM*); -int dbm_delete (DBM*, datum); -int dbm_error (DBM*); -datum dbm_fetch (DBM*, datum); -datum dbm_firstkey (DBM*); -datum dbm_nextkey (DBM*); -DBM* dbm_open (const char*, int, mode_t); -int dbm_store (DBM*, datum, datum, int); +int ROKEN_LIB_FUNCTION dbm_clearerr (DBM*); +void ROKEN_LIB_FUNCTION dbm_close (DBM*); +int ROKEN_LIB_FUNCTION dbm_delete (DBM*, datum); +int ROKEN_LIB_FUNCTION dbm_error (DBM*); +datum ROKEN_LIB_FUNCTION dbm_fetch (DBM*, datum); +datum ROKEN_LIB_FUNCTION dbm_firstkey (DBM*); +datum ROKEN_LIB_FUNCTION dbm_nextkey (DBM*); +DBM* ROKEN_LIB_FUNCTION dbm_open (const char*, int, mode_t); +int ROKEN_LIB_FUNCTION dbm_store (DBM*, datum, datum, int); #endif /* __ndbm_wrap_h__ */ diff --git a/lib/roken/net_read.c b/lib/roken/net_read.c index ca3384541..9bbe24a2c 100644 --- a/lib/roken/net_read.c +++ b/lib/roken/net_read.c @@ -46,7 +46,7 @@ RCSID("$Id$"); * Like read but never return partial data. */ -ssize_t +ssize_t ROKEN_LIB_FUNCTION net_read (int fd, void *buf, size_t nbytes) { char *cbuf = (char *)buf; diff --git a/lib/roken/net_write.c b/lib/roken/net_write.c index f5e1d93be..8805354b5 100644 --- a/lib/roken/net_write.c +++ b/lib/roken/net_write.c @@ -46,7 +46,7 @@ RCSID("$Id$"); * Like write but never return partial data. */ -ssize_t +ssize_t ROKEN_LIB_FUNCTION net_write (int fd, const void *buf, size_t nbytes) { const char *cbuf = (const char *)buf; diff --git a/lib/roken/parse_bytes.c b/lib/roken/parse_bytes.c index 6577ab5de..2d6b81f70 100644 --- a/lib/roken/parse_bytes.c +++ b/lib/roken/parse_bytes.c @@ -59,19 +59,19 @@ static struct units bytes_short_units[] = { { NULL, 0 } }; -int +int ROKEN_LIB_FUNCTION parse_bytes (const char *s, const char *def_unit) { return parse_units (s, bytes_units, def_unit); } -int +int ROKEN_LIB_FUNCTION unparse_bytes (int t, char *s, size_t len) { return unparse_units (t, bytes_units, s, len); } -int +int ROKEN_LIB_FUNCTION unparse_bytes_short (int t, char *s, size_t len) { return unparse_units_approx (t, bytes_short_units, s, len); diff --git a/lib/roken/parse_time.c b/lib/roken/parse_time.c index 1ecb55dc7..4ae448135 100644 --- a/lib/roken/parse_time.c +++ b/lib/roken/parse_time.c @@ -53,25 +53,25 @@ static struct units time_units[] = { {NULL, 0}, }; -int +int ROKEN_LIB_FUNCTION parse_time (const char *s, const char *def_unit) { return parse_units (s, time_units, def_unit); } -size_t +size_t ROKEN_LIB_FUNCTION unparse_time (int t, char *s, size_t len) { return unparse_units (t, time_units, s, len); } -size_t +size_t ROKEN_LIB_FUNCTION unparse_time_approx (int t, char *s, size_t len) { return unparse_units_approx (t, time_units, s, len); } -void +void ROKEN_LIB_FUNCTION print_time_table (FILE *f) { print_units_table (time_units, f); diff --git a/lib/roken/parse_time.h b/lib/roken/parse_time.h index cd9d43de8..dce50772f 100644 --- a/lib/roken/parse_time.h +++ b/lib/roken/parse_time.h @@ -36,6 +36,14 @@ #ifndef __PARSE_TIME_H__ #define __PARSE_TIME_H__ +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + int parse_time (const char *s, const char *def_unit); diff --git a/lib/roken/parse_units.c b/lib/roken/parse_units.c index 93f61e7ef..f94bd8e07 100644 --- a/lib/roken/parse_units.c +++ b/lib/roken/parse_units.c @@ -152,7 +152,7 @@ acc_units(int res, int val, unsigned mult) return res + val * mult; } -int +int ROKEN_LIB_FUNCTION parse_units (const char *s, const struct units *units, const char *def_unit) { @@ -178,7 +178,7 @@ acc_flags(int res, int val, unsigned mult) return -1; } -int +int ROKEN_LIB_FUNCTION parse_flags (const char *s, const struct units *units, int orig) { @@ -248,7 +248,7 @@ update_unit_approx (int in, unsigned mult) return update_unit (in, mult); } -int +int ROKEN_LIB_FUNCTION unparse_units (int num, const struct units *units, char *s, size_t len) { return unparse_something (num, units, s, len, @@ -257,7 +257,7 @@ unparse_units (int num, const struct units *units, char *s, size_t len) "0"); } -int +int ROKEN_LIB_FUNCTION unparse_units_approx (int num, const struct units *units, char *s, size_t len) { return unparse_something (num, units, s, len, @@ -266,7 +266,7 @@ unparse_units_approx (int num, const struct units *units, char *s, size_t len) "0"); } -void +void ROKEN_LIB_FUNCTION print_units_table (const struct units *units, FILE *f) { const struct units *u, *u2; @@ -311,7 +311,7 @@ update_flag (int in, unsigned mult) return in - mult; } -int +int ROKEN_LIB_FUNCTION unparse_flags (int num, const struct units *units, char *s, size_t len) { return unparse_something (num, units, s, len, @@ -320,7 +320,7 @@ unparse_flags (int num, const struct units *units, char *s, size_t len) ""); } -void +void ROKEN_LIB_FUNCTION print_flags_table (const struct units *units, FILE *f) { const struct units *u; diff --git a/lib/roken/parse_units.h b/lib/roken/parse_units.h index c80c3fde3..2f903072c 100644 --- a/lib/roken/parse_units.h +++ b/lib/roken/parse_units.h @@ -39,33 +39,41 @@ #include #include +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + struct units { const char *name; unsigned mult; }; -int +int ROKEN_LIB_FUNCTION parse_units (const char *s, const struct units *units, const char *def_unit); -void +void ROKEN_LIB_FUNCTION print_units_table (const struct units *units, FILE *f); -int +int ROKEN_LIB_FUNCTION parse_flags (const char *s, const struct units *units, int orig); -int +int ROKEN_LIB_FUNCTION unparse_units (int num, const struct units *units, char *s, size_t len); -int +int ROKEN_LIB_FUNCTION unparse_units_approx (int num, const struct units *units, char *s, size_t len); -int +int ROKEN_LIB_FUNCTION unparse_flags (int num, const struct units *units, char *s, size_t len); -void +void ROKEN_LIB_FUNCTION print_flags_table (const struct units *units, FILE *f); #endif /* __PARSE_UNITS_H__ */ diff --git a/lib/roken/print_version.c b/lib/roken/print_version.c index baab99e82..8a6bcfeac 100644 --- a/lib/roken/print_version.c +++ b/lib/roken/print_version.c @@ -39,7 +39,7 @@ RCSID("$Id$"); #include "print_version.h" -void +void ROKEN_LIB_FUNCTION print_version(const char *progname) { const char *arg[] = VERSIONLIST; diff --git a/lib/roken/putenv.c b/lib/roken/putenv.c index e717e77b2..0b58e12bf 100644 --- a/lib/roken/putenv.c +++ b/lib/roken/putenv.c @@ -48,7 +48,7 @@ extern char **environ; * value by altering an existing variable or creating a new one. */ -int +int ROKEN_LIB_FUNCTION putenv(const char *string) { int i; diff --git a/lib/roken/rcmd.c b/lib/roken/rcmd.c index 0e86cf711..243bd4e5a 100644 --- a/lib/roken/rcmd.c +++ b/lib/roken/rcmd.c @@ -39,7 +39,7 @@ RCSID("$Id$"); #include "roken.h" #include -int +int ROKEN_LIB_FUNCTION rcmd(char **ahost, unsigned short inport, const char *locuser, diff --git a/lib/roken/readv.c b/lib/roken/readv.c index 1d6fe0717..1e0e4fc21 100644 --- a/lib/roken/readv.c +++ b/lib/roken/readv.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -ssize_t +ssize_t ROKEN_LIB_FUNCTION readv(int d, const struct iovec *iov, int iovcnt) { ssize_t ret, nb; diff --git a/lib/roken/recvmsg.c b/lib/roken/recvmsg.c index ebd100523..155e2ae5a 100644 --- a/lib/roken/recvmsg.c +++ b/lib/roken/recvmsg.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -ssize_t +ssize_t ROKEN_LIB_FUNCTION recvmsg(int s, struct msghdr *msg, int flags) { ssize_t ret, nb; diff --git a/lib/roken/resolve.c b/lib/roken/resolve.c index b145723c9..8b3ed7354 100644 --- a/lib/roken/resolve.c +++ b/lib/roken/resolve.c @@ -77,7 +77,7 @@ static struct stot{ int _resolve_debug = 0; -int +int ROKEN_LIB_FUNCTION dns_string_to_type(const char *name) { struct stot *p = stot; @@ -87,7 +87,7 @@ dns_string_to_type(const char *name) return -1; } -const char * +const char * ROKEN_LIB_FUNCTION dns_type_to_string(int type) { struct stot *p = stot; @@ -99,7 +99,7 @@ dns_type_to_string(int type) #if (defined(HAVE_RES_SEARCH) || defined(HAVE_RES_NSEARCH)) && defined(HAVE_DN_EXPAND) -void +void ROKEN_LIB_FUNCTION dns_free_data(struct dns_reply *r) { struct resource_record *rr; @@ -550,7 +550,7 @@ dns_lookup_int(const char *domain, int rr_class, int rr_type) return r; } -struct dns_reply * +struct dns_reply * ROKEN_LIB_FUNCTION dns_lookup(const char *domain, const char *type_name) { int type; @@ -580,7 +580,7 @@ compare_srv(const void *a, const void *b) #endif /* try to rearrange the srv-records by the algorithm in RFC2782 */ -void +void ROKEN_LIB_FUNCTION dns_srv_order(struct dns_reply *r) { struct resource_record **srvs, **ss, **headp; @@ -671,18 +671,18 @@ dns_srv_order(struct dns_reply *r) #else /* NOT defined(HAVE_RES_SEARCH) && defined(HAVE_DN_EXPAND) */ -struct dns_reply * +struct dns_reply * ROKEN_LIB_FUNCTION dns_lookup(const char *domain, const char *type_name) { return NULL; } -void +void ROKEN_LIB_FUNCTION dns_free_data(struct dns_reply *r) { } -void +void ROKEN_LIB_FUNCTION dns_srv_order(struct dns_reply *r) { } diff --git a/lib/roken/resolve.h b/lib/roken/resolve.h index 34cfc0eed..bf8829b36 100644 --- a/lib/roken/resolve.h +++ b/lib/roken/resolve.h @@ -36,6 +36,14 @@ #ifndef __RESOLVE_H__ #define __RESOLVE_H__ +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + typedef enum { rk_ns_t_invalid = 0, /* Cookie. */ rk_ns_t_a = 1, /* Host address. */ @@ -276,10 +284,15 @@ struct dns_reply{ }; -struct dns_reply* dns_lookup(const char *, const char *); -void dns_free_data(struct dns_reply *); -int dns_string_to_type(const char *name); -const char *dns_type_to_string(int type); -void dns_srv_order(struct dns_reply*); +struct dns_reply* ROKEN_LIB_FUNCTION + dns_lookup(const char *, const char *); +void ROKEN_LIB_FUNCTION + dns_free_data(struct dns_reply *); +int ROKEN_LIB_FUNCTION + dns_string_to_type(const char *name); +const char *ROKEN_LIB_FUNCTION + dns_type_to_string(int type); +void ROKEN_LIB_FUNCTION + dns_srv_order(struct dns_reply*); #endif /* __RESOLVE_H__ */ diff --git a/lib/roken/roken-common.h b/lib/roken/roken-common.h index be40a042a..c3d07bb45 100644 --- a/lib/roken/roken-common.h +++ b/lib/roken/roken-common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2002 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2005 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -36,6 +36,14 @@ #ifndef __ROKEN_COMMON_H__ #define __ROKEN_COMMON_H__ +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + #ifdef __cplusplus #define ROKEN_CPP_START extern "C" { #define ROKEN_CPP_END } @@ -259,88 +267,113 @@ SigAction signal(int iSig, SigAction pAction); /* BSD compatible */ #endif #endif -int ROKEN_LIB_FUNCTION simple_execve(const char*, char*const[], char*const[]); -int ROKEN_LIB_FUNCTION simple_execve_timed(const char *, char *const[], - char *const [], time_t (*)(void *), - void *, time_t); -int ROKEN_LIB_FUNCTION simple_execvp(const char*, char *const[]); -int ROKEN_LIB_FUNCTION simple_execvp_timed(const char *, char *const[], - time_t (*)(void *), void *, time_t); -int ROKEN_LIB_FUNCTION simple_execlp(const char*, ...); -int ROKEN_LIB_FUNCTION simple_execle(const char*, ...); -int ROKEN_LIB_FUNCTION simple_execl(const char *file, ...); +int ROKEN_LIB_FUNCTION +simple_execve(const char*, char*const[], char*const[]); -int ROKEN_LIB_FUNCTION wait_for_process(pid_t); -int ROKEN_LIB_FUNCTION wait_for_process_timed(pid_t, time_t (*)(void *), +int ROKEN_LIB_FUNCTION +simple_execve_timed(const char *, char *const[], + char *const [], time_t (*)(void *), + void *, time_t); +int ROKEN_LIB_FUNCTION +simple_execvp(const char*, char *const[]); + +int ROKEN_LIB_FUNCTION +simple_execvp_timed(const char *, char *const[], + time_t (*)(void *), void *, time_t); +int ROKEN_LIB_FUNCTION +simple_execlp(const char*, ...); + +int ROKEN_LIB_FUNCTION +simple_execle(const char*, ...); + +int ROKEN_LIB_FUNCTION +simple_execl(const char *file, ...); + +int ROKEN_LIB_FUNCTION +wait_for_process(pid_t); + +int ROKEN_LIB_FUNCTION +wait_for_process_timed(pid_t, time_t (*)(void *), void *, time_t); -int ROKEN_LIB_FUNCTION pipe_execv(FILE**, FILE**, FILE**, const char*, ...); +int ROKEN_LIB_FUNCTION +pipe_execv(FILE**, FILE**, FILE**, const char*, ...); -void ROKEN_LIB_FUNCTION print_version(const char *); +void ROKEN_LIB_FUNCTION +print_version(const char *); -ssize_t ROKEN_LIB_FUNCTION eread (int fd, void *buf, size_t nbytes); -ssize_t ROKEN_LIB_FUNCTION ewrite (int fd, const void *buf, size_t nbytes); +ssize_t ROKEN_LIB_FUNCTION +eread (int fd, void *buf, size_t nbytes); + +ssize_t ROKEN_LIB_FUNCTION +ewrite (int fd, const void *buf, size_t nbytes); struct hostent; -const char * +const char * ROKEN_LIB_FUNCTION hostent_find_fqdn (const struct hostent *he); -void +void ROKEN_LIB_FUNCTION esetenv(const char *var, const char *val, int rewrite); -void +void ROKEN_LIB_FUNCTION socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port); -size_t +size_t ROKEN_LIB_FUNCTION socket_addr_size (const struct sockaddr *sa); -void +void ROKEN_LIB_FUNCTION socket_set_any (struct sockaddr *sa, int af); -size_t +size_t ROKEN_LIB_FUNCTION socket_sockaddr_size (const struct sockaddr *sa); -void * +void * ROKEN_LIB_FUNCTION socket_get_address (struct sockaddr *sa); -int +int ROKEN_LIB_FUNCTION socket_get_port (const struct sockaddr *sa); -void +void ROKEN_LIB_FUNCTION socket_set_port (struct sockaddr *sa, int port); -void +void ROKEN_LIB_FUNCTION socket_set_portrange (int sock, int restr, int af); -void +void ROKEN_LIB_FUNCTION socket_set_debug (int sock); -void +void ROKEN_LIB_FUNCTION socket_set_tos (int sock, int tos); -void +void ROKEN_LIB_FUNCTION socket_set_reuseaddr (int sock, int val); -void -socket_set_no_ipsec(int sock); - -char ** +char ** ROKEN_LIB_FUNCTION vstrcollect(va_list *ap); -char ** +char ** ROKEN_LIB_FUNCTION strcollect(char *first, ...); -void timevalfix(struct timeval *t1); -void timevaladd(struct timeval *t1, const struct timeval *t2); -void timevalsub(struct timeval *t1, const struct timeval *t2); +void ROKEN_LIB_FUNCTION +timevalfix(struct timeval *t1); -char *pid_file_write (const char *progname); -void pid_file_delete (char **); +void ROKEN_LIB_FUNCTION +timevaladd(struct timeval *t1, const struct timeval *t2); -int +void ROKEN_LIB_FUNCTION +timevalsub(struct timeval *t1, const struct timeval *t2); + +char *ROKEN_LIB_FUNCTION +pid_file_write (const char *progname); + +void ROKEN_LIB_FUNCTION +pid_file_delete (char **); + +int ROKEN_LIB_FUNCTION read_environment(const char *file, char ***env); -void warnerr(int doerrno, const char *fmt, va_list ap) +void ROKEN_LIB_FUNCTION +warnerr(int doerrno, const char *fmt, va_list ap) __attribute__ ((format (printf, 2, 0))); ROKEN_CPP_END diff --git a/lib/roken/roken.h.in b/lib/roken/roken.h.in index 33c41be46..a88391f1b 100644 --- a/lib/roken/roken.h.in +++ b/lib/roken/roken.h.in @@ -1,6 +1,6 @@ /* -*- C -*- */ /* - * Copyright (c) 1995-2004 Kungliga Tekniska Högskolan + * Copyright (c) 1995-2005 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -129,17 +129,6 @@ struct sockaddr_dl; #include #endif - -#ifndef ROKEN_LIB_FUNCTION -#if defined(__BORLANDC__) -#define ROKEN_LIB_FUNCTION /* not-ready-definition-yet */ -#elif defined(_MSC_VER) -#define ROKEN_LIB_FUNCTION /* not-ready-definition-yet2 */ -#else -#define ROKEN_LIB_FUNCTION -#endif -#endif - #ifndef HAVE_SSIZE_T typedef int ssize_t; #endif @@ -153,112 +142,117 @@ ROKEN_CPP_START #endif #ifndef HAVE_PUTENV -int putenv(const char *string); +int ROKEN_LIB_FUNCTION putenv(const char *string); #endif #if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO) -int setenv(const char *var, const char *val, int rewrite); +int ROKEN_LIB_FUNCTION setenv(const char *var, const char *val, int rewrite); #endif #if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO) -void unsetenv(const char *name); +void ROKEN_LIB_FUNCTION unsetenv(const char *name); #endif #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO) -char *getusershell(void); -void endusershell(void); +char * ROKEN_LIB_FUNCTION getusershell(void); +void ROKEN_LIB_FUNCTION endusershell(void); #endif #if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO) -int snprintf (char *str, size_t sz, const char *format, ...) +int ROKEN_LIB_FUNCTION snprintf (char *str, size_t sz, const char *format, ...) __attribute__ ((format (printf, 3, 4))); #endif #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO) -int vsnprintf (char *str, size_t sz, const char *format, va_list ap) +int ROKEN_LIB_FUNCTION + vsnprintf (char *str, size_t sz, const char *format, va_list ap) __attribute__((format (printf, 3, 0))); #endif #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO) -int asprintf (char **ret, const char *format, ...) +int ROKEN_LIB_FUNCTION + asprintf (char **ret, const char *format, ...) __attribute__ ((format (printf, 2, 3))); #endif #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO) -int vasprintf (char **ret, const char *format, va_list ap) +int ROKEN_LIB_FUNCTION + vasprintf (char **ret, const char *format, va_list ap) __attribute__((format (printf, 2, 0))); #endif #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO) -int asnprintf (char **ret, size_t max_sz, const char *format, ...) +int ROKEN_LIB_FUNCTION + asnprintf (char **ret, size_t max_sz, const char *format, ...) __attribute__ ((format (printf, 3, 4))); #endif #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO) -int vasnprintf (char **ret, size_t max_sz, const char *format, va_list ap) +int ROKEN_LIB_FUNCTION + vasnprintf (char **ret, size_t max_sz, const char *format, va_list ap) __attribute__((format (printf, 3, 0))); #endif #ifndef HAVE_STRDUP -char * strdup(const char *old); +char * ROKEN_LIB_FUNCTION strdup(const char *old); #endif #if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO) -char * strndup(const char *old, size_t sz); +char * ROKEN_LIB_FUNCTION strndup(const char *old, size_t sz); #endif #ifndef HAVE_STRLWR -char * strlwr(char *); +char * ROKEN_LIB_FUNCTION strlwr(char *); #endif #ifndef HAVE_STRNLEN -size_t strnlen(const char*, size_t); +size_t ROKEN_LIB_FUNCTION strnlen(const char*, size_t); #endif #if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO) -char *strsep(char**, const char*); +char * ROKEN_LIB_FUNCTION strsep(char**, const char*); #endif #if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO) -ssize_t strsep_copy(const char**, const char*, char*, size_t); +ssize_t ROKEN_LIB_FUNCTION strsep_copy(const char**, const char*, char*, size_t); #endif #ifndef HAVE_STRCASECMP -int strcasecmp(const char *s1, const char *s2); +int ROKEN_LIB_FUNCTION strcasecmp(const char *s1, const char *s2); #endif #ifdef NEED_FCLOSE_PROTO -int fclose(FILE *); +int ROKEN_LIB_FUNCTION fclose(FILE *); #endif #ifdef NEED_STRTOK_R_PROTO -char *strtok_r(char *s1, const char *s2, char **lasts); +char * ROKEN_LIB_FUNCTION strtok_r(char *s1, const char *s2, char **lasts); #endif #ifndef HAVE_STRUPR -char * strupr(char *); +char * ROKEN_LIB_FUNCTION strupr(char *); #endif #ifndef HAVE_STRLCPY -size_t strlcpy (char *dst, const char *src, size_t dst_sz); +size_t ROKEN_LIB_FUNCTION strlcpy (char *dst, const char *src, size_t dst_sz); #endif #ifndef HAVE_STRLCAT -size_t strlcat (char *dst, const char *src, size_t dst_sz); +size_t ROKEN_LIB_FUNCTION strlcat (char *dst, const char *src, size_t dst_sz); #endif #ifndef HAVE_GETDTABLESIZE -int getdtablesize(void); +int ROKEN_LIB_FUNCTION getdtablesize(void); #endif #if !defined(HAVE_STRERROR) && !defined(strerror) -char *strerror(int eno); +char * ROKEN_LIB_FUNCTION strerror(int eno); #endif #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO) /* This causes a fatal error under Psoriasis */ #if !(defined(SunOS) && (SunOS >= 50)) -const char *hstrerror(int herr); +const char * ROKEN_LIB_FUNCTION hstrerror(int herr); #endif #endif @@ -267,116 +261,118 @@ extern int h_errno; #endif #if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO) -int inet_aton(const char *cp, struct in_addr *adr); +int ROKEN_LIB_FUNCTION inet_aton(const char *cp, struct in_addr *adr); #endif #ifndef HAVE_INET_NTOP -const char * +const char * ROKEN_LIB_FUNCTION inet_ntop(int af, const void *src, char *dst, size_t size); #endif #ifndef HAVE_INET_PTON -int +int ROKEN_LIB_FUNCTION inet_pton(int af, const char *src, void *dst); #endif #if !defined(HAVE_GETCWD) -char* getcwd(char *path, size_t size); +char* ROKEN_LIB_FUNCTION getcwd(char *path, size_t size); #endif #ifdef HAVE_PWD_H #include -struct passwd *k_getpwnam (const char *user); -struct passwd *k_getpwuid (uid_t uid); +struct passwd * ROKEN_LIB_FUNCTION k_getpwnam (const char *user); +struct passwd * ROKEN_LIB_FUNCTION k_getpwuid (uid_t uid); #endif -const char *get_default_username (void); +const char * ROKEN_LIB_FUNCTION get_default_username (void); #ifndef HAVE_SETEUID -int seteuid(uid_t euid); +int ROKEN_LIB_FUNCTION seteuid(uid_t euid); #endif #ifndef HAVE_SETEGID -int setegid(gid_t egid); +int ROKEN_LIB_FUNCTION setegid(gid_t egid); #endif #ifndef HAVE_LSTAT -int lstat(const char *path, struct stat *buf); +int ROKEN_LIB_FUNCTION lstat(const char *path, struct stat *buf); #endif #if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO) -int mkstemp(char *); +int ROKEN_LIB_FUNCTION mkstemp(char *); #endif #ifndef HAVE_CGETENT -int cgetent(char **buf, char **db_array, const char *name); -int cgetstr(char *buf, const char *cap, char **str); +int ROKEN_LIB_FUNCTION cgetent(char **buf, char **db_array, const char *name); +int ROKEN_LIB_FUNCTION cgetstr(char *buf, const char *cap, char **str); #endif #ifndef HAVE_INITGROUPS -int initgroups(const char *name, gid_t basegid); +int ROKEN_LIB_FUNCTION initgroups(const char *name, gid_t basegid); #endif #ifndef HAVE_FCHOWN -int fchown(int fd, uid_t owner, gid_t group); +int ROKEN_LIB_FUNCTION fchown(int fd, uid_t owner, gid_t group); #endif #ifndef HAVE_DAEMON -int daemon(int nochdir, int noclose); +int ROKEN_LIB_FUNCTION daemon(int nochdir, int noclose); #endif #ifndef HAVE_INNETGR -int innetgr(const char *netgroup, const char *machine, +int ROKEN_LIB_FUNCTION innetgr(const char *netgroup, const char *machine, const char *user, const char *domain); #endif #ifndef HAVE_CHOWN -int chown(const char *path, uid_t owner, gid_t group); +int ROKEN_LIB_FUNCTION chown(const char *path, uid_t owner, gid_t group); #endif #ifndef HAVE_RCMD -int rcmd(char **ahost, unsigned short inport, const char *locuser, +int ROKEN_LIB_FUNCTION + rcmd(char **ahost, unsigned short inport, const char *locuser, const char *remuser, const char *cmd, int *fd2p); #endif #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO) -int innetgr(const char*, const char*, const char*, const char*); +int ROKEN_LIB_FUNCTION innetgr(const char*, const char*, + const char*, const char*); #endif #ifndef HAVE_IRUSEROK -int iruserok(unsigned raddr, int superuser, const char *ruser, - const char *luser); +int ROKEN_LIB_FUNCTION iruserok(unsigned raddr, int superuser, + const char *ruser, const char *luser); #endif #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO) -int gethostname(char *name, int namelen); +int ROKEN_LIB_FUNCTION gethostname(char *name, int namelen); #endif #ifndef HAVE_WRITEV -ssize_t +ssize_t ROKEN_LIB_FUNCTION writev(int d, const struct iovec *iov, int iovcnt); #endif #ifndef HAVE_READV -ssize_t +ssize_t ROKEN_LIB_FUNCTION readv(int d, const struct iovec *iov, int iovcnt); #endif #ifndef HAVE_MKSTEMP -int +int ROKEN_LIB_FUNCTION mkstemp(char *template); #endif #ifndef HAVE_PIDFILE -void pidfile (const char*); +void ROKEN_LIB_FUNCTION pidfile (const char*); #endif #ifndef HAVE_BSWAP32 -unsigned int bswap32(unsigned int); +unsigned int ROKEN_LIB_FUNCTION bswap32(unsigned int); #endif #ifndef HAVE_BSWAP16 -unsigned short bswap16(unsigned short); +unsigned short ROKEN_LIB_FUNCTION bswap16(unsigned short); #endif #ifndef HAVE_FLOCK @@ -396,23 +392,24 @@ unsigned short bswap16(unsigned short); int flock(int fd, int operation); #endif /* HAVE_FLOCK */ -time_t tm2time (struct tm tm, int local); +time_t ROKEN_LIB_FUNCTION tm2time (struct tm tm, int local); -int unix_verify_user(char *user, char *password); +int ROKEN_LIB_FUNCTION unix_verify_user(char *user, char *password); -int roken_concat (char *s, size_t len, ...); +int ROKEN_LIB_FUNCTION roken_concat (char *s, size_t len, ...); -size_t roken_mconcat (char **s, size_t max_len, ...); +size_t ROKEN_LIB_FUNCTION roken_mconcat (char **s, size_t max_len, ...); -int roken_vconcat (char *s, size_t len, va_list args); +int ROKEN_LIB_FUNCTION roken_vconcat (char *s, size_t len, va_list args); -size_t roken_vmconcat (char **s, size_t max_len, va_list args); +size_t ROKEN_LIB_FUNCTION + roken_vmconcat (char **s, size_t max_len, va_list args); -ssize_t net_write (int fd, const void *buf, size_t nbytes); +ssize_t ROKEN_LIB_FUNCTION net_write (int fd, const void *buf, size_t nbytes); -ssize_t net_read (int fd, void *buf, size_t nbytes); +ssize_t ROKEN_LIB_FUNCTION net_read (int fd, void *buf, size_t nbytes); -int issuid(void); +int ROKEN_LIB_FUNCTION issuid(void); #ifndef HAVE_STRUCT_WINSIZE struct winsize { @@ -421,10 +418,10 @@ struct winsize { }; #endif -int get_window_size(int fd, struct winsize *); +int ROKEN_LIB_FUNCTION get_window_size(int fd, struct winsize *); #ifndef HAVE_VSYSLOG -void vsyslog(int pri, const char *fmt, va_list ap); +void ROKEN_LIB_FUNCTION vsyslog(int pri, const char *fmt, va_list ap); #endif #if !HAVE_DECL_OPTARG @@ -442,22 +439,22 @@ extern char **environ; #endif #ifndef HAVE_GETIPNODEBYNAME -struct hostent * +struct hostent * ROKEN_LIB_FUNCTION getipnodebyname (const char *name, int af, int flags, int *error_num); #endif #ifndef HAVE_GETIPNODEBYADDR -struct hostent * +struct hostent * ROKEN_LIB_FUNCTION getipnodebyaddr (const void *src, size_t len, int af, int *error_num); #endif #ifndef HAVE_FREEHOSTENT -void +void ROKEN_LIB_FUNCTION freehostent (struct hostent *h); #endif #ifndef HAVE_COPYHOSTENT -struct hostent * +struct hostent * ROKEN_LIB_FUNCTION copyhostent (const struct hostent *h); #endif @@ -524,7 +521,7 @@ struct addrinfo { #endif #ifndef HAVE_GETADDRINFO -int +int ROKEN_LIB_FUNCTION getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, @@ -532,53 +529,56 @@ getaddrinfo(const char *nodename, #endif #ifndef HAVE_GETNAMEINFO -int getnameinfo(const struct sockaddr *sa, socklen_t salen, +int ROKEN_LIB_FUNCTION +getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); #endif #ifndef HAVE_FREEADDRINFO -void +void ROKEN_LIB_FUNCTION freeaddrinfo(struct addrinfo *ai); #endif #ifndef HAVE_GAI_STRERROR -char * +char * ROKEN_LIB_FUNCTION gai_strerror(int ecode); #endif -int +int ROKEN_LIB_FUNCTION getnameinfo_verified(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); -int roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **); -int roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **); +int ROKEN_LIB_FUNCTION +roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **); +int ROKEN_LIB_FUNCTION +roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **); #ifndef HAVE_STRFTIME -size_t +size_t ROKEN_LIB_FUNCTION strftime (char *buf, size_t maxsize, const char *format, const struct tm *tm); #endif #ifndef HAVE_STRPTIME -char * +char * ROKEN_LIB_FUNCTION strptime (const char *buf, const char *format, struct tm *timeptr); #endif #ifndef HAVE_EMALLOC -void *emalloc (size_t); +void * ROKEN_LIB_FUNCTION emalloc (size_t); #endif #ifndef HAVE_ECALLOC -void *ecalloc(size_t num, size_t sz); +void * ROKEN_LIB_FUNCTION ecalloc(size_t num, size_t sz); #endif #ifndef HAVE_EREALLOC -void *erealloc (void *, size_t); +void * ROKEN_LIB_FUNCTION erealloc (void *, size_t); #endif #ifndef HAVE_ESTRDUP -char *estrdup (const char *); +char * ROKEN_LIB_FUNCTION estrdup (const char *); #endif /* @@ -586,9 +586,12 @@ char *estrdup (const char *); */ #if 1 -int roken_gethostby_setup(const char*, const char*); -struct hostent* roken_gethostbyname(const char*); -struct hostent* roken_gethostbyaddr(const void*, size_t, int); +int ROKEN_LIB_FUNCTION +roken_gethostby_setup(const char*, const char*); +struct hostent* ROKEN_LIB_FUNCTION +roken_gethostbyname(const char*); +struct hostent* ROKEN_LIB_FUNCTION +roken_gethostbyaddr(const void*, size_t, int); #else #ifdef GETHOSTBYNAME_PROTO_COMPATIBLE #define roken_gethostbyname(x) gethostbyname(x) @@ -622,57 +625,57 @@ struct hostent* roken_gethostbyaddr(const void*, size_t, int); #endif #ifndef HAVE_SETPROGNAME -void setprogname(const char *argv0); +void ROKEN_LIB_FUNCTION setprogname(const char *argv0); #endif #ifndef HAVE_GETPROGNAME -const char *getprogname(void); +const char * ROKEN_LIB_FUNCTION getprogname(void); #endif #if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME extern const char *__progname; #endif -void mini_inetd_addrinfo (struct addrinfo*); -void mini_inetd (int port); +void ROKEN_LIB_FUNCTION mini_inetd_addrinfo (struct addrinfo*); +void ROKEN_LIB_FUNCTION mini_inetd (int port); #ifndef HAVE_LOCALTIME_R -struct tm * +struct tm * ROKEN_LIB_FUNCTION localtime_r(const time_t *timer, struct tm *result); #endif #if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO) -int +int ROKEN_LIB_FUNCTION strsvis(char *dst, const char *src, int flag, const char *extra); #endif #if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO) -int +int ROKEN_LIB_FUNCTION strunvis(char *dst, const char *src); #endif #if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO) -int +int ROKEN_LIB_FUNCTION strvis(char *dst, const char *src, int flag); #endif #if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO) -int +int ROKEN_LIB_FUNCTION strvisx(char *dst, const char *src, size_t len, int flag); #endif #if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO) -char * +char * ROKEN_LIB_FUNCTION svis(char *dst, int c, int flag, int nextc, const char *extra); #endif #if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO) -int +int ROKEN_LIB_FUNCTION unvis(char *cp, int c, int *astate, int flag); #endif #if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO) -char * +char * ROKEN_LIB_FUNCTION vis(char *dst, int c, int flag, int nextc); #endif diff --git a/lib/roken/roken_gethostby.c b/lib/roken/roken_gethostby.c index cfa4d14a0..00a804a0b 100644 --- a/lib/roken/roken_gethostby.c +++ b/lib/roken/roken_gethostby.c @@ -107,7 +107,7 @@ split_spec(const char *spec, char **host, int *port, char **path, int def_port) } -int +int ROKEN_LIB_FUNCTION roken_gethostby_setup(const char *proxy_spec, const char *dns_spec) { char *proxy_host = NULL; @@ -220,7 +220,7 @@ roken_gethostbyname(const char *hostname) return roken_gethostby(hostname); } -struct hostent* +struct hostent* ROKEN_LIB_FUNCTION roken_gethostbyaddr(const void *addr, size_t len, int type) { struct in_addr a; diff --git a/lib/roken/rtbl.c b/lib/roken/rtbl.c index b2832feed..554cafad2 100644 --- a/lib/roken/rtbl.c +++ b/lib/roken/rtbl.c @@ -61,19 +61,19 @@ struct rtbl_data { char *column_separator; }; -rtbl_t +rtbl_t ROKEN_LIB_FUNCTION rtbl_create (void) { return calloc (1, sizeof (struct rtbl_data)); } -void +void ROKEN_LIB_FUNCTION rtbl_set_flags (rtbl_t table, unsigned int flags) { table->flags = flags; } -unsigned int +unsigned int ROKEN_LIB_FUNCTION rtbl_get_flags (rtbl_t table) { return table->flags; @@ -99,7 +99,7 @@ rtbl_get_column (rtbl_t table, const char *column) return NULL; } -void +void ROKEN_LIB_FUNCTION rtbl_destroy (rtbl_t table) { int i, j; @@ -121,7 +121,7 @@ rtbl_destroy (rtbl_t table) free (table); } -int +int ROKEN_LIB_FUNCTION rtbl_add_column_by_id (rtbl_t table, unsigned int id, const char *header, unsigned int flags) { @@ -150,13 +150,13 @@ rtbl_add_column_by_id (rtbl_t table, unsigned int id, return 0; } -int +int ROKEN_LIB_FUNCTION rtbl_add_column (rtbl_t table, const char *header, unsigned int flags) { return rtbl_add_column_by_id(table, 0, header, flags); } -int +int ROKEN_LIB_FUNCTION rtbl_new_row(rtbl_t table) { size_t max_rows = 0; @@ -196,7 +196,7 @@ column_compute_width (rtbl_t table, struct column_data *column) } /* DEPRECATED */ -int +int ROKEN_LIB_FUNCTION rtbl_set_prefix (rtbl_t table, const char *prefix) { if (table->column_prefix) @@ -207,7 +207,7 @@ rtbl_set_prefix (rtbl_t table, const char *prefix) return 0; } -int +int ROKEN_LIB_FUNCTION rtbl_set_separator (rtbl_t table, const char *separator) { if (table->column_separator) @@ -218,7 +218,7 @@ rtbl_set_separator (rtbl_t table, const char *separator) return 0; } -int +int ROKEN_LIB_FUNCTION rtbl_set_column_prefix (rtbl_t table, const char *column, const char *prefix) { @@ -234,7 +234,7 @@ rtbl_set_column_prefix (rtbl_t table, const char *column, return 0; } -int +int ROKEN_LIB_FUNCTION rtbl_set_column_affix_by_id(rtbl_t table, unsigned int id, const char *prefix, const char *suffix) { @@ -303,7 +303,7 @@ add_column_entry (struct column_data *c, const char *data) return 0; } -int +int ROKEN_LIB_FUNCTION rtbl_add_column_entry_by_id (rtbl_t table, unsigned int id, const char *data) { struct column_data *c = rtbl_get_column_by_id (table, id); @@ -314,7 +314,7 @@ rtbl_add_column_entry_by_id (rtbl_t table, unsigned int id, const char *data) return add_column_entry(c, data); } -int +int ROKEN_LIB_FUNCTION rtbl_add_column_entry (rtbl_t table, const char *column, const char *data) { struct column_data *c = rtbl_get_column (table, column); @@ -325,7 +325,7 @@ rtbl_add_column_entry (rtbl_t table, const char *column, const char *data) return add_column_entry(c, data); } -int +int ROKEN_LIB_FUNCTION rtbl_format (rtbl_t table, FILE * f) { int i, j; diff --git a/lib/roken/rtbl.h b/lib/roken/rtbl.h index 3ac34c443..9c482e161 100644 --- a/lib/roken/rtbl.h +++ b/lib/roken/rtbl.h @@ -35,6 +35,14 @@ #ifndef __rtbl_h__ #define __rtbl_h__ +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + struct rtbl_data; typedef struct rtbl_data *rtbl_t; @@ -44,32 +52,46 @@ typedef struct rtbl_data *rtbl_t; /* flags */ #define RTBL_HEADER_STYLE_NONE 1 -int rtbl_add_column (rtbl_t, const char*, unsigned int); +int ROKEN_LIB_FUNCTION +rtbl_add_column (rtbl_t, const char*, unsigned int); -int rtbl_add_column_by_id (rtbl_t, unsigned int, const char*, unsigned int); +int ROKEN_LIB_FUNCTION +rtbl_add_column_by_id (rtbl_t, unsigned int, const char*, unsigned int); -int rtbl_add_column_entry (rtbl_t, const char*, const char*); +int ROKEN_LIB_FUNCTION +rtbl_add_column_entry (rtbl_t, const char*, const char*); -int rtbl_add_column_entry_by_id (rtbl_t, unsigned int, const char*); +int ROKEN_LIB_FUNCTION +rtbl_add_column_entry_by_id (rtbl_t, unsigned int, const char*); -rtbl_t rtbl_create (void); +rtbl_t ROKEN_LIB_FUNCTION +rtbl_create (void); -void rtbl_destroy (rtbl_t); +void ROKEN_LIB_FUNCTION +rtbl_destroy (rtbl_t); -int rtbl_format (rtbl_t, FILE*); +int ROKEN_LIB_FUNCTION +rtbl_format (rtbl_t, FILE*); -unsigned int rtbl_get_flags (rtbl_t); +unsigned int ROKEN_LIB_FUNCTION +rtbl_get_flags (rtbl_t); -int rtbl_new_row (rtbl_t); +int ROKEN_LIB_FUNCTION +rtbl_new_row (rtbl_t); -int rtbl_set_column_affix_by_id (rtbl_t, unsigned int, const char*, const char*); +int ROKEN_LIB_FUNCTION +rtbl_set_column_affix_by_id (rtbl_t, unsigned int, const char*, const char*); -int rtbl_set_column_prefix (rtbl_t, const char*, const char*); +int ROKEN_LIB_FUNCTION +rtbl_set_column_prefix (rtbl_t, const char*, const char*); -void rtbl_set_flags (rtbl_t, unsigned int); +void ROKEN_LIB_FUNCTION +rtbl_set_flags (rtbl_t, unsigned int); -int rtbl_set_prefix (rtbl_t, const char*); +int ROKEN_LIB_FUNCTION +rtbl_set_prefix (rtbl_t, const char*); -int rtbl_set_separator (rtbl_t, const char*); +int ROKEN_LIB_FUNCTION +rtbl_set_separator (rtbl_t, const char*); #endif /* __rtbl_h__ */ diff --git a/lib/roken/sendmsg.c b/lib/roken/sendmsg.c index fab91bcd2..2f2d01323 100644 --- a/lib/roken/sendmsg.c +++ b/lib/roken/sendmsg.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -ssize_t +ssize_t ROKEN_LIB_FUNCTION sendmsg(int s, const struct msghdr *msg, int flags) { ssize_t ret; diff --git a/lib/roken/setegid.c b/lib/roken/setegid.c index 8ec137a21..4c6fc890e 100644 --- a/lib/roken/setegid.c +++ b/lib/roken/setegid.c @@ -42,7 +42,7 @@ RCSID("$Id$"); #include "roken.h" -int +int ROKEN_LIB_FUNCTION setegid(gid_t egid) { #ifdef HAVE_SETREGID diff --git a/lib/roken/setenv.c b/lib/roken/setenv.c index 3b68ff643..0d0b88425 100644 --- a/lib/roken/setenv.c +++ b/lib/roken/setenv.c @@ -47,7 +47,7 @@ RCSID("$Id$"); * anyway. */ -int +int ROKEN_LIB_FUNCTION setenv(const char *var, const char *val, int rewrite) { char *t; diff --git a/lib/roken/seteuid.c b/lib/roken/seteuid.c index 2c3ca1dd6..71eda7f35 100644 --- a/lib/roken/seteuid.c +++ b/lib/roken/seteuid.c @@ -42,7 +42,7 @@ RCSID("$Id$"); #include "roken.h" -int +int ROKEN_LIB_FUNCTION seteuid(uid_t euid) { #ifdef HAVE_SETREUID diff --git a/lib/roken/setprogname.c b/lib/roken/setprogname.c index 0453383ba..7ba6b6c19 100644 --- a/lib/roken/setprogname.c +++ b/lib/roken/setprogname.c @@ -43,7 +43,7 @@ extern const char *__progname; #endif #ifndef HAVE_SETPROGNAME -void +void ROKEN_LIB_FUNCTION setprogname(const char *argv0) { #ifndef HAVE___PROGNAME diff --git a/lib/roken/signal.c b/lib/roken/signal.c index aac3784be..f38de50f6 100644 --- a/lib/roken/signal.c +++ b/lib/roken/signal.c @@ -50,7 +50,7 @@ RCSID("$Id$"); * Do we need any extra hacks for SIGCLD and/or SIGCHLD? */ -SigAction +SigAction ROKEN_LIB_FUNCTION signal(int iSig, SigAction pAction) { struct sigaction saNew, saOld; diff --git a/lib/roken/simple_exec.c b/lib/roken/simple_exec.c index dbf5830ca..cc3c5b47c 100644 --- a/lib/roken/simple_exec.c +++ b/lib/roken/simple_exec.c @@ -81,7 +81,7 @@ sigtimeout(int sig) SIGRETURN(0); } -int +int ROKEN_LIB_FUNCTION wait_for_process_timed(pid_t pid, time_t (*func)(void *), void *ptr, time_t timeout) { @@ -137,13 +137,13 @@ wait_for_process_timed(pid_t pid, time_t (*func)(void *), return ret; } -int +int ROKEN_LIB_FUNCTION wait_for_process(pid_t pid) { return wait_for_process_timed(pid, NULL, NULL, 0); } -int +int ROKEN_LIB_FUNCTION pipe_execv(FILE **stdin_fd, FILE **stdout_fd, FILE **stderr_fd, const char *file, ...) { @@ -230,7 +230,7 @@ pipe_execv(FILE **stdin_fd, FILE **stdout_fd, FILE **stderr_fd, return pid; } -int +int ROKEN_LIB_FUNCTION simple_execvp_timed(const char *file, char *const args[], time_t (*func)(void *), void *ptr, time_t timeout) { @@ -246,14 +246,14 @@ simple_execvp_timed(const char *file, char *const args[], } } -int +int ROKEN_LIB_FUNCTION simple_execvp(const char *file, char *const args[]) { return simple_execvp_timed(file, args, NULL, NULL, 0); } /* gee, I'd like a execvpe */ -int +int ROKEN_LIB_FUNCTION simple_execve_timed(const char *file, char *const args[], char *const envp[], time_t (*func)(void *), void *ptr, time_t timeout) { @@ -269,13 +269,13 @@ simple_execve_timed(const char *file, char *const args[], char *const envp[], } } -int +int ROKEN_LIB_FUNCTION simple_execve(const char *file, char *const args[], char *const envp[]) { return simple_execve_timed(file, args, envp, NULL, NULL, 0); } -int +int ROKEN_LIB_FUNCTION simple_execlp(const char *file, ...) { va_list ap; @@ -292,7 +292,7 @@ simple_execlp(const char *file, ...) return ret; } -int +int ROKEN_LIB_FUNCTION simple_execle(const char *file, ... /* ,char *const envp[] */) { va_list ap; @@ -311,7 +311,7 @@ simple_execle(const char *file, ... /* ,char *const envp[] */) return ret; } -int +int ROKEN_LIB_FUNCTION simple_execl(const char *file, ...) { va_list ap; diff --git a/lib/roken/snprintf.c b/lib/roken/snprintf.c index 2ecf8c23a..927e90330 100644 --- a/lib/roken/snprintf.c +++ b/lib/roken/snprintf.c @@ -530,7 +530,7 @@ xyzprintf (struct snprintf_state *state, const char *char_format, va_list ap) } #if !defined(HAVE_SNPRINTF) || defined(TEST_SNPRINTF) -int +int ROKEN_LIB_FUNCTION snprintf (char *str, size_t sz, const char *format, ...) { va_list args; @@ -563,7 +563,7 @@ snprintf (char *str, size_t sz, const char *format, ...) #endif #if !defined(HAVE_ASPRINTF) || defined(TEST_SNPRINTF) -int +int ROKEN_LIB_FUNCTION asprintf (char **ret, const char *format, ...) { va_list args; @@ -595,7 +595,7 @@ asprintf (char **ret, const char *format, ...) #endif #if !defined(HAVE_ASNPRINTF) || defined(TEST_SNPRINTF) -int +int ROKEN_LIB_FUNCTION asnprintf (char **ret, size_t max_sz, const char *format, ...) { va_list args; @@ -625,7 +625,7 @@ asnprintf (char **ret, size_t max_sz, const char *format, ...) #endif #if !defined(HAVE_VASPRINTF) || defined(TEST_SNPRINTF) -int +int ROKEN_LIB_FUNCTION vasprintf (char **ret, const char *format, va_list args) { return vasnprintf (ret, 0, format, args); @@ -634,7 +634,7 @@ vasprintf (char **ret, const char *format, va_list args) #if !defined(HAVE_VASNPRINTF) || defined(TEST_SNPRINTF) -int +int ROKEN_LIB_FUNCTION vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) { int st; @@ -673,7 +673,7 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) #endif #if !defined(HAVE_VSNPRINTF) || defined(TEST_SNPRINTF) -int +int ROKEN_LIB_FUNCTION vsnprintf (char *str, size_t sz, const char *format, va_list args) { struct snprintf_state state; diff --git a/lib/roken/socket.c b/lib/roken/socket.c index ebb9936e6..e8862def3 100644 --- a/lib/roken/socket.c +++ b/lib/roken/socket.c @@ -43,7 +43,7 @@ RCSID("$Id$"); * Set `sa' to the unitialized address of address family `af' */ -void +void ROKEN_LIB_FUNCTION socket_set_any (struct sockaddr *sa, int af) { switch (af) { @@ -77,7 +77,7 @@ socket_set_any (struct sockaddr *sa, int af) * set `sa' to (`ptr', `port') */ -void +void ROKEN_LIB_FUNCTION socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port) { switch (sa->sa_family) { @@ -111,7 +111,7 @@ socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port) * Return the size of an address of the type in `sa' */ -size_t +size_t ROKEN_LIB_FUNCTION socket_addr_size (const struct sockaddr *sa) { switch (sa->sa_family) { @@ -131,7 +131,7 @@ socket_addr_size (const struct sockaddr *sa) * Return the size of a `struct sockaddr' in `sa'. */ -size_t +size_t ROKEN_LIB_FUNCTION socket_sockaddr_size (const struct sockaddr *sa) { switch (sa->sa_family) { @@ -151,7 +151,7 @@ socket_sockaddr_size (const struct sockaddr *sa) * Return the binary address of `sa'. */ -void * +void * ROKEN_LIB_FUNCTION socket_get_address (struct sockaddr *sa) { switch (sa->sa_family) { @@ -175,7 +175,7 @@ socket_get_address (struct sockaddr *sa) * Return the port number from `sa'. */ -int +int ROKEN_LIB_FUNCTION socket_get_port (const struct sockaddr *sa) { switch (sa->sa_family) { @@ -199,7 +199,7 @@ socket_get_port (const struct sockaddr *sa) * Set the port in `sa' to `port'. */ -void +void ROKEN_LIB_FUNCTION socket_set_port (struct sockaddr *sa, int port) { switch (sa->sa_family) { @@ -224,7 +224,7 @@ socket_set_port (struct sockaddr *sa, int port) /* * Set the range of ports to use when binding with port = 0. */ -void +void ROKEN_LIB_FUNCTION socket_set_portrange (int sock, int restr, int af) { #if defined(IP_PORTRANGE) @@ -250,7 +250,7 @@ socket_set_portrange (int sock, int restr, int af) * Enable debug on `sock'. */ -void +void ROKEN_LIB_FUNCTION socket_set_debug (int sock) { #if defined(SO_DEBUG) && defined(HAVE_SETSOCKOPT) @@ -265,7 +265,7 @@ socket_set_debug (int sock) * Set the type-of-service of `sock' to `tos'. */ -void +void ROKEN_LIB_FUNCTION socket_set_tos (int sock, int tos) { #if defined(IP_TOS) && defined(HAVE_SETSOCKOPT) @@ -279,7 +279,7 @@ socket_set_tos (int sock, int tos) * set the reuse of addresses on `sock' to `val'. */ -void +void ROKEN_LIB_FUNCTION socket_set_reuseaddr (int sock, int val) { #if defined(SO_REUSEADDR) && defined(HAVE_SETSOCKOPT) diff --git a/lib/roken/strcasecmp.c b/lib/roken/strcasecmp.c index b2425c989..e2cb2b40e 100644 --- a/lib/roken/strcasecmp.c +++ b/lib/roken/strcasecmp.c @@ -43,7 +43,7 @@ RCSID("$Id$"); #ifndef HAVE_STRCASECMP -int +int ROKEN_LIB_FUNCTION strcasecmp(const char *s1, const char *s2) { while(toupper((unsigned char)*s1) == toupper((unsigned char)*s2)) { diff --git a/lib/roken/strcollect.c b/lib/roken/strcollect.c index 9c7beec81..ad08f3ba4 100644 --- a/lib/roken/strcollect.c +++ b/lib/roken/strcollect.c @@ -69,7 +69,7 @@ sub (char **argv, int i, int argc, va_list *ap) * terminated by NULL. */ -char ** +char ** ROKEN_LIB_FUNCTION vstrcollect(va_list *ap) { return sub (NULL, 0, 0, ap); @@ -79,7 +79,7 @@ vstrcollect(va_list *ap) * */ -char ** +char ** ROKEN_LIB_FUNCTION strcollect(char *first, ...) { va_list ap; diff --git a/lib/roken/strdup.c b/lib/roken/strdup.c index 522177fa9..f51175c83 100644 --- a/lib/roken/strdup.c +++ b/lib/roken/strdup.c @@ -39,7 +39,7 @@ RCSID("$Id$"); #include #ifndef HAVE_STRDUP -char * +char * ROKEN_LIB_FUNCTION strdup(const char *old) { char *t = malloc(strlen(old)+1); diff --git a/lib/roken/strerror.c b/lib/roken/strerror.c index 3b888dcdb..71d4a8856 100644 --- a/lib/roken/strerror.c +++ b/lib/roken/strerror.c @@ -43,7 +43,7 @@ RCSID("$Id$"); extern int sys_nerr; extern char *sys_errlist[]; -char* +char* ROKEN_LIB_FUNCTION strerror(int eno) { static char emsg[1024]; diff --git a/lib/roken/strftime.c b/lib/roken/strftime.c index 74a962262..8681d1b86 100644 --- a/lib/roken/strftime.c +++ b/lib/roken/strftime.c @@ -167,7 +167,7 @@ week_number_mon4 (const struct tm *tm) * */ -size_t +size_t ROKEN_LIB_FUNCTION strftime (char *buf, size_t maxsize, const char *format, const struct tm *tm) { diff --git a/lib/roken/strlcat.c b/lib/roken/strlcat.c index 54bbb4f06..032f9a388 100644 --- a/lib/roken/strlcat.c +++ b/lib/roken/strlcat.c @@ -40,7 +40,7 @@ RCSID("$Id$"); #ifndef HAVE_STRLCAT -size_t +size_t ROKEN_LIB_FUNCTION strlcat (char *dst, const char *src, size_t dst_sz) { size_t len = strlen(dst); diff --git a/lib/roken/strlcpy.c b/lib/roken/strlcpy.c index 83695922b..2509aedd7 100644 --- a/lib/roken/strlcpy.c +++ b/lib/roken/strlcpy.c @@ -40,7 +40,7 @@ RCSID("$Id$"); #ifndef HAVE_STRLCPY -size_t +size_t ROKEN_LIB_FUNCTION strlcpy (char *dst, const char *src, size_t dst_sz) { size_t n; diff --git a/lib/roken/strlwr.c b/lib/roken/strlwr.c index f60a17b9b..e74f1c12c 100644 --- a/lib/roken/strlwr.c +++ b/lib/roken/strlwr.c @@ -41,7 +41,7 @@ RCSID("$Id$"); #include #ifndef HAVE_STRLWR -char * +char * ROKEN_LIB_FUNCTION strlwr(char *str) { char *s; diff --git a/lib/roken/strncasecmp.c b/lib/roken/strncasecmp.c index ed2f475c2..8cc9f2ba1 100644 --- a/lib/roken/strncasecmp.c +++ b/lib/roken/strncasecmp.c @@ -42,7 +42,7 @@ RCSID("$Id$"); #ifndef HAVE_STRNCASECMP -int +int ROKEN_LIB_FUNCTION strncasecmp(const char *s1, const char *s2, size_t n) { while(n > 0 diff --git a/lib/roken/strndup.c b/lib/roken/strndup.c index 60fbe36f8..cf34051f9 100644 --- a/lib/roken/strndup.c +++ b/lib/roken/strndup.c @@ -41,7 +41,7 @@ RCSID("$Id$"); #include #ifndef HAVE_STRNDUP -char * +char * ROKEN_LIB_FUNCTION strndup(const char *old, size_t sz) { size_t len = strnlen (old, sz); diff --git a/lib/roken/strnlen.c b/lib/roken/strnlen.c index b5214e579..53d99ed17 100644 --- a/lib/roken/strnlen.c +++ b/lib/roken/strnlen.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -size_t +size_t ROKEN_LIB_FUNCTION strnlen(const char *s, size_t len) { size_t i; diff --git a/lib/roken/strptime.c b/lib/roken/strptime.c index 84bb57207..1af4cb84a 100644 --- a/lib/roken/strptime.c +++ b/lib/roken/strptime.c @@ -204,7 +204,7 @@ set_week_number_mon4 (struct tm *timeptr, int wnum) * */ -char * +char * ROKEN_LIB_FUNCTION strptime (const char *buf, const char *format, struct tm *timeptr) { char c; diff --git a/lib/roken/strsep.c b/lib/roken/strsep.c index f873cbcd2..93acf0c80 100644 --- a/lib/roken/strsep.c +++ b/lib/roken/strsep.c @@ -42,7 +42,7 @@ RCSID("$Id$"); #ifndef HAVE_STRSEP -char * +char * ROKEN_LIB_FUNCTION strsep(char **str, const char *delim) { char *save = *str; diff --git a/lib/roken/strsep_copy.c b/lib/roken/strsep_copy.c index ace41f688..34117d2c0 100644 --- a/lib/roken/strsep_copy.c +++ b/lib/roken/strsep_copy.c @@ -44,7 +44,7 @@ RCSID("$Id$"); /* strsep, but with const stringp, so return string in buf */ -ssize_t +ssize_t ROKEN_LIB_FUNCTION strsep_copy(const char **stringp, const char *delim, char *buf, size_t len) { const char *save = *stringp; diff --git a/lib/roken/strtok_r.c b/lib/roken/strtok_r.c index 4c15ce5c0..59c25063e 100644 --- a/lib/roken/strtok_r.c +++ b/lib/roken/strtok_r.c @@ -42,7 +42,7 @@ RCSID("$Id$"); #ifndef HAVE_STRTOK_R -char * +char * ROKEN_LIB_FUNCTION strtok_r(char *s1, const char *s2, char **lasts) { char *ret; diff --git a/lib/roken/strupr.c b/lib/roken/strupr.c index 1f617e306..4dc06676a 100644 --- a/lib/roken/strupr.c +++ b/lib/roken/strupr.c @@ -41,7 +41,7 @@ RCSID("$Id$"); #include #ifndef HAVE_STRUPR -char * +char * ROKEN_LIB_FUNCTION strupr(char *str) { char *s; diff --git a/lib/roken/swab.c b/lib/roken/swab.c index 6847f2b4a..91ce2cab4 100644 --- a/lib/roken/swab.c +++ b/lib/roken/swab.c @@ -40,7 +40,7 @@ RCSID("$Id$"); -void +void ROKEN_LIB_FUNCTION swab (char *from, char *to, int nbytes) { while(nbytes >= 2) { diff --git a/lib/roken/test-mem.c b/lib/roken/test-mem.c index 9980925dd..2ac05f0ae 100644 --- a/lib/roken/test-mem.c +++ b/lib/roken/test-mem.c @@ -84,7 +84,7 @@ segv_handler(int sig) errx(1, "malloc"); -void * +void * ROKEN_LIB_FUNCTION rk_test_mem_alloc(enum rk_test_mem_type type, const char *name, void *buf, size_t size) { @@ -164,7 +164,7 @@ rk_test_mem_alloc(enum rk_test_mem_type type, const char *name, return map.data_start; } -void +void ROKEN_LIB_FUNCTION rk_test_mem_free(const char *map_name) { #ifndef HAVE_MMAP diff --git a/lib/roken/test-mem.h b/lib/roken/test-mem.h index 589326afc..896222f8d 100644 --- a/lib/roken/test-mem.h +++ b/lib/roken/test-mem.h @@ -33,5 +33,7 @@ enum rk_test_mem_type { RK_TM_OVERRUN, RK_TM_UNDERRUN }; -void * rk_test_mem_alloc(enum rk_test_mem_type, const char *, void *, size_t); -void rk_test_mem_free(const char *); +void * ROKEN_LIB_FUNCTION + rk_test_mem_alloc(enum rk_test_mem_type, const char *, void *, size_t); +void ROKEN_LIB_FUNCTION + rk_test_mem_free(const char *); diff --git a/lib/roken/timeval.c b/lib/roken/timeval.c index 90f3b7213..a2fe29aeb 100644 --- a/lib/roken/timeval.c +++ b/lib/roken/timeval.c @@ -46,7 +46,7 @@ RCSID("$Id$"); * Make `t1' consistent. */ -void +void ROKEN_LIB_FUNCTION timevalfix(struct timeval *t1) { if (t1->tv_usec < 0) { @@ -63,7 +63,7 @@ timevalfix(struct timeval *t1) * t1 += t2 */ -void +void ROKEN_LIB_FUNCTION timevaladd(struct timeval *t1, const struct timeval *t2) { t1->tv_sec += t2->tv_sec; @@ -75,7 +75,7 @@ timevaladd(struct timeval *t1, const struct timeval *t2) * t1 -= t2 */ -void +void ROKEN_LIB_FUNCTION timevalsub(struct timeval *t1, const struct timeval *t2) { t1->tv_sec -= t2->tv_sec; diff --git a/lib/roken/tm2time.c b/lib/roken/tm2time.c index 86861453c..d6d0f6095 100644 --- a/lib/roken/tm2time.c +++ b/lib/roken/tm2time.c @@ -46,7 +46,7 @@ RCSID("$Id$"); #endif #include "roken.h" -time_t +time_t ROKEN_LIB_FUNCTION tm2time (struct tm tm, int local) { time_t t; diff --git a/lib/roken/unsetenv.c b/lib/roken/unsetenv.c index 45a277b47..ba7c032a2 100644 --- a/lib/roken/unsetenv.c +++ b/lib/roken/unsetenv.c @@ -46,7 +46,7 @@ extern char **environ; /* * unsetenv -- */ -void +void ROKEN_LIB_FUNCTION unsetenv(const char *name) { int len; diff --git a/lib/roken/unvis.c b/lib/roken/unvis.c index f4275b7e6..3cf32b603 100644 --- a/lib/roken/unvis.c +++ b/lib/roken/unvis.c @@ -86,7 +86,7 @@ __warn_references(unvis, * unvis - decode characters previously encoded by vis */ #ifndef HAVE_UNVIS -int +int ROKEN_LIB_FUNCTION unvis(char *cp, int c, int *astate, int flag) { @@ -250,7 +250,7 @@ unvis(char *cp, int c, int *astate, int flag) */ #ifndef HAVE_STRUNVIS -int +int ROKEN_LIB_FUNCTION strunvis(char *dst, const char *src) { char c; diff --git a/lib/roken/verify.c b/lib/roken/verify.c index f9eab9663..5285eda4b 100644 --- a/lib/roken/verify.c +++ b/lib/roken/verify.c @@ -45,7 +45,7 @@ RCSID("$Id$"); #endif #include "roken.h" -int +int ROKEN_LIB_FUNCTION unix_verify_user(char *user, char *password) { struct passwd *pw; diff --git a/lib/roken/verr.c b/lib/roken/verr.c index e2e510b2f..6da7451ee 100644 --- a/lib/roken/verr.c +++ b/lib/roken/verr.c @@ -39,7 +39,7 @@ RCSID("$Id$"); #include "roken.h" #include -void +void ROKEN_LIB_FUNCTION verr(int eval, const char *fmt, va_list ap) { warnerr(1, fmt, ap); diff --git a/lib/roken/verrx.c b/lib/roken/verrx.c index 0fcbf3f93..68dea057e 100644 --- a/lib/roken/verrx.c +++ b/lib/roken/verrx.c @@ -39,7 +39,7 @@ RCSID("$Id$"); #include "roken.h" #include -void +void ROKEN_LIB_FUNCTION verrx(int eval, const char *fmt, va_list ap) { warnerr(0, fmt, ap); diff --git a/lib/roken/vis.c b/lib/roken/vis.c index 798bb833c..2ab1845f7 100644 --- a/lib/roken/vis.c +++ b/lib/roken/vis.c @@ -209,7 +209,7 @@ do { \ * pointed to by `extra' */ #ifndef HAVE_SVIS -char * +char * ROKEN_LIB_FUNCTION svis(char *dst, int c, int flag, int nextc, const char *extra) { _DIAGASSERT(dst != NULL); @@ -238,7 +238,7 @@ svis(char *dst, int c, int flag, int nextc, const char *extra) * This is useful for encoding a block of data. */ #ifndef HAVE_STRSVIS -int +int ROKEN_LIB_FUNCTION strsvis(char *dst, const char *src, int flag, const char *extra) { char c; @@ -257,7 +257,7 @@ strsvis(char *dst, const char *src, int flag, const char *extra) #ifndef HAVE_STRVISX -int +int ROKEN_LIB_FUNCTION strsvisx(char *dst, const char *src, size_t len, int flag, const char *extra) { char c; @@ -281,7 +281,7 @@ strsvisx(char *dst, const char *src, size_t len, int flag, const char *extra) * vis - visually encode characters */ #ifndef HAVE_VIS -char * +char * ROKEN_LIB_FUNCTION vis(char *dst, int c, int flag, int nextc) { char extra[MAXEXTRAS]; @@ -307,7 +307,7 @@ vis(char *dst, int c, int flag, int nextc) * This is useful for encoding a block of data. */ #ifndef HAVE_STRVIS -int +int ROKEN_LIB_FUNCTION strvis(char *dst, const char *src, int flag) { char extra[MAXEXTRAS]; @@ -319,7 +319,7 @@ strvis(char *dst, const char *src, int flag) #ifndef HAVE_STRVISX -int +int ROKEN_LIB_FUNCTION strvisx(char *dst, const char *src, size_t len, int flag) { char extra[MAXEXTRAS]; diff --git a/lib/roken/vis.hin b/lib/roken/vis.hin index fe8b69ab7..edc3bf131 100644 --- a/lib/roken/vis.hin +++ b/lib/roken/vis.hin @@ -35,6 +35,14 @@ #ifndef _VIS_H_ #define _VIS_H_ +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION _stdcall +#else +#define ROKEN_LIB_FUNCTION +#endif +#endif + /* * to select alternate encoding format */ @@ -70,13 +78,21 @@ */ #define UNVIS_END 1 /* no more characters */ -char *vis (char *, int, int, int); -char *svis (char *, int, int, int, const char *); -int strvis (char *, const char *, int); -int strsvis (char *, const char *, int, const char *); -int strvisx (char *, const char *, size_t, int); -int strsvisx (char *, const char *, size_t, int, const char *); -int strunvis (char *, const char *); -int unvis (char *, int, int *, int); +char ROKEN_LIB_FUNCTION + *vis (char *, int, int, int); +char ROKEN_LIB_FUNCTION + *svis (char *, int, int, int, const char *); +int ROKEN_LIB_FUNCTION + strvis (char *, const char *, int); +int ROKEN_LIB_FUNCTION + strsvis (char *, const char *, int, const char *); +int ROKEN_LIB_FUNCTION + strvisx (char *, const char *, size_t, int); +int ROKEN_LIB_FUNCTION + strsvisx (char *, const char *, size_t, int, const char *); +int ROKEN_LIB_FUNCTION + strunvis (char *, const char *); +int ROKEN_LIB_FUNCTION + unvis (char *, int, int *, int); #endif /* !_VIS_H_ */ diff --git a/lib/roken/vsyslog.c b/lib/roken/vsyslog.c index 2ba1eedc8..4d47f288c 100644 --- a/lib/roken/vsyslog.c +++ b/lib/roken/vsyslog.c @@ -61,7 +61,7 @@ simple_vsyslog(int pri, const char *fmt, va_list ap) * do like syslog but with a `va_list' */ -void +void ROKEN_LIB_FUNCTION vsyslog(int pri, const char *fmt, va_list ap) { char *fmt2; diff --git a/lib/roken/vwarn.c b/lib/roken/vwarn.c index 4f84ddfde..b3ffffe77 100644 --- a/lib/roken/vwarn.c +++ b/lib/roken/vwarn.c @@ -39,7 +39,7 @@ RCSID("$Id$"); #include "roken.h" #include -void +void ROKEN_LIB_FUNCTION vwarn(const char *fmt, va_list ap) { warnerr(1, fmt, ap); diff --git a/lib/roken/vwarnx.c b/lib/roken/vwarnx.c index 43e0b3e0c..fd6310f52 100644 --- a/lib/roken/vwarnx.c +++ b/lib/roken/vwarnx.c @@ -39,7 +39,7 @@ RCSID("$Id$"); #include "roken.h" #include -void +void ROKEN_LIB_FUNCTION vwarnx(const char *fmt, va_list ap) { warnerr(0, fmt, ap); diff --git a/lib/roken/warnerr.c b/lib/roken/warnerr.c index 043e702cf..d95436fc3 100644 --- a/lib/roken/warnerr.c +++ b/lib/roken/warnerr.c @@ -39,7 +39,7 @@ RCSID("$Id$"); #include "roken.h" #include "err.h" -void +void ROKEN_LIB_FUNCTION warnerr(int doerrno, const char *fmt, va_list ap) { int sverrno = errno; diff --git a/lib/roken/warnx.c b/lib/roken/warnx.c index 8fd138855..e96aacf7c 100644 --- a/lib/roken/warnx.c +++ b/lib/roken/warnx.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "err.h" -void +void ROKEN_LIB_FUNCTION warnx(const char *fmt, ...) { va_list ap; diff --git a/lib/roken/write_pid.c b/lib/roken/write_pid.c index bc51d8261..5e4cf2369 100644 --- a/lib/roken/write_pid.c +++ b/lib/roken/write_pid.c @@ -43,7 +43,7 @@ RCSID("$Id$"); #include "roken.h" -char * +char * ROKEN_LIB_FUNCTION pid_file_write (const char *progname) { FILE *fp; @@ -62,7 +62,7 @@ pid_file_write (const char *progname) return ret; } -void +void ROKEN_LIB_FUNCTION pid_file_delete (char **filename) { if (*filename != NULL) { diff --git a/lib/roken/writev.c b/lib/roken/writev.c index 8fa47358e..40c803ebb 100644 --- a/lib/roken/writev.c +++ b/lib/roken/writev.c @@ -38,7 +38,7 @@ RCSID("$Id$"); #include "roken.h" -ssize_t +ssize_t ROKEN_LIB_FUNCTION writev(int d, const struct iovec *iov, int iovcnt) { ssize_t ret;