summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/roken
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/lib/roken')
-rw-r--r--source4/heimdal/lib/roken/base64.c4
-rw-r--r--source4/heimdal/lib/roken/base64.h8
-rw-r--r--source4/heimdal/lib/roken/bswap.c4
-rw-r--r--source4/heimdal/lib/roken/cloexec.c15
-rw-r--r--source4/heimdal/lib/roken/closefrom.c2
-rw-r--r--source4/heimdal/lib/roken/copyhostent.c2
-rw-r--r--source4/heimdal/lib/roken/dumpdata.c6
-rw-r--r--source4/heimdal/lib/roken/ecalloc.c2
-rw-r--r--source4/heimdal/lib/roken/emalloc.c2
-rw-r--r--source4/heimdal/lib/roken/erealloc.c2
-rw-r--r--source4/heimdal/lib/roken/err.hin20
-rw-r--r--source4/heimdal/lib/roken/estrdup.c2
-rw-r--r--source4/heimdal/lib/roken/freeaddrinfo.c2
-rw-r--r--source4/heimdal/lib/roken/freehostent.c2
-rw-r--r--source4/heimdal/lib/roken/gai_strerror.c2
-rw-r--r--source4/heimdal/lib/roken/get_window_size.c16
-rw-r--r--source4/heimdal/lib/roken/getaddrinfo.c2
-rw-r--r--source4/heimdal/lib/roken/getarg.c16
-rw-r--r--source4/heimdal/lib/roken/getarg.h12
-rw-r--r--source4/heimdal/lib/roken/getdtablesize.c2
-rw-r--r--source4/heimdal/lib/roken/getipnodebyaddr.c2
-rw-r--r--source4/heimdal/lib/roken/getipnodebyname.c2
-rw-r--r--source4/heimdal/lib/roken/getnameinfo.c2
-rw-r--r--source4/heimdal/lib/roken/getprogname.c2
-rw-r--r--source4/heimdal/lib/roken/hex.c4
-rw-r--r--source4/heimdal/lib/roken/hex.h8
-rw-r--r--source4/heimdal/lib/roken/hostent_find_fqdn.c2
-rw-r--r--source4/heimdal/lib/roken/inet_aton.c2
-rw-r--r--source4/heimdal/lib/roken/inet_ntop.c2
-rw-r--r--source4/heimdal/lib/roken/inet_pton.c61
-rw-r--r--source4/heimdal/lib/roken/issuid.c2
-rw-r--r--source4/heimdal/lib/roken/net_read.c47
-rw-r--r--source4/heimdal/lib/roken/net_write.c39
-rw-r--r--source4/heimdal/lib/roken/parse_bytes.h10
-rw-r--r--source4/heimdal/lib/roken/parse_time.c8
-rw-r--r--source4/heimdal/lib/roken/parse_time.h12
-rw-r--r--source4/heimdal/lib/roken/parse_units.c20
-rw-r--r--source4/heimdal/lib/roken/parse_units.h18
-rw-r--r--source4/heimdal/lib/roken/resolve.c16
-rw-r--r--source4/heimdal/lib/roken/resolve.h14
-rw-r--r--source4/heimdal/lib/roken/rkpty.c2
-rw-r--r--source4/heimdal/lib/roken/roken-common.h142
-rw-r--r--source4/heimdal/lib/roken/roken.h.in422
-rw-r--r--source4/heimdal/lib/roken/roken_gethostby.c6
-rw-r--r--source4/heimdal/lib/roken/rtbl.c44
-rw-r--r--source4/heimdal/lib/roken/rtbl.h36
-rw-r--r--source4/heimdal/lib/roken/setprogname.c2
-rw-r--r--source4/heimdal/lib/roken/signal.c2
-rw-r--r--source4/heimdal/lib/roken/simple_exec.c44
-rw-r--r--source4/heimdal/lib/roken/socket.c60
-rw-r--r--source4/heimdal/lib/roken/strcollect.c4
-rw-r--r--source4/heimdal/lib/roken/strlwr.c2
-rw-r--r--source4/heimdal/lib/roken/strpool.c6
-rw-r--r--source4/heimdal/lib/roken/strsep.c2
-rw-r--r--source4/heimdal/lib/roken/strsep_copy.c2
-rw-r--r--source4/heimdal/lib/roken/strupr.c2
-rw-r--r--source4/heimdal/lib/roken/vis.c25
-rw-r--r--source4/heimdal/lib/roken/vis.hin23
-rw-r--r--source4/heimdal/lib/roken/xfree.c2
59 files changed, 824 insertions, 400 deletions
diff --git a/source4/heimdal/lib/roken/base64.c b/source4/heimdal/lib/roken/base64.c
index a9f0535dda..4c06bd2d1f 100644
--- a/source4/heimdal/lib/roken/base64.c
+++ b/source4/heimdal/lib/roken/base64.c
@@ -51,7 +51,7 @@ pos(char c)
return -1;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
base64_encode(const void *data, int size, char **str)
{
char *s, *p;
@@ -120,7 +120,7 @@ token_decode(const char *token)
return (marker << 24) | val;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
base64_decode(const char *str, void *data)
{
const char *p;
diff --git a/source4/heimdal/lib/roken/base64.h b/source4/heimdal/lib/roken/base64.h
index f42c0ba429..dfae4c13b3 100644
--- a/source4/heimdal/lib/roken/base64.h
+++ b/source4/heimdal/lib/roken/base64.h
@@ -38,16 +38,18 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
base64_encode(const void *, int, char **);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
base64_decode(const char *, void *);
#endif
diff --git a/source4/heimdal/lib/roken/bswap.c b/source4/heimdal/lib/roken/bswap.c
index 67d240c231..7f8c1c22b1 100644
--- a/source4/heimdal/lib/roken/bswap.c
+++ b/source4/heimdal/lib/roken/bswap.c
@@ -36,7 +36,7 @@
#ifndef HAVE_BSWAP32
-unsigned int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
bswap32 (unsigned int val)
{
return (val & 0xff) << 24 |
@@ -48,7 +48,7 @@ bswap32 (unsigned int val)
#ifndef HAVE_BSWAP16
-unsigned short ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL
bswap16 (unsigned short val)
{
return (val & 0xff) << 8 |
diff --git a/source4/heimdal/lib/roken/cloexec.c b/source4/heimdal/lib/roken/cloexec.c
index c015b1d8fa..2d1fe033f2 100644
--- a/source4/heimdal/lib/roken/cloexec.c
+++ b/source4/heimdal/lib/roken/cloexec.c
@@ -33,14 +33,12 @@
#include <config.h>
-#include <unistd.h>
-#include <fcntl.h>
-
#include "roken.h"
void ROKEN_LIB_FUNCTION
rk_cloexec(int fd)
{
+#ifdef HAVE_FCNTL
int ret;
ret = fcntl(fd, F_GETFD);
@@ -48,10 +46,21 @@ rk_cloexec(int fd)
return;
if (fcntl(fd, F_SETFD, ret | FD_CLOEXEC) == -1)
return;
+#endif
}
void ROKEN_LIB_FUNCTION
rk_cloexec_file(FILE *f)
{
+#ifdef HAVE_FCNTL
rk_cloexec(fileno(f));
+#endif
+}
+
+void ROKEN_LIB_FUNCTION
+rk_cloexec_dir(DIR * d)
+{
+#ifndef _WIN32
+ rk_cloexec(dirfd(d));
+#endif
}
diff --git a/source4/heimdal/lib/roken/closefrom.c b/source4/heimdal/lib/roken/closefrom.c
index 7aa0ef7372..770eb2c67a 100644
--- a/source4/heimdal/lib/roken/closefrom.c
+++ b/source4/heimdal/lib/roken/closefrom.c
@@ -42,7 +42,7 @@
#include "roken.h"
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
closefrom(int fd)
{
int num = getdtablesize();
diff --git a/source4/heimdal/lib/roken/copyhostent.c b/source4/heimdal/lib/roken/copyhostent.c
index 69c1ba40ff..4ed630210f 100644
--- a/source4/heimdal/lib/roken/copyhostent.c
+++ b/source4/heimdal/lib/roken/copyhostent.c
@@ -39,7 +39,7 @@
* return a malloced copy of `h'
*/
-struct hostent * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
copyhostent (const struct hostent *h)
{
struct hostent *res;
diff --git a/source4/heimdal/lib/roken/dumpdata.c b/source4/heimdal/lib/roken/dumpdata.c
index c5513c323d..f30f0e54cc 100644
--- a/source4/heimdal/lib/roken/dumpdata.c
+++ b/source4/heimdal/lib/roken/dumpdata.c
@@ -33,15 +33,13 @@
#include <config.h>
-#include <unistd.h>
-
#include "roken.h"
/*
* Write datablob to a filename, don't care about errors.
*/
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dumpdata (const char *filename, const void *buf, size_t size)
{
int fd;
@@ -57,7 +55,7 @@ rk_dumpdata (const char *filename, const void *buf, size_t size)
* Read all data from a filename, care about errors.
*/
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_undumpdata(const char *filename, void **buf, size_t *size)
{
struct stat sb;
diff --git a/source4/heimdal/lib/roken/ecalloc.c b/source4/heimdal/lib/roken/ecalloc.c
index c8e6504030..04b37330c9 100644
--- a/source4/heimdal/lib/roken/ecalloc.c
+++ b/source4/heimdal/lib/roken/ecalloc.c
@@ -42,7 +42,7 @@
* Like calloc but never fails.
*/
-void * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
ecalloc (size_t number, size_t size)
{
void *tmp = calloc (number, size);
diff --git a/source4/heimdal/lib/roken/emalloc.c b/source4/heimdal/lib/roken/emalloc.c
index c937e6d707..2520230a35 100644
--- a/source4/heimdal/lib/roken/emalloc.c
+++ b/source4/heimdal/lib/roken/emalloc.c
@@ -42,7 +42,7 @@
* Like malloc but never fails.
*/
-void * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
emalloc (size_t sz)
{
void *tmp = malloc (sz);
diff --git a/source4/heimdal/lib/roken/erealloc.c b/source4/heimdal/lib/roken/erealloc.c
index f77c8ec733..1c30ecc60b 100644
--- a/source4/heimdal/lib/roken/erealloc.c
+++ b/source4/heimdal/lib/roken/erealloc.c
@@ -42,7 +42,7 @@
* Like realloc but never fails.
*/
-void * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
erealloc (void *ptr, size_t sz)
{
void *tmp = realloc (ptr, sz);
diff --git a/source4/heimdal/lib/roken/err.hin b/source4/heimdal/lib/roken/err.hin
index 9fd1856e2b..96fe5cf851 100644
--- a/source4/heimdal/lib/roken/err.hin
+++ b/source4/heimdal/lib/roken/err.hin
@@ -48,40 +48,42 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
verr(int eval, const char *fmt, va_list ap)
__attribute__ ((noreturn, format (printf, 2, 0)));
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
err(int eval, const char *fmt, ...)
__attribute__ ((noreturn, format (printf, 2, 3)));
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
verrx(int eval, const char *fmt, va_list ap)
__attribute__ ((noreturn, format (printf, 2, 0)));
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
errx(int eval, const char *fmt, ...)
__attribute__ ((noreturn, format (printf, 2, 3)));
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
vwarn(const char *fmt, va_list ap)
__attribute__ ((format (printf, 1, 0)));
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
warn(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
vwarnx(const char *fmt, va_list ap)
__attribute__ ((format (printf, 1, 0)));
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
warnx(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
diff --git a/source4/heimdal/lib/roken/estrdup.c b/source4/heimdal/lib/roken/estrdup.c
index ab7f26550b..d275a2830b 100644
--- a/source4/heimdal/lib/roken/estrdup.c
+++ b/source4/heimdal/lib/roken/estrdup.c
@@ -42,7 +42,7 @@
* Like strdup but never fails.
*/
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
estrdup (const char *str)
{
char *tmp = strdup (str);
diff --git a/source4/heimdal/lib/roken/freeaddrinfo.c b/source4/heimdal/lib/roken/freeaddrinfo.c
index 434e49e888..7132e95dd3 100644
--- a/source4/heimdal/lib/roken/freeaddrinfo.c
+++ b/source4/heimdal/lib/roken/freeaddrinfo.c
@@ -39,7 +39,7 @@
* free the list of `struct addrinfo' starting at `ai'
*/
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
freeaddrinfo(struct addrinfo *ai)
{
struct addrinfo *tofree;
diff --git a/source4/heimdal/lib/roken/freehostent.c b/source4/heimdal/lib/roken/freehostent.c
index 335504300a..61fbb223b5 100644
--- a/source4/heimdal/lib/roken/freehostent.c
+++ b/source4/heimdal/lib/roken/freehostent.c
@@ -39,7 +39,7 @@
* free a malloced hostent
*/
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
freehostent (struct hostent *h)
{
char **p;
diff --git a/source4/heimdal/lib/roken/gai_strerror.c b/source4/heimdal/lib/roken/gai_strerror.c
index 10beac05ea..1e326bee36 100644
--- a/source4/heimdal/lib/roken/gai_strerror.c
+++ b/source4/heimdal/lib/roken/gai_strerror.c
@@ -62,7 +62,7 @@ static struct gai_error {
*
*/
-const char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
gai_strerror(int ecode)
{
struct gai_error *g;
diff --git a/source4/heimdal/lib/roken/get_window_size.c b/source4/heimdal/lib/roken/get_window_size.c
index 60fb1764fa..13e7ebf157 100644
--- a/source4/heimdal/lib/roken/get_window_size.c
+++ b/source4/heimdal/lib/roken/get_window_size.c
@@ -57,7 +57,7 @@
#include "roken.h"
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
get_window_size(int fd, struct winsize *wp)
{
int ret = -1;
@@ -85,6 +85,20 @@ get_window_size(int fd, struct winsize *wp)
wp->ws_col = dst[0];
ret = 0;
}
+#elif defined(_WIN32)
+ {
+ intptr_t fh = 0;
+ CONSOLE_SCREEN_BUFFER_INFO sb_info;
+
+ fh = _get_osfhandle(fd);
+ if (fh != (intptr_t) INVALID_HANDLE_VALUE &&
+ GetConsoleScreenBufferInfo((HANDLE) fh, &sb_info)) {
+ wp->ws_row = 1 + sb_info.srWindow.Bottom - sb_info.srWindow.Top;
+ wp->ws_col = 1 + sb_info.srWindow.Right - sb_info.srWindow.Left;
+
+ ret = 0;
+ }
+ }
#endif
if (ret != 0) {
char *s;
diff --git a/source4/heimdal/lib/roken/getaddrinfo.c b/source4/heimdal/lib/roken/getaddrinfo.c
index 8c61299763..c8ed95413f 100644
--- a/source4/heimdal/lib/roken/getaddrinfo.c
+++ b/source4/heimdal/lib/roken/getaddrinfo.c
@@ -365,7 +365,7 @@ get_nodes (const char *nodename,
* };
*/
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getaddrinfo(const char *nodename,
const char *servname,
const struct addrinfo *hints,
diff --git a/source4/heimdal/lib/roken/getarg.c b/source4/heimdal/lib/roken/getarg.c
index 60b0f645af..d182f0019e 100644
--- a/source4/heimdal/lib/roken/getarg.c
+++ b/source4/heimdal/lib/roken/getarg.c
@@ -91,7 +91,7 @@ mandoc_template(struct getargs *args,
const char *extra_string,
char *(i18n)(const char *))
{
- int i;
+ size_t i;
char timestr[64], cmd[64];
char buf[128];
const char *p;
@@ -207,7 +207,7 @@ builtin_i18n(const char *str)
return rk_UNCONST(str);
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
arg_printusage (struct getargs *args,
size_t num_args,
const char *progname,
@@ -217,7 +217,7 @@ arg_printusage (struct getargs *args,
progname, extra_string, builtin_i18n);
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
arg_printusage_i18n (struct getargs *args,
size_t num_args,
const char *usage,
@@ -225,8 +225,7 @@ arg_printusage_i18n (struct getargs *args,
const char *extra_string,
char *(i18n)(const char *))
{
- int i;
- size_t max_len = 0;
+ size_t i, max_len = 0;
char buf[128];
int col = 0, columns;
struct winsize ws;
@@ -474,6 +473,7 @@ arg_match_long(struct getargs *args, size_t num_args,
default:
abort ();
+ UNREACHABLE(return 0);
}
/* not reached */
@@ -550,7 +550,7 @@ arg_match_short (struct getargs *args, size_t num_args,
return 0;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getarg(struct getargs *args, size_t num_args,
int argc, char **argv, int *goptind)
{
@@ -562,7 +562,7 @@ getarg(struct getargs *args, size_t num_args,
#elif defined(HAVE_RANDOM)
srandom(time(NULL));
#else
- srand (time(NULL));
+ srand ((int) time(NULL));
#endif
(*goptind)++;
for(i = *goptind; i < argc; i++) {
@@ -586,7 +586,7 @@ getarg(struct getargs *args, size_t num_args,
return ret;
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
free_getarg_strings (getarg_strings *s)
{
free (s->strings);
diff --git a/source4/heimdal/lib/roken/getarg.h b/source4/heimdal/lib/roken/getarg.h
index 64b65aa766..79573a0ea4 100644
--- a/source4/heimdal/lib/roken/getarg.h
+++ b/source4/heimdal/lib/roken/getarg.h
@@ -40,9 +40,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
@@ -86,17 +88,17 @@ typedef struct getarg_collect_info {
void *data;
} getarg_collect_info;
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getarg(struct getargs *args, size_t num_args,
int argc, char **argv, int *goptind);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
arg_printusage (struct getargs *args,
size_t num_args,
const char *progname,
const char *extra_string);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
arg_printusage_i18n (struct getargs *args,
size_t num_args,
const char *usage,
@@ -104,7 +106,7 @@ arg_printusage_i18n (struct getargs *args,
const char *extra_string,
char *(i18n)(const char *));
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
free_getarg_strings (getarg_strings *);
#endif /* __GETARG_H__ */
diff --git a/source4/heimdal/lib/roken/getdtablesize.c b/source4/heimdal/lib/roken/getdtablesize.c
index a515af3454..08c0661faa 100644
--- a/source4/heimdal/lib/roken/getdtablesize.c
+++ b/source4/heimdal/lib/roken/getdtablesize.c
@@ -61,7 +61,7 @@
#include <sys/sysctl.h>
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getdtablesize(void)
{
int files = -1;
diff --git a/source4/heimdal/lib/roken/getipnodebyaddr.c b/source4/heimdal/lib/roken/getipnodebyaddr.c
index ddaec03a89..7d4095f1d8 100644
--- a/source4/heimdal/lib/roken/getipnodebyaddr.c
+++ b/source4/heimdal/lib/roken/getipnodebyaddr.c
@@ -40,7 +40,7 @@
* to a malloced struct hostent or NULL.
*/
-struct hostent * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
getipnodebyaddr (const void *src, size_t len, int af, int *error_num)
{
struct hostent *tmp;
diff --git a/source4/heimdal/lib/roken/getipnodebyname.c b/source4/heimdal/lib/roken/getipnodebyname.c
index 16fdbdd24a..2ff282707c 100644
--- a/source4/heimdal/lib/roken/getipnodebyname.c
+++ b/source4/heimdal/lib/roken/getipnodebyname.c
@@ -44,7 +44,7 @@ static int h_errno = NO_RECOVERY;
* to a malloced struct hostent or NULL.
*/
-struct hostent * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
getipnodebyname (const char *name, int af, int flags, int *error_num)
{
struct hostent *tmp;
diff --git a/source4/heimdal/lib/roken/getnameinfo.c b/source4/heimdal/lib/roken/getnameinfo.c
index 0621cfeee1..b23ad01ebd 100644
--- a/source4/heimdal/lib/roken/getnameinfo.c
+++ b/source4/heimdal/lib/roken/getnameinfo.c
@@ -91,7 +91,7 @@ doit (int af,
*
*/
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getnameinfo(const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen,
char *serv, size_t servlen,
diff --git a/source4/heimdal/lib/roken/getprogname.c b/source4/heimdal/lib/roken/getprogname.c
index 933b6dec79..a310208a84 100644
--- a/source4/heimdal/lib/roken/getprogname.c
+++ b/source4/heimdal/lib/roken/getprogname.c
@@ -40,7 +40,7 @@ const char *__progname;
#endif
#ifndef HAVE_GETPROGNAME
-const char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
getprogname(void)
{
return __progname;
diff --git a/source4/heimdal/lib/roken/hex.c b/source4/heimdal/lib/roken/hex.c
index 95488af5c7..91590dd49d 100644
--- a/source4/heimdal/lib/roken/hex.c
+++ b/source4/heimdal/lib/roken/hex.c
@@ -50,7 +50,7 @@ pos(char c)
return -1;
}
-ssize_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
hex_encode(const void *data, size_t size, char **str)
{
const unsigned char *q = data;
@@ -80,7 +80,7 @@ hex_encode(const void *data, size_t size, char **str)
return i * 2;
}
-ssize_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
hex_decode(const char *str, void *data, size_t len)
{
size_t l;
diff --git a/source4/heimdal/lib/roken/hex.h b/source4/heimdal/lib/roken/hex.h
index b3c45511c8..c266268ea0 100644
--- a/source4/heimdal/lib/roken/hex.h
+++ b/source4/heimdal/lib/roken/hex.h
@@ -38,18 +38,20 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
#define hex_encode rk_hex_encode
#define hex_decode rk_hex_decode
-ssize_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
hex_encode(const void *, size_t, char **);
-ssize_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
hex_decode(const char *, void *, size_t);
#endif /* _rk_HEX_H_ */
diff --git a/source4/heimdal/lib/roken/hostent_find_fqdn.c b/source4/heimdal/lib/roken/hostent_find_fqdn.c
index b5f2b42f60..dc3c17ff22 100644
--- a/source4/heimdal/lib/roken/hostent_find_fqdn.c
+++ b/source4/heimdal/lib/roken/hostent_find_fqdn.c
@@ -39,7 +39,7 @@
* Try to find a fqdn (with `.') in he if possible, else return h_name
*/
-const char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
hostent_find_fqdn (const struct hostent *he)
{
const char *ret = he->h_name;
diff --git a/source4/heimdal/lib/roken/inet_aton.c b/source4/heimdal/lib/roken/inet_aton.c
index c9b21e00f8..31644a0cd3 100644
--- a/source4/heimdal/lib/roken/inet_aton.c
+++ b/source4/heimdal/lib/roken/inet_aton.c
@@ -38,7 +38,7 @@
/* Minimal implementation of inet_aton.
* Cannot distinguish between failure and a local broadcast address. */
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
inet_aton(const char *cp, struct in_addr *addr)
{
addr->s_addr = inet_addr(cp);
diff --git a/source4/heimdal/lib/roken/inet_ntop.c b/source4/heimdal/lib/roken/inet_ntop.c
index daf3e926dd..0c72b27fc6 100644
--- a/source4/heimdal/lib/roken/inet_ntop.c
+++ b/source4/heimdal/lib/roken/inet_ntop.c
@@ -113,7 +113,7 @@ inet_ntop_v6 (const void *src, char *dst, size_t size)
}
#endif /* HAVE_IPV6 */
-const char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
inet_ntop(int af, const void *src, char *dst, size_t size)
{
switch (af) {
diff --git a/source4/heimdal/lib/roken/inet_pton.c b/source4/heimdal/lib/roken/inet_pton.c
index ad60824f4a..3db1f49f22 100644
--- a/source4/heimdal/lib/roken/inet_pton.c
+++ b/source4/heimdal/lib/roken/inet_pton.c
@@ -35,7 +35,64 @@
#include "roken.h"
-int ROKEN_LIB_FUNCTION
+#ifdef HAVE_WINSOCK
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+inet_pton(int af, const char *src, void *dst)
+{
+ switch (af) {
+ case AF_INET:
+ {
+ struct sockaddr_in si4;
+ INT r;
+ INT s = sizeof(si4);
+
+ si4.sin_family = AF_INET;
+ r = WSAStringToAddress(src, AF_INET, NULL, (LPSOCKADDR) &si4, &s);
+
+ if (r == 0) {
+ memcpy(dst, &si4.sin_addr, sizeof(si4.sin_addr));
+ return 1;
+ }
+ }
+ break;
+
+ case AF_INET6:
+ {
+ struct sockaddr_in6 si6;
+ INT r;
+ INT s = sizeof(si6);
+
+ si6.sin6_family = AF_INET6;
+ r = WSAStringToAddress(src, AF_INET6, NULL, (LPSOCKADDR) &si6, &s);
+
+ if (r == 0) {
+ memcpy(dst, &si6.sin6_addr, sizeof(si6.sin6_addr));
+ return 1;
+ }
+ }
+ break;
+
+ default:
+ _set_errno( EAFNOSUPPORT );
+ return -1;
+ }
+
+ /* the call failed */
+ {
+ int le = WSAGetLastError();
+
+ if (le == WSAEINVAL)
+ return 0;
+
+ _set_errno(le);
+ return -1;
+ }
+}
+
+#else /* !HAVE_WINSOCK */
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
inet_pton(int af, const char *src, void *dst)
{
if (af != AF_INET) {
@@ -44,3 +101,5 @@ inet_pton(int af, const char *src, void *dst)
}
return inet_aton (src, dst);
}
+
+#endif
diff --git a/source4/heimdal/lib/roken/issuid.c b/source4/heimdal/lib/roken/issuid.c
index 2999e8249c..ea0db803e2 100644
--- a/source4/heimdal/lib/roken/issuid.c
+++ b/source4/heimdal/lib/roken/issuid.c
@@ -35,7 +35,7 @@
#include "roken.h"
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
issuid(void)
{
#if defined(HAVE_ISSETUGID)
diff --git a/source4/heimdal/lib/roken/net_read.c b/source4/heimdal/lib/roken/net_read.c
index 9d055d0068..b57dda3dda 100644
--- a/source4/heimdal/lib/roken/net_read.c
+++ b/source4/heimdal/lib/roken/net_read.c
@@ -33,29 +33,23 @@
#include <config.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <errno.h>
-
#include "roken.h"
/*
* Like read but never return partial data.
*/
-ssize_t ROKEN_LIB_FUNCTION
-net_read (int fd, void *buf, size_t nbytes)
+#ifndef _WIN32
+
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
+net_read (rk_socket_t fd, void *buf, size_t nbytes)
{
char *cbuf = (char *)buf;
ssize_t count;
size_t rem = nbytes;
while (rem > 0) {
-#ifdef WIN32
- count = recv (fd, cbuf, rem, 0);
-#else
count = read (fd, cbuf, rem);
-#endif
if (count < 0) {
if (errno == EINTR)
continue;
@@ -69,3 +63,36 @@ net_read (int fd, void *buf, size_t nbytes)
}
return nbytes;
}
+
+#else
+
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
+net_read(rk_socket_t sock, void *buf, size_t nbytes)
+{
+ char *cbuf = (char *)buf;
+ ssize_t count;
+ size_t rem = nbytes;
+
+ while (rem > 0) {
+ count = recv (sock, cbuf, rem, 0);
+ if (count < 0) {
+
+ /* With WinSock, the error EINTR (WSAEINTR), is used to
+ indicate that a blocking call was cancelled using
+ WSACancelBlockingCall(). */
+
+#ifndef HAVE_WINSOCK
+ if (rk_SOCK_ERRNO == EINTR)
+ continue;
+#endif
+ return count;
+ } else if (count == 0) {
+ return count;
+ }
+ cbuf += count;
+ rem -= count;
+ }
+ return nbytes;
+}
+
+#endif
diff --git a/source4/heimdal/lib/roken/net_write.c b/source4/heimdal/lib/roken/net_write.c
index 515f210973..94c9df1c38 100644
--- a/source4/heimdal/lib/roken/net_write.c
+++ b/source4/heimdal/lib/roken/net_write.c
@@ -33,29 +33,23 @@
#include <config.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <errno.h>
-
#include "roken.h"
/*
* Like write but never return partial data.
*/
-ssize_t ROKEN_LIB_FUNCTION
-net_write (int fd, const void *buf, size_t nbytes)
+#ifndef _WIN32
+
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
+net_write (rk_socket_t fd, const void *buf, size_t nbytes)
{
const char *cbuf = (const char *)buf;
ssize_t count;
size_t rem = nbytes;
while (rem > 0) {
-#ifdef WIN32
- count = send (fd, cbuf, rem, 0);
-#else
count = write (fd, cbuf, rem);
-#endif
if (count < 0) {
if (errno == EINTR)
continue;
@@ -67,3 +61,28 @@ net_write (int fd, const void *buf, size_t nbytes)
}
return nbytes;
}
+
+#else
+
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
+net_write(rk_socket_t sock, const void *buf, size_t nbytes)
+{
+ const char *cbuf = (const char *)buf;
+ ssize_t count;
+ size_t rem = nbytes;
+
+ while (rem > 0) {
+ count = send (sock, cbuf, rem, 0);
+ if (count < 0) {
+ if (errno == EINTR)
+ continue;
+ else
+ return count;
+ }
+ cbuf += count;
+ rem -= count;
+ }
+ return nbytes;
+}
+
+#endif
diff --git a/source4/heimdal/lib/roken/parse_bytes.h b/source4/heimdal/lib/roken/parse_bytes.h
index 7d389e808e..8a88eca49b 100644
--- a/source4/heimdal/lib/roken/parse_bytes.h
+++ b/source4/heimdal/lib/roken/parse_bytes.h
@@ -38,19 +38,21 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_bytes (const char *s, const char *def_unit);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_bytes (int t, char *s, size_t len);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_bytes_short (int t, char *s, size_t len);
#endif /* __PARSE_BYTES_H__ */
diff --git a/source4/heimdal/lib/roken/parse_time.c b/source4/heimdal/lib/roken/parse_time.c
index b581970bd7..febd6a5d2b 100644
--- a/source4/heimdal/lib/roken/parse_time.c
+++ b/source4/heimdal/lib/roken/parse_time.c
@@ -50,25 +50,25 @@ static struct units time_units[] = {
{NULL, 0},
};
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_time (const char *s, const char *def_unit)
{
return parse_units (s, time_units, def_unit);
}
-size_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
unparse_time (int t, char *s, size_t len)
{
return unparse_units (t, time_units, s, len);
}
-size_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
unparse_time_approx (int t, char *s, size_t len)
{
return unparse_units_approx (t, time_units, s, len);
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_time_table (FILE *f)
{
print_units_table (time_units, f);
diff --git a/source4/heimdal/lib/roken/parse_time.h b/source4/heimdal/lib/roken/parse_time.h
index 23aae2fc97..dabcefd81a 100644
--- a/source4/heimdal/lib/roken/parse_time.h
+++ b/source4/heimdal/lib/roken/parse_time.h
@@ -38,22 +38,24 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
-int
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_time (const char *s, const char *def_unit);
-size_t
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
unparse_time (int t, char *s, size_t len);
-size_t
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
unparse_time_approx (int t, char *s, size_t len);
-void
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_time_table (FILE *f);
#endif /* __PARSE_TIME_H__ */
diff --git a/source4/heimdal/lib/roken/parse_units.c b/source4/heimdal/lib/roken/parse_units.c
index a848298c57..d2857cfa07 100644
--- a/source4/heimdal/lib/roken/parse_units.c
+++ b/source4/heimdal/lib/roken/parse_units.c
@@ -70,7 +70,7 @@ parse_something (const char *s, const struct units *units,
p = s;
while (*p) {
- double val;
+ int val;
char *next;
const struct units *u, *partial_unit;
size_t u_len;
@@ -80,7 +80,7 @@ parse_something (const char *s, const struct units *units,
while(isspace((unsigned char)*p) || *p == ',')
++p;
- val = strtod (p, &next); /* strtol(p, &next, 0); */
+ val = strtol(p, &next, 0);
if (p == next) {
val = 0;
if(!accept_no_val_p)
@@ -149,7 +149,7 @@ acc_units(int res, int val, unsigned mult)
return res + val * mult;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_units (const char *s, const struct units *units,
const char *def_unit)
{
@@ -175,7 +175,7 @@ acc_flags(int res, int val, unsigned mult)
return -1;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_flags (const char *s, const struct units *units,
int orig)
{
@@ -208,7 +208,7 @@ unparse_something (int num, const struct units *units, char *s, size_t len,
tmp = (*print) (s, len, divisor, u->name, num);
if (tmp < 0)
return tmp;
- if (tmp > len) {
+ if (tmp > (int) len) {
len = 0;
s = NULL;
} else {
@@ -245,7 +245,7 @@ update_unit_approx (int in, unsigned mult)
return update_unit (in, mult);
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_units (int num, const struct units *units, char *s, size_t len)
{
return unparse_something (num, units, s, len,
@@ -254,7 +254,7 @@ unparse_units (int num, const struct units *units, char *s, size_t len)
"0");
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_units_approx (int num, const struct units *units, char *s, size_t len)
{
return unparse_something (num, units, s, len,
@@ -263,7 +263,7 @@ unparse_units_approx (int num, const struct units *units, char *s, size_t len)
"0");
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_units_table (const struct units *units, FILE *f)
{
const struct units *u, *u2;
@@ -308,7 +308,7 @@ update_flag (int in, unsigned mult)
return in - mult;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_flags (int num, const struct units *units, char *s, size_t len)
{
return unparse_something (num, units, s, len,
@@ -317,7 +317,7 @@ unparse_flags (int num, const struct units *units, char *s, size_t len)
"");
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_flags_table (const struct units *units, FILE *f)
{
const struct units *u;
diff --git a/source4/heimdal/lib/roken/parse_units.h b/source4/heimdal/lib/roken/parse_units.h
index 2f2235bb0d..2d1c286906 100644
--- a/source4/heimdal/lib/roken/parse_units.h
+++ b/source4/heimdal/lib/roken/parse_units.h
@@ -41,9 +41,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
@@ -52,28 +54,28 @@ struct units {
unsigned mult;
};
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_units (const char *s, const struct units *units,
const char *def_unit);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_units_table (const struct units *units, FILE *f);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_flags (const char *s, const struct units *units,
int orig);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_units (int num, const struct units *units, char *s, size_t len);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_units_approx (int num, const struct units *units, char *s,
size_t len);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_flags (int num, const struct units *units, char *s, size_t len);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_flags_table (const struct units *units, FILE *f);
#endif /* __PARSE_UNITS_H__ */
diff --git a/source4/heimdal/lib/roken/resolve.c b/source4/heimdal/lib/roken/resolve.c
index 419c8d94e0..0c0fc1dd92 100644
--- a/source4/heimdal/lib/roken/resolve.c
+++ b/source4/heimdal/lib/roken/resolve.c
@@ -78,7 +78,7 @@ static struct stot{
int _resolve_debug = 0;
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_dns_string_to_type(const char *name)
{
struct stot *p = stot;
@@ -88,7 +88,7 @@ rk_dns_string_to_type(const char *name)
return -1;
}
-const char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
rk_dns_type_to_string(int type)
{
struct stot *p = stot;
@@ -110,7 +110,7 @@ dns_free_rr(struct rk_resource_record *rr)
free(rr);
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_free_data(struct rk_dns_reply *r)
{
struct rk_resource_record *rr;
@@ -584,7 +584,7 @@ dns_lookup_int(const char *domain, int rr_class, int rr_type)
return r;
}
-struct rk_dns_reply * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct rk_dns_reply * ROKEN_LIB_CALL
rk_dns_lookup(const char *domain, const char *type_name)
{
int type;
@@ -614,7 +614,7 @@ compare_srv(const void *a, const void *b)
#endif
/* try to rearrange the srv-records by the algorithm in RFC2782 */
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_srv_order(struct rk_dns_reply *r)
{
struct rk_resource_record **srvs, **ss, **headp;
@@ -704,18 +704,18 @@ rk_dns_srv_order(struct rk_dns_reply *r)
#else /* NOT defined(HAVE_RES_SEARCH) && defined(HAVE_DN_EXPAND) */
-struct rk_dns_reply * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct rk_dns_reply * ROKEN_LIB_CALL
rk_dns_lookup(const char *domain, const char *type_name)
{
return NULL;
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_free_data(struct rk_dns_reply *r)
{
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_srv_order(struct rk_dns_reply *r)
{
}
diff --git a/source4/heimdal/lib/roken/resolve.h b/source4/heimdal/lib/roken/resolve.h
index 91b2afefe7..adec8084b8 100644
--- a/source4/heimdal/lib/roken/resolve.h
+++ b/source4/heimdal/lib/roken/resolve.h
@@ -38,9 +38,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
@@ -231,15 +233,15 @@ struct rk_dns_reply{
extern "C" {
#endif
-struct rk_dns_reply* ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct rk_dns_reply* ROKEN_LIB_CALL
rk_dns_lookup(const char *, const char *);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_free_data(struct rk_dns_reply *);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_dns_string_to_type(const char *name);
-const char *ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
rk_dns_type_to_string(int type);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_srv_order(struct rk_dns_reply*);
#ifdef __cplusplus
diff --git a/source4/heimdal/lib/roken/rkpty.c b/source4/heimdal/lib/roken/rkpty.c
index 6043e2b815..0faf668615 100644
--- a/source4/heimdal/lib/roken/rkpty.c
+++ b/source4/heimdal/lib/roken/rkpty.c
@@ -41,7 +41,9 @@
#endif
#include <stdio.h>
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#ifdef HAVE_PTY_H
#include <pty.h>
#endif
diff --git a/source4/heimdal/lib/roken/roken-common.h b/source4/heimdal/lib/roken/roken-common.h
index ea7dcaade0..a437d8a346 100644
--- a/source4/heimdal/lib/roken/roken-common.h
+++ b/source4/heimdal/lib/roken/roken-common.h
@@ -38,9 +38,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
@@ -120,6 +122,8 @@
#define O_ACCMODE 003
#endif
+#ifndef _WIN32
+
#ifndef _PATH_DEV
#define _PATH_DEV "/dev/"
#endif
@@ -144,6 +148,16 @@
#define MAXPATHLEN (1024+4)
#endif
+#endif /* !_WIN32 */
+
+#ifndef PATH_MAX
+#define PATH_MAX MAX_PATH
+#endif
+
+#ifndef RETSIGTYPE
+#define RETSIGTYPE void
+#endif
+
#ifndef SIG_ERR
#define SIG_ERR ((RETSIGTYPE (*)(int))-1)
#endif
@@ -261,193 +275,215 @@
ROKEN_CPP_START
#ifndef IRIX4 /* fix for compiler bug */
+#ifndef _WIN32
#ifdef RETSIGTYPE
typedef RETSIGTYPE (*SigAction)(int);
SigAction signal(int iSig, SigAction pAction); /* BSD compatible */
#endif
#endif
+#endif
+
+#define SE_E_UNSPECIFIED (-1)
+#define SE_E_FORKFAILED (-2)
+#define SE_E_WAITPIDFAILED (-3)
+#define SE_E_EXECTIMEOUT (-4)
+#define SE_E_NOEXEC 126
+#define SE_E_NOTFOUND 127
+
+#define SE_PROCSTATUS(st) (((st) >= 0 && (st) < 126)? st: -1)
+#define SE_PROCSIGNAL(st) (((st) >= 128)? (st) - 128: -1)
+#define SE_IS_ERROR(st) ((st) < 0 || (st) >= 126)
+
#define simple_execve rk_simple_execve
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execve(const char*, char*const[], char*const[]);
#define simple_execve_timed rk_simple_execve_timed
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execve_timed(const char *, char *const[],
char *const [], time_t (*)(void *),
void *, time_t);
#define simple_execvp rk_simple_execvp
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execvp(const char*, char *const[]);
#define simple_execvp_timed rk_simple_execvp_timed
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execvp_timed(const char *, char *const[],
time_t (*)(void *), void *, time_t);
#define simple_execlp rk_simple_execlp
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execlp(const char*, ...);
#define simple_execle rk_simple_execle
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execle(const char*, ...);
#define wait_for_process rk_wait_for_process
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
wait_for_process(pid_t);
#define wait_for_process_timed rk_wait_for_process_timed
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
wait_for_process_timed(pid_t, time_t (*)(void *),
- void *, time_t);
+ void *, time_t);
+
#define pipe_execv rk_pipe_execv
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
pipe_execv(FILE**, FILE**, FILE**, const char*, ...);
#define print_version rk_print_version
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_version(const char *);
#define eread rk_eread
-ssize_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
eread (int fd, void *buf, size_t nbytes);
#define ewrite rk_ewrite
-ssize_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
ewrite (int fd, const void *buf, size_t nbytes);
struct hostent;
#define hostent_find_fqdn rk_hostent_find_fqdn
-const char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
hostent_find_fqdn (const struct hostent *);
#define esetenv rk_esetenv
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
esetenv(const char *, const char *, int);
#define socket_set_address_and_port rk_socket_set_address_and_port
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_address_and_port (struct sockaddr *, const void *, int);
#define socket_addr_size rk_socket_addr_size
-size_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_addr_size (const struct sockaddr *);
#define socket_set_any rk_socket_set_any
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_any (struct sockaddr *, int);
#define socket_sockaddr_size rk_socket_sockaddr_size
-size_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_sockaddr_size (const struct sockaddr *);
#define socket_get_address rk_socket_get_address
-void * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
socket_get_address (const struct sockaddr *);
#define socket_get_port rk_socket_get_port
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
socket_get_port (const struct sockaddr *);
#define socket_set_port rk_socket_set_port
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_port (struct sockaddr *, int);
#define socket_set_portrange rk_socket_set_portrange
-void ROKEN_LIB_FUNCTION
-socket_set_portrange (int, int, int);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_portrange (rk_socket_t, int, int);
#define socket_set_debug rk_socket_set_debug
-void ROKEN_LIB_FUNCTION
-socket_set_debug (int);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_debug (rk_socket_t);
#define socket_set_tos rk_socket_set_tos
-void ROKEN_LIB_FUNCTION
-socket_set_tos (int, int);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_tos (rk_socket_t, int);
#define socket_set_reuseaddr rk_socket_set_reuseaddr
-void ROKEN_LIB_FUNCTION
-socket_set_reuseaddr (int, int);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_reuseaddr (rk_socket_t, int);
#define socket_set_ipv6only rk_socket_set_ipv6only
-void ROKEN_LIB_FUNCTION
-socket_set_ipv6only (int, int);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_ipv6only (rk_socket_t, int);
+
+#define socket_to_fd rk_socket_to_fd
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+socket_to_fd(rk_socket_t, int);
#define vstrcollect rk_vstrcollect
-char ** ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
vstrcollect(va_list *ap);
#define strcollect rk_strcollect
-char ** ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
strcollect(char *first, ...);
#define timevalfix rk_timevalfix
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
timevalfix(struct timeval *t1);
#define timevaladd rk_timevaladd
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
timevaladd(struct timeval *t1, const struct timeval *t2);
#define timevalsub rk_timevalsub
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
timevalsub(struct timeval *t1, const struct timeval *t2);
#define pid_file_write rk_pid_file_write
-char *ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
pid_file_write (const char *progname);
#define pid_file_delete rk_pid_file_delete
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
pid_file_delete (char **);
#define read_environment rk_read_environment
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
read_environment(const char *file, char ***env);
#define free_environment rk_free_environment
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
free_environment(char **);
#define warnerr rk_warnerr
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_warnerr(int doerrno, const char *fmt, va_list ap)
__attribute__ ((format (printf, 2, 0)));
-void * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
rk_realloc(void *, size_t);
struct rk_strpool;
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_strpoolcollect(struct rk_strpool *);
-struct rk_strpool * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL
rk_strpoolprintf(struct rk_strpool *, const char *, ...)
__attribute__ ((format (printf, 2, 3)));
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_strpoolfree(struct rk_strpool *);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dumpdata (const char *, const void *, size_t);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_undumpdata (const char *, void **, size_t *);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_xfree (void *);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_cloexec(int);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_cloexec_file(FILE *);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+rk_cloexec_dir(DIR *);
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
ct_memcmp(const void *, const void *, size_t);
ROKEN_CPP_END
diff --git a/source4/heimdal/lib/roken/roken.h.in b/source4/heimdal/lib/roken/roken.h.in
index 6fc533c697..0492db4d6b 100644
--- a/source4/heimdal/lib/roken/roken.h.in
+++ b/source4/heimdal/lib/roken/roken.h.in
@@ -41,6 +41,96 @@
#include <string.h>
#include <signal.h>
+#ifndef ROKEN_LIB_FUNCTION
+#ifdef _WIN32
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
+#else
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
+#endif
+#endif
+
+#ifdef HAVE_WINSOCK
+/* Declarations for Microsoft Windows */
+
+#include<ws2tcpip.h>
+
+/*
+ * error codes for inet_ntop/inet_pton
+ */
+#define EAFNOSUPPORT WSAEAFNOSUPPORT
+
+typedef SOCKET rk_socket_t;
+
+#define rk_closesocket(x) closesocket(x)
+#define rk_INVALID_SOCKET INVALID_SOCKET
+#define rk_IS_BAD_SOCKET(s) ((s) == INVALID_SOCKET)
+#define rk_IS_SOCKET_ERROR(rv) ((rv) == SOCKET_ERROR)
+#define rk_SOCK_ERRNO WSAGetLastError()
+#define rk_SOCK_IOCTL(s,c,a) ioctlsocket((s),(c),(a))
+
+#define ETIMEDOUT WSAETIMEDOUT
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define ENOTSOCK WSAENOTSOCK
+
+#define rk_SOCK_INIT() rk_WSAStartup()
+#define rk_SOCK_EXIT() rk_WSACleanup()
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSAStartup(void);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSACleanup(void);
+
+#else /* not WinSock */
+
+typedef int rk_socket_t;
+
+#define rk_closesocket(x) close(x)
+#define rk_SOCK_IOCTL(s,c,a) ioctl((s),(c),(a))
+#define rk_IS_BAD_SOCKET(s) ((s) < 0)
+#define rk_IS_SOCKET_ERROR(rv) ((rv) < 0)
+#define rk_SOCK_ERRNO errno
+#define rk_INVALID_SOCKET (-1)
+
+#define rk_SOCK_INIT() 0
+#define rk_SOCK_EXIT() do { } while(0)
+
+#endif
+
+#ifdef _MSC_VER
+/* Declarations for Microsoft Visual C runtime on Windows */
+
+#include<process.h>
+
+#include<io.h>
+
+#ifndef __BIT_TYPES_DEFINED__
+#define __BIT_TYPES_DEFINED__
+
+typedef __int8 int8_t;
+typedef __int16 int16_t;
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+typedef uint8_t u_int8_t;
+typedef uint16_t u_int16_t;
+typedef uint32_t u_int32_t;
+typedef uint64_t u_int64_t;
+
+#endif /* __BIT_TYPES_DEFINED__ */
+
+#define UNREACHABLE(x) x
+#define UNUSED_ARGUMENT(x) ((void) x)
+
+#else
+
+#define UNREACHABLE(x)
+#define UNUSED_ARGUMENT(x)
+
+#endif
+
#ifdef _AIX
struct ether_addr;
struct sockaddr_dl;
@@ -132,9 +222,21 @@ struct sockaddr_dl;
#include <paths.h>
#endif
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+
+#ifdef BACKSLASH_PATH_DELIM
+#define rk_PATH_DELIM '\\'
+#endif
+
#ifndef HAVE_SSIZE_T
+#ifdef _WIN64
+typedef __int64 ssize_t;
+#else
typedef int ssize_t;
#endif
+#endif
#include <roken-common.h>
@@ -150,23 +252,86 @@ ROKEN_CPP_START
#define setsid _setsid
#endif
+#ifdef _MSC_VER
+/* Additional macros for Visual C/C++ runtime */
+
+#define close _close
+
+#define getpid _getpid
+
+#define open _open
+
+#define chdir _chdir
+
+#define fsync _commit
+
+/* The MSVC implementation of snprintf is not C99 compliant. */
+#define snprintf rk_snprintf
+#define vsnprintf rk_vsnprintf
+#define vasnprintf rk_vasnprintf
+#define vasprintf rk_vasprintf
+#define asnprintf rk_asnprintf
+#define asprintf rk_asprintf
+
+#define _PIPE_BUFFER_SZ 8192
+#define pipe(fds) _pipe((fds), _PIPE_BUFFER_SZ, O_BINARY);
+
+#define ftruncate(fd, sz) _chsize((fd), (sz))
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+rk_snprintf (char *str, size_t sz, const char *format, ...);
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+rk_asprintf (char **ret, const char *format, ...);
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+rk_asnprintf (char **ret, size_t max_sz, const char *format, ...);
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+rk_vasprintf (char **ret, const char *format, va_list args);
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+rk_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args);
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+rk_vsnprintf (char *str, size_t sz, const char *format, va_list args);
+
+/* missing stat.h predicates */
+
+#define S_ISREG(m) (((m) & _S_IFREG) == _S_IFREG)
+
+#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
+
+#define S_ISCHR(m) (((m) & _S_IFCHR) == _S_IFCHR)
+
+#define S_ISFIFO(m) (((m) & _S_IFIFO) == _S_IFIFO)
+
+/* The following are not implemented:
+
+ S_ISLNK(m)
+ S_ISSOCK(m)
+ S_ISBLK(m)
+*/
+
+#endif /* _MSC_VER */
+
#ifndef HAVE_PUTENV
#define putenv rk_putenv
-int ROKEN_LIB_FUNCTION putenv(const char *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL putenv(const char *);
#endif
#if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO)
#ifndef HAVE_SETENV
#define setenv rk_setenv
#endif
-int ROKEN_LIB_FUNCTION setenv(const char *, const char *, int);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setenv(const char *, const char *, int);
#endif
#if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO)
#ifndef HAVE_UNSETENV
#define unsetenv rk_unsetenv
#endif
-void ROKEN_LIB_FUNCTION unsetenv(const char *);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL unsetenv(const char *);
#endif
#if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
@@ -174,15 +339,15 @@ void ROKEN_LIB_FUNCTION unsetenv(const char *);
#define getusershell rk_getusershell
#define endusershell rk_endusershell
#endif
-char * ROKEN_LIB_FUNCTION getusershell(void);
-void ROKEN_LIB_FUNCTION endusershell(void);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL getusershell(void);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL endusershell(void);
#endif
#if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO)
#ifndef HAVE_SNPRINTF
#define snprintf rk_snprintf
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_snprintf (char *, size_t, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
#endif
@@ -191,7 +356,7 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_VSNPRINTF
#define vsnprintf rk_vsnprintf
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_vsnprintf (char *, size_t, const char *, va_list)
__attribute__((format (printf, 3, 0)));
#endif
@@ -200,7 +365,7 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_ASPRINTF
#define asprintf rk_asprintf
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_asprintf (char **, const char *, ...)
__attribute__ ((format (printf, 2, 3)));
#endif
@@ -209,7 +374,7 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_VASPRINTF
#define vasprintf rk_vasprintf
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_vasprintf (char **, const char *, va_list)
__attribute__((format (printf, 2, 0)));
#endif
@@ -218,7 +383,7 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_ASNPRINTF
#define asnprintf rk_asnprintf
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_asnprintf (char **, size_t, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
#endif
@@ -227,91 +392,91 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_VASNPRINTF
#define vasnprintf rk_vasnprintf
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
vasnprintf (char **, size_t, const char *, va_list)
__attribute__((format (printf, 3, 0)));
#endif
#ifndef HAVE_STRDUP
#define strdup rk_strdup
-char * ROKEN_LIB_FUNCTION strdup(const char *);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strdup(const char *);
#endif
#if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO)
#ifndef HAVE_STRNDUP
#define strndup rk_strndup
#endif
-char * ROKEN_LIB_FUNCTION strndup(const char *, size_t);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strndup(const char *, size_t);
#endif
#ifndef HAVE_STRLWR
#define strlwr rk_strlwr
-char * ROKEN_LIB_FUNCTION strlwr(char *);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strlwr(char *);
#endif
#ifndef HAVE_STRNLEN
#define strnlen rk_strnlen
-size_t ROKEN_LIB_FUNCTION strnlen(const char*, size_t);
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strnlen(const char*, size_t);
#endif
#if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO)
#ifndef HAVE_STRSEP
#define strsep rk_strsep
#endif
-char * ROKEN_LIB_FUNCTION strsep(char**, const char*);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strsep(char**, const char*);
#endif
#if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO)
#ifndef HAVE_STRSEP_COPY
#define strsep_copy rk_strsep_copy
#endif
-ssize_t ROKEN_LIB_FUNCTION strsep_copy(const char**, const char*, char*, size_t);
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL strsep_copy(const char**, const char*, char*, size_t);
#endif
#ifndef HAVE_STRCASECMP
#define strcasecmp rk_strcasecmp
-int ROKEN_LIB_FUNCTION strcasecmp(const char *, const char *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL strcasecmp(const char *, const char *);
#endif
#ifdef NEED_FCLOSE_PROTO
-int ROKEN_LIB_FUNCTION fclose(FILE *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fclose(FILE *);
#endif
#ifdef NEED_STRTOK_R_PROTO
-char * ROKEN_LIB_FUNCTION strtok_r(char *, const char *, char **);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strtok_r(char *, const char *, char **);
#endif
#ifndef HAVE_STRUPR
#define strupr rk_strupr
-char * ROKEN_LIB_FUNCTION strupr(char *);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strupr(char *);
#endif
#ifndef HAVE_STRLCPY
#define strlcpy rk_strlcpy
-size_t ROKEN_LIB_FUNCTION strlcpy (char *, const char *, size_t);
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcpy (char *, const char *, size_t);
#endif
#ifndef HAVE_STRLCAT
#define strlcat rk_strlcat
-size_t ROKEN_LIB_FUNCTION strlcat (char *, const char *, size_t);
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcat (char *, const char *, size_t);
#endif
#ifndef HAVE_GETDTABLESIZE
#define getdtablesize rk_getdtablesize
-int ROKEN_LIB_FUNCTION getdtablesize(void);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL getdtablesize(void);
#endif
#if !defined(HAVE_STRERROR) && !defined(strerror)
#define strerror rk_strerror
-char * ROKEN_LIB_FUNCTION strerror(int);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strerror(int);
#endif
-#if !defined(HAVE_STRERROR) && !defined(strerror)
-#define strerror_r rk_strerror_r
-int ROKEN_LIB_FUNCTION strerror_r(int, char *, size_t);
+#if !defined(HAVE_STRERROR_R) && !defined(strerror_r) && !defined(STRERROR_R_PROTO_COMPATIBLE)
+int ROKEN_LIB_FUNCTION rk_strerror_r(int, char *, size_t);
+#else
+#define rk_strerror_r strerror_r
#endif
-
#if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO)
#ifndef HAVE_HSTRERROR
#define hstrerror rk_hstrerror
@@ -319,6 +484,7 @@ int ROKEN_LIB_FUNCTION strerror_r(int, char *, size_t);
/* This causes a fatal error under Psoriasis */
#ifndef SunOS
const char * ROKEN_LIB_FUNCTION hstrerror(int);
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL hstrerror(int);
#endif
#endif
@@ -330,88 +496,88 @@ extern int h_errno;
#ifndef HAVE_INET_ATON
#define inet_aton rk_inet_aton
#endif
-int ROKEN_LIB_FUNCTION inet_aton(const char *, struct in_addr *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL inet_aton(const char *, struct in_addr *);
#endif
#ifndef HAVE_INET_NTOP
#define inet_ntop rk_inet_ntop
-const char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
inet_ntop(int af, const void *src, char *dst, size_t size);
#endif
#ifndef HAVE_INET_PTON
#define inet_pton rk_inet_pton
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
inet_pton(int, const char *, void *);
#endif
#ifndef HAVE_GETCWD
#define getcwd rk_getcwd
-char* ROKEN_LIB_FUNCTION getcwd(char *, size_t);
+ROKEN_LIB_FUNCTION char* ROKEN_LIB_CALL getcwd(char *, size_t);
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
-struct passwd * ROKEN_LIB_FUNCTION k_getpwnam (const char *);
-struct passwd * ROKEN_LIB_FUNCTION k_getpwuid (uid_t);
+ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwnam (const char *);
+ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwuid (uid_t);
#endif
-const char * ROKEN_LIB_FUNCTION get_default_username (void);
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL get_default_username (void);
#ifndef HAVE_SETEUID
#define seteuid rk_seteuid
-int ROKEN_LIB_FUNCTION seteuid(uid_t);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL seteuid(uid_t);
#endif
#ifndef HAVE_SETEGID
#define setegid rk_setegid
-int ROKEN_LIB_FUNCTION setegid(gid_t);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setegid(gid_t);
#endif
#ifndef HAVE_LSTAT
#define lstat rk_lstat
-int ROKEN_LIB_FUNCTION lstat(const char *, struct stat *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL lstat(const char *, struct stat *);
#endif
#if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO)
#ifndef HAVE_MKSTEMP
#define mkstemp rk_mkstemp
#endif
-int ROKEN_LIB_FUNCTION mkstemp(char *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL mkstemp(char *);
#endif
#ifndef HAVE_CGETENT
#define cgetent rk_cgetent
#define cgetstr rk_cgetstr
-int ROKEN_LIB_FUNCTION cgetent(char **, char **, const char *);
-int ROKEN_LIB_FUNCTION cgetstr(char *, const char *, char **);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **, char **, const char *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *, const char *, char **);
#endif
#ifndef HAVE_INITGROUPS
#define initgroups rk_initgroups
-int ROKEN_LIB_FUNCTION initgroups(const char *, gid_t);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL initgroups(const char *, gid_t);
#endif
#ifndef HAVE_FCHOWN
#define fchown rk_fchown
-int ROKEN_LIB_FUNCTION fchown(int, uid_t, gid_t);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fchown(int, uid_t, gid_t);
#endif
#if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO)
#ifndef HAVE_DAEMON
#define daemon rk_daemon
#endif
-int ROKEN_LIB_FUNCTION daemon(int, int);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL daemon(int, int);
#endif
#ifndef HAVE_CHOWN
#define chown rk_chown
-int ROKEN_LIB_FUNCTION chown(const char *, uid_t, gid_t);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL chown(const char *, uid_t, gid_t);
#endif
#ifndef HAVE_RCMD
#define rcmd rk_rcmd
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rcmd(char **, unsigned short, const char *,
const char *, const char *, int *);
#endif
@@ -420,13 +586,13 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_INNETGR
#define innetgr rk_innetgr
#endif
-int ROKEN_LIB_FUNCTION innetgr(const char*, const char*,
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL innetgr(const char*, const char*,
const char*, const char*);
#endif
#ifndef HAVE_IRUSEROK
#define iruserok rk_iruserok
-int ROKEN_LIB_FUNCTION iruserok(unsigned, int,
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int,
const char *, const char *);
#endif
@@ -434,34 +600,38 @@ int ROKEN_LIB_FUNCTION iruserok(unsigned, int,
#ifndef HAVE_GETHOSTNAME
#define gethostname rk_gethostname
#endif
-int ROKEN_LIB_FUNCTION gethostname(char *, int);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL gethostname(char *, int);
#endif
#ifndef HAVE_WRITEV
#define writev rk_writev
-ssize_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
writev(int, const struct iovec *, int);
#endif
#ifndef HAVE_READV
#define readv rk_readv
-ssize_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
readv(int, const struct iovec *, int);
#endif
#ifndef HAVE_PIDFILE
+#ifdef NO_PIDFILES
+#define pidfile(x) ((void) 0)
+#else
#define pidfile rk_pidfile
-void ROKEN_LIB_FUNCTION pidfile (const char*);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL pidfile (const char*);
+#endif
#endif
#ifndef HAVE_BSWAP32
#define bswap32 rk_bswap32
-unsigned int ROKEN_LIB_FUNCTION bswap32(unsigned int);
+ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL bswap32(unsigned int);
#endif
#ifndef HAVE_BSWAP16
#define bswap16 rk_bswap16
-unsigned short ROKEN_LIB_FUNCTION bswap16(unsigned short);
+ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL bswap16(unsigned short);
#endif
#ifndef HAVE_FLOCK
@@ -486,24 +656,27 @@ int rk_flock(int fd, int operation);
#define dirfd(x) ((x)->dd_fd)
#endif
-time_t ROKEN_LIB_FUNCTION tm2time (struct tm, int);
+ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL tm2time (struct tm, int);
-int ROKEN_LIB_FUNCTION unix_verify_user(char *, char *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL unix_verify_user(char *, char *);
-int ROKEN_LIB_FUNCTION roken_concat (char *, size_t, ...);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_concat (char *, size_t, ...);
-size_t ROKEN_LIB_FUNCTION roken_mconcat (char **, size_t, ...);
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_mconcat (char **, size_t, ...);
-int ROKEN_LIB_FUNCTION roken_vconcat (char *, size_t, va_list);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_vconcat (char *, size_t, va_list);
-size_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
roken_vmconcat (char **, size_t, va_list);
-ssize_t ROKEN_LIB_FUNCTION net_write (int, const void *, size_t);
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
+ net_write (rk_socket_t, const void *, size_t);
-ssize_t ROKEN_LIB_FUNCTION net_read (int, void *, size_t);
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
+ net_read (rk_socket_t, void *, size_t);
-int ROKEN_LIB_FUNCTION issuid(void);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+ issuid(void);
#ifndef HAVE_STRUCT_WINSIZE
struct winsize {
@@ -512,11 +685,11 @@ struct winsize {
};
#endif
-int ROKEN_LIB_FUNCTION get_window_size(int fd, struct winsize *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, struct winsize *);
#ifndef HAVE_VSYSLOG
#define vsyslog rk_vsyslog
-void ROKEN_LIB_FUNCTION vsyslog(int, const char *, va_list);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL vsyslog(int, const char *, va_list);
#endif
#if !HAVE_DECL_OPTARG
@@ -531,25 +704,25 @@ extern int opterr;
#ifndef HAVE_GETIPNODEBYNAME
#define getipnodebyname rk_getipnodebyname
-struct hostent * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
getipnodebyname (const char *, int, int, int *);
#endif
#ifndef HAVE_GETIPNODEBYADDR
#define getipnodebyaddr rk_getipnodebyaddr
-struct hostent * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
getipnodebyaddr (const void *, size_t, int, int *);
#endif
#ifndef HAVE_FREEHOSTENT
#define freehostent rk_freehostent
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
freehostent (struct hostent *);
#endif
#ifndef HAVE_COPYHOSTENT
#define copyhostent rk_copyhostent
-struct hostent * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
copyhostent (const struct hostent *);
#endif
@@ -617,7 +790,7 @@ struct addrinfo {
#ifndef HAVE_GETADDRINFO
#define getaddrinfo rk_getaddrinfo
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getaddrinfo(const char *,
const char *,
const struct addrinfo *,
@@ -626,7 +799,7 @@ getaddrinfo(const char *,
#ifndef HAVE_GETNAMEINFO
#define getnameinfo rk_getnameinfo
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getnameinfo(const struct sockaddr *, socklen_t,
char *, size_t,
char *, size_t,
@@ -635,65 +808,103 @@ getnameinfo(const struct sockaddr *, socklen_t,
#ifndef HAVE_FREEADDRINFO
#define freeaddrinfo rk_freeaddrinfo
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
freeaddrinfo(struct addrinfo *);
#endif
#ifndef HAVE_GAI_STRERROR
#define gai_strerror rk_gai_strerror
-const char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
gai_strerror(int);
#endif
-int ROKEN_LIB_FUNCTION
+#ifdef HAVE_WINSOCK
+
+/* While we are at it, define WinSock specific scatter gather socket
+ I/O. */
+
+#define iovec _WSABUF
+#define iov_base buf
+#define iov_len len
+
+struct msghdr {
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ size_t msg_iovlen;
+ void *msg_control;
+ socklen_t msg_controllen;
+ int msg_flags;
+};
+
+#define sendmsg sendmsg_w32
+
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
+sendmsg_w32(rk_socket_t s, const struct msghdr * msg, int flags);
+
+#endif
+
+#ifdef NO_SLEEP
+
+ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
+sleep(unsigned int seconds);
+
+#endif
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getnameinfo_verified(const struct sockaddr *, socklen_t,
char *, size_t,
char *, size_t,
int);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);
#ifndef HAVE_STRFTIME
#define strftime rk_strftime
-size_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
strftime (char *, size_t, const char *, const struct tm *);
#endif
#ifndef HAVE_STRPTIME
#define strptime rk_strptime
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
strptime (const char *, const char *, struct tm *);
#endif
+#ifndef HAVE_GETTIMEOFDAY
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+gettimeofday (struct timeval *, void *);
+#endif
+
#ifndef HAVE_EMALLOC
#define emalloc rk_emalloc
-void * ROKEN_LIB_FUNCTION emalloc (size_t);
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL emalloc (size_t);
#endif
#ifndef HAVE_ECALLOC
#define ecalloc rk_ecalloc
-void * ROKEN_LIB_FUNCTION ecalloc(size_t, size_t);
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ecalloc(size_t, size_t);
#endif
#ifndef HAVE_EREALLOC
#define erealloc rk_erealloc
-void * ROKEN_LIB_FUNCTION erealloc (void *, size_t);
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL erealloc (void *, size_t);
#endif
#ifndef HAVE_ESTRDUP
#define estrdup rk_estrdup
-char * ROKEN_LIB_FUNCTION estrdup (const char *);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL estrdup (const char *);
#endif
/*
* kludges and such
*/
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_gethostby_setup(const char*, const char*);
-struct hostent* ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyname(const char*);
-struct hostent* ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyaddr(const void*, size_t, int);
#ifdef GETSERVBYNAME_PROTO_COMPATIBLE
@@ -716,24 +927,27 @@ roken_gethostbyaddr(const void*, size_t, int);
#ifndef HAVE_SETPROGNAME
#define setprogname rk_setprogname
-void ROKEN_LIB_FUNCTION setprogname(const char *);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL setprogname(const char *);
#endif
#ifndef HAVE_GETPROGNAME
#define getprogname rk_getprogname
-const char * ROKEN_LIB_FUNCTION getprogname(void);
+ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void);
#endif
#if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME
extern const char *__progname;
#endif
-void ROKEN_LIB_FUNCTION mini_inetd_addrinfo (struct addrinfo*);
-void ROKEN_LIB_FUNCTION mini_inetd (int);
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+mini_inetd_addrinfo (struct addrinfo*, rk_socket_t *);
+
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+mini_inetd (int, rk_socket_t *);
#ifndef HAVE_LOCALTIME_R
#define localtime_r rk_localtime_r
-struct tm * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct tm * ROKEN_LIB_CALL
localtime_r(const time_t *, struct tm *);
#endif
@@ -741,15 +955,23 @@ localtime_r(const time_t *, struct tm *);
#ifndef HAVE_STRSVIS
#define strsvis rk_strsvis
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
strsvis(char *, const char *, int, const char *);
#endif
+#if !defined(HAVE_STRSVISX) || defined(NEED_STRSVISX_PROTO)
+#ifndef HAVE_STRSVISX
+#define strsvisx rk_strsvisx
+#endif
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+strsvisx(char *, const char *, size_t, int, const char *);
+#endif
+
#if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO)
#ifndef HAVE_STRUNVIS
#define strunvis rk_strunvis
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
strunvis(char *, const char *);
#endif
@@ -757,7 +979,7 @@ strunvis(char *, const char *);
#ifndef HAVE_STRVIS
#define strvis rk_strvis
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
strvis(char *, const char *, int);
#endif
@@ -765,7 +987,7 @@ strvis(char *, const char *, int);
#ifndef HAVE_STRVISX
#define strvisx rk_strvisx
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
strvisx(char *, const char *, size_t, int);
#endif
@@ -773,7 +995,7 @@ strvisx(char *, const char *, size_t, int);
#ifndef HAVE_SVIS
#define svis rk_svis
#endif
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
svis(char *, int, int, int, const char *);
#endif
@@ -781,7 +1003,7 @@ svis(char *, int, int, int, const char *);
#ifndef HAVE_UNVIS
#define unvis rk_unvis
#endif
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unvis(char *, int, int *, int);
#endif
@@ -789,19 +1011,19 @@ unvis(char *, int, int *, int);
#ifndef HAVE_VIS
#define vis rk_vis
#endif
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
vis(char *, int, int, int);
#endif
#if !defined(HAVE_CLOSEFROM)
#define closefrom rk_closefrom
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
closefrom(int);
#endif
#if !defined(HAVE_TIMEGM)
#define timegm rk_timegm
-time_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL
rk_timegm(struct tm *tm);
#endif
diff --git a/source4/heimdal/lib/roken/roken_gethostby.c b/source4/heimdal/lib/roken/roken_gethostby.c
index d87a49a04b..c99596c536 100644
--- a/source4/heimdal/lib/roken/roken_gethostby.c
+++ b/source4/heimdal/lib/roken/roken_gethostby.c
@@ -104,7 +104,7 @@ split_spec(const char *spec, char **host, int *port, char **path, int def_port)
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_gethostby_setup(const char *proxy_spec, const char *dns_spec)
{
char *proxy_host = NULL;
@@ -207,7 +207,7 @@ roken_gethostby(const char *hostname)
}
}
-struct hostent*
+ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyname(const char *hostname)
{
struct hostent *he;
@@ -217,7 +217,7 @@ roken_gethostbyname(const char *hostname)
return roken_gethostby(hostname);
}
-struct hostent* ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyaddr(const void *addr, size_t len, int type)
{
struct in_addr a;
diff --git a/source4/heimdal/lib/roken/rtbl.c b/source4/heimdal/lib/roken/rtbl.c
index 7d11a487cf..fe0fde662b 100644
--- a/source4/heimdal/lib/roken/rtbl.c
+++ b/source4/heimdal/lib/roken/rtbl.c
@@ -59,19 +59,19 @@ struct rtbl_data {
char *column_separator;
};
-rtbl_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION rtbl_t ROKEN_LIB_CALL
rtbl_create (void)
{
return calloc (1, sizeof (struct rtbl_data));
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rtbl_set_flags (rtbl_t table, unsigned int flags)
{
table->flags = flags;
}
-unsigned int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
rtbl_get_flags (rtbl_t table)
{
return table->flags;
@@ -80,7 +80,7 @@ rtbl_get_flags (rtbl_t table)
static struct column_data *
rtbl_get_column_by_id (rtbl_t table, unsigned int id)
{
- int i;
+ size_t i;
for(i = 0; i < table->num_columns; i++)
if(table->columns[i]->column_id == id)
return table->columns[i];
@@ -90,17 +90,17 @@ rtbl_get_column_by_id (rtbl_t table, unsigned int id)
static struct column_data *
rtbl_get_column (rtbl_t table, const char *column)
{
- int i;
+ size_t i;
for(i = 0; i < table->num_columns; i++)
if(strcmp(table->columns[i]->header, column) == 0)
return table->columns[i];
return NULL;
}
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rtbl_destroy (rtbl_t table)
{
- int i, j;
+ size_t i, j;
for (i = 0; i < table->num_columns; i++) {
struct column_data *c = table->columns[i];
@@ -119,7 +119,7 @@ rtbl_destroy (rtbl_t table)
free (table);
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column_by_id (rtbl_t table, unsigned int id,
const char *header, unsigned int flags)
{
@@ -148,13 +148,13 @@ rtbl_add_column_by_id (rtbl_t table, unsigned int id,
return 0;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column (rtbl_t table, const char *header, unsigned int flags)
{
return rtbl_add_column_by_id(table, 0, header, flags);
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_new_row(rtbl_t table)
{
size_t max_rows = 0;
@@ -183,18 +183,18 @@ rtbl_new_row(rtbl_t table)
static void
column_compute_width (rtbl_t table, struct column_data *column)
{
- int i;
+ size_t i;
if(table->flags & RTBL_HEADER_STYLE_NONE)
column->width = 0;
else
column->width = strlen (column->header);
for (i = 0; i < column->num_rows; i++)
- column->width = max (column->width, strlen (column->rows[i].data));
+ column->width = max (column->width, (int) strlen (column->rows[i].data));
}
/* DEPRECATED */
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_set_prefix (rtbl_t table, const char *prefix)
{
if (table->column_prefix)
@@ -205,7 +205,7 @@ rtbl_set_prefix (rtbl_t table, const char *prefix)
return 0;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_set_separator (rtbl_t table, const char *separator)
{
if (table->column_separator)
@@ -216,7 +216,7 @@ rtbl_set_separator (rtbl_t table, const char *separator)
return 0;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_set_column_prefix (rtbl_t table, const char *column,
const char *prefix)
{
@@ -232,7 +232,7 @@ rtbl_set_column_prefix (rtbl_t table, const char *column,
return 0;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_set_column_affix_by_id(rtbl_t table, unsigned int id,
const char *prefix, const char *suffix)
{
@@ -301,7 +301,7 @@ add_column_entry (struct column_data *c, const char *data)
return 0;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
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);
@@ -312,7 +312,7 @@ rtbl_add_column_entry_by_id (rtbl_t table, unsigned int id, const char *data)
return add_column_entry(c, data);
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column_entryv_by_id (rtbl_t table, unsigned int id,
const char *fmt, ...)
{
@@ -330,7 +330,7 @@ rtbl_add_column_entryv_by_id (rtbl_t table, unsigned int id,
return ret;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column_entry (rtbl_t table, const char *column, const char *data)
{
struct column_data *c = rtbl_get_column (table, column);
@@ -341,7 +341,7 @@ rtbl_add_column_entry (rtbl_t table, const char *column, const char *data)
return add_column_entry(c, data);
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column_entryv (rtbl_t table, const char *column, const char *fmt, ...)
{
va_list ap;
@@ -359,10 +359,10 @@ rtbl_add_column_entryv (rtbl_t table, const char *column, const char *fmt, ...)
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_format (rtbl_t table, FILE * f)
{
- int i, j;
+ size_t i, j;
for (i = 0; i < table->num_columns; i++)
column_compute_width (table, table->columns[i]);
diff --git a/source4/heimdal/lib/roken/rtbl.h b/source4/heimdal/lib/roken/rtbl.h
index 60bbc9f873..549d3a8aa4 100644
--- a/source4/heimdal/lib/roken/rtbl.h
+++ b/source4/heimdal/lib/roken/rtbl.h
@@ -37,9 +37,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
@@ -60,55 +62,55 @@ typedef struct rtbl_data *rtbl_t;
/* flags */
#define RTBL_HEADER_STYLE_NONE 1
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column (rtbl_t, const char*, unsigned int);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column_by_id (rtbl_t, unsigned int, const char*, unsigned int);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column_entryv_by_id (rtbl_t table, unsigned int id,
const char *fmt, ...)
__attribute__ ((format (printf, 3, 0)));
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column_entry (rtbl_t, const char*, const char*);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column_entryv (rtbl_t, const char*, const char*, ...)
__attribute__ ((format (printf, 3, 0)));
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_add_column_entry_by_id (rtbl_t, unsigned int, const char*);
-rtbl_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION rtbl_t ROKEN_LIB_CALL
rtbl_create (void);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rtbl_destroy (rtbl_t);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_format (rtbl_t, FILE*);
-unsigned int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
rtbl_get_flags (rtbl_t);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_new_row (rtbl_t);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_set_column_affix_by_id (rtbl_t, unsigned int, const char*, const char*);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_set_column_prefix (rtbl_t, const char*, const char*);
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rtbl_set_flags (rtbl_t, unsigned int);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_set_prefix (rtbl_t, const char*);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rtbl_set_separator (rtbl_t, const char*);
#ifdef __cplusplus
diff --git a/source4/heimdal/lib/roken/setprogname.c b/source4/heimdal/lib/roken/setprogname.c
index 225e6ae092..115af77b88 100644
--- a/source4/heimdal/lib/roken/setprogname.c
+++ b/source4/heimdal/lib/roken/setprogname.c
@@ -40,7 +40,7 @@ extern const char *__progname;
#endif
#ifndef HAVE_SETPROGNAME
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
setprogname(const char *argv0)
{
#ifndef HAVE___PROGNAME
diff --git a/source4/heimdal/lib/roken/signal.c b/source4/heimdal/lib/roken/signal.c
index 19a4845435..284f1e7926 100644
--- a/source4/heimdal/lib/roken/signal.c
+++ b/source4/heimdal/lib/roken/signal.c
@@ -47,7 +47,7 @@
* Do we need any extra hacks for SIGCLD and/or SIGCHLD?
*/
-SigAction ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION SigAction ROKEN_LIB_CALL
signal(int iSig, SigAction pAction)
{
struct sigaction saNew, saOld;
diff --git a/source4/heimdal/lib/roken/simple_exec.c b/source4/heimdal/lib/roken/simple_exec.c
index 86dde1bad2..97679d7e41 100644
--- a/source4/heimdal/lib/roken/simple_exec.c
+++ b/source4/heimdal/lib/roken/simple_exec.c
@@ -52,13 +52,13 @@
#define EX_NOTFOUND 127
/* return values:
- -1 on `unspecified' system errors
- -2 on fork failures
- -3 on waitpid errors
- -4 exec timeout
+ SE_E_UNSPECIFIED on `unspecified' system errors
+ SE_E_FORKFAILED on fork failures
+ SE_E_WAITPIDFAILED on waitpid errors
+ SE_E_EXECTIMEOUT exec timeout
0- is return value from subprocess
- 126 if the program couldn't be executed
- 127 if the program couldn't be found
+ SE_E_NOEXEC if the program couldn't be executed
+ SE_E_NOTFOUND if the program couldn't be found
128- is 128 + signal that killed subprocess
possible values `func' can return:
@@ -78,7 +78,7 @@ sigtimeout(int sig)
SIGRETURN(0);
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
wait_for_process_timed(pid_t pid, time_t (*func)(void *),
void *ptr, time_t timeout)
{
@@ -98,7 +98,7 @@ wait_for_process_timed(pid_t pid, time_t (*func)(void *),
while(waitpid(pid, &status, 0) < 0) {
if (errno != EINTR) {
- ret = -3;
+ ret = SE_E_WAITPIDFAILED;
goto out;
}
if (func == NULL)
@@ -110,7 +110,7 @@ wait_for_process_timed(pid_t pid, time_t (*func)(void *),
kill(pid, SIGTERM);
continue;
} else if (timeout == (time_t)-2) {
- ret = -4;
+ ret = SE_E_EXECTIMEOUT;
goto out;
}
alarm(timeout);
@@ -134,13 +134,13 @@ wait_for_process_timed(pid_t pid, time_t (*func)(void *),
return ret;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
wait_for_process(pid_t pid)
{
return wait_for_process_timed(pid, NULL, NULL, 0);
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
pipe_execv(FILE **stdin_fd, FILE **stdout_fd, FILE **stderr_fd,
const char *file, ...)
{
@@ -211,7 +211,7 @@ pipe_execv(FILE **stdin_fd, FILE **stdout_fd, FILE **stderr_fd,
close(err_fd[0]);
close(err_fd[1]);
}
- return -2;
+ return SE_E_FORKFAILED;
default:
if(stdin_fd != NULL) {
close(in_fd[0]);
@@ -229,14 +229,14 @@ pipe_execv(FILE **stdin_fd, FILE **stdout_fd, FILE **stderr_fd,
return pid;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execvp_timed(const char *file, char *const args[],
time_t (*func)(void *), void *ptr, time_t timeout)
{
pid_t pid = fork();
switch(pid){
case -1:
- return -2;
+ return SE_E_FORKFAILED;
case 0:
execvp(file, args);
exit((errno == ENOENT) ? EX_NOTFOUND : EX_NOEXEC);
@@ -245,21 +245,21 @@ simple_execvp_timed(const char *file, char *const args[],
}
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execvp(const char *file, char *const args[])
{
return simple_execvp_timed(file, args, NULL, NULL, 0);
}
/* gee, I'd like a execvpe */
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execve_timed(const char *file, char *const args[], char *const envp[],
time_t (*func)(void *), void *ptr, time_t timeout)
{
pid_t pid = fork();
switch(pid){
case -1:
- return -2;
+ return SE_E_FORKFAILED;
case 0:
execve(file, args, envp);
exit((errno == ENOENT) ? EX_NOTFOUND : EX_NOEXEC);
@@ -268,13 +268,13 @@ simple_execve_timed(const char *file, char *const args[], char *const envp[],
}
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execve(const char *file, char *const args[], char *const envp[])
{
return simple_execve_timed(file, args, envp, NULL, NULL, 0);
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execlp(const char *file, ...)
{
va_list ap;
@@ -285,13 +285,13 @@ simple_execlp(const char *file, ...)
argv = vstrcollect(&ap);
va_end(ap);
if(argv == NULL)
- return -1;
+ return SE_E_UNSPECIFIED;
ret = simple_execvp(file, argv);
free(argv);
return ret;
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execle(const char *file, ... /* ,char *const envp[] */)
{
va_list ap;
@@ -304,7 +304,7 @@ simple_execle(const char *file, ... /* ,char *const envp[] */)
envp = va_arg(ap, char **);
va_end(ap);
if(argv == NULL)
- return -1;
+ return SE_E_UNSPECIFIED;
ret = simple_execve(file, argv, envp);
free(argv);
return ret;
diff --git a/source4/heimdal/lib/roken/socket.c b/source4/heimdal/lib/roken/socket.c
index ab1b7ff344..bfc4b7102b 100644
--- a/source4/heimdal/lib/roken/socket.c
+++ b/source4/heimdal/lib/roken/socket.c
@@ -40,7 +40,7 @@
* Set `sa' to the unitialized address of address family `af'
*/
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_any (struct sockaddr *sa, int af)
{
switch (af) {
@@ -74,7 +74,7 @@ socket_set_any (struct sockaddr *sa, int af)
* set `sa' to (`ptr', `port')
*/
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port)
{
switch (sa->sa_family) {
@@ -108,7 +108,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 ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_addr_size (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -120,7 +120,7 @@ socket_addr_size (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
- break;
+ UNREACHABLE(return 0);
}
}
@@ -128,7 +128,7 @@ socket_addr_size (const struct sockaddr *sa)
* Return the size of a `struct sockaddr' in `sa'.
*/
-size_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_sockaddr_size (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -140,7 +140,7 @@ socket_sockaddr_size (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
- break;
+ UNREACHABLE(return 0);
}
}
@@ -148,7 +148,7 @@ socket_sockaddr_size (const struct sockaddr *sa)
* Return the binary address of `sa'.
*/
-void * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
socket_get_address (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -164,7 +164,7 @@ socket_get_address (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
- break;
+ UNREACHABLE(return NULL);
}
}
@@ -172,7 +172,7 @@ socket_get_address (const struct sockaddr *sa)
* Return the port number from `sa'.
*/
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
socket_get_port (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -188,7 +188,7 @@ socket_get_port (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
- break;
+ UNREACHABLE(return 0);
}
}
@@ -196,7 +196,7 @@ socket_get_port (const struct sockaddr *sa)
* Set the port in `sa' to `port'.
*/
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_port (struct sockaddr *sa, int port)
{
switch (sa->sa_family) {
@@ -221,8 +221,8 @@ socket_set_port (struct sockaddr *sa, int port)
/*
* Set the range of ports to use when binding with port = 0.
*/
-void ROKEN_LIB_FUNCTION
-socket_set_portrange (int sock, int restr, int af)
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_portrange (rk_socket_t sock, int restr, int af)
{
#if defined(IP_PORTRANGE)
if (af == AF_INET) {
@@ -247,8 +247,8 @@ socket_set_portrange (int sock, int restr, int af)
* Enable debug on `sock'.
*/
-void ROKEN_LIB_FUNCTION
-socket_set_debug (int sock)
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_debug (rk_socket_t sock)
{
#if defined(SO_DEBUG) && defined(HAVE_SETSOCKOPT)
int on = 1;
@@ -262,8 +262,8 @@ socket_set_debug (int sock)
* Set the type-of-service of `sock' to `tos'.
*/
-void ROKEN_LIB_FUNCTION
-socket_set_tos (int sock, int tos)
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_tos (rk_socket_t sock, int tos)
{
#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
if (setsockopt (sock, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof (int)) < 0)
@@ -276,8 +276,8 @@ socket_set_tos (int sock, int tos)
* set the reuse of addresses on `sock' to `val'.
*/
-void ROKEN_LIB_FUNCTION
-socket_set_reuseaddr (int sock, int val)
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_reuseaddr (rk_socket_t sock, int val)
{
#if defined(SO_REUSEADDR) && defined(HAVE_SETSOCKOPT)
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&val,
@@ -290,10 +290,28 @@ socket_set_reuseaddr (int sock, int val)
* Set the that the `sock' should bind to only IPv6 addresses.
*/
-void ROKEN_LIB_FUNCTION
-socket_set_ipv6only (int sock, int val)
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_ipv6only (rk_socket_t sock, int val)
{
#if defined(IPV6_V6ONLY) && defined(HAVE_SETSOCKOPT)
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&val, sizeof(val));
#endif
}
+
+/**
+ * Create a file descriptor from a socket
+ *
+ * While the socket handle in \a sock can be used with WinSock
+ * functions after calling socket_to_fd(), it should not be closed
+ * with rk_closesocket(). The socket will be closed when the associated
+ * file descriptor is closed.
+ */
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+socket_to_fd(rk_socket_t sock, int flags)
+{
+#ifndef _WIN32
+ return sock;
+#else
+ return _open_osfhandle((intptr_t) sock, flags);
+#endif
+}
diff --git a/source4/heimdal/lib/roken/strcollect.c b/source4/heimdal/lib/roken/strcollect.c
index f444d05e25..0afc3f0c62 100644
--- a/source4/heimdal/lib/roken/strcollect.c
+++ b/source4/heimdal/lib/roken/strcollect.c
@@ -66,7 +66,7 @@ sub (char **argv, int i, int argc, va_list *ap)
* terminated by NULL.
*/
-char ** ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
vstrcollect(va_list *ap)
{
return sub (NULL, 0, 0, ap);
@@ -76,7 +76,7 @@ vstrcollect(va_list *ap)
*
*/
-char ** ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
strcollect(char *first, ...)
{
va_list ap;
diff --git a/source4/heimdal/lib/roken/strlwr.c b/source4/heimdal/lib/roken/strlwr.c
index 1a6634b736..68bd4edad3 100644
--- a/source4/heimdal/lib/roken/strlwr.c
+++ b/source4/heimdal/lib/roken/strlwr.c
@@ -38,7 +38,7 @@
#include "roken.h"
#ifndef HAVE_STRLWR
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
strlwr(char *str)
{
char *s;
diff --git a/source4/heimdal/lib/roken/strpool.c b/source4/heimdal/lib/roken/strpool.c
index 642d335dec..6e6a737bc6 100644
--- a/source4/heimdal/lib/roken/strpool.c
+++ b/source4/heimdal/lib/roken/strpool.c
@@ -46,7 +46,7 @@ struct rk_strpool {
*
*/
-void ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_strpoolfree(struct rk_strpool *p)
{
if (p->str) {
@@ -60,7 +60,7 @@ rk_strpoolfree(struct rk_strpool *p)
*
*/
-struct rk_strpool * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL
rk_strpoolprintf(struct rk_strpool *p, const char *fmt, ...)
{
va_list ap;
@@ -97,7 +97,7 @@ rk_strpoolprintf(struct rk_strpool *p, const char *fmt, ...)
*
*/
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_strpoolcollect(struct rk_strpool *p)
{
char *str;
diff --git a/source4/heimdal/lib/roken/strsep.c b/source4/heimdal/lib/roken/strsep.c
index 5cbf8557a5..76b447c373 100644
--- a/source4/heimdal/lib/roken/strsep.c
+++ b/source4/heimdal/lib/roken/strsep.c
@@ -39,7 +39,7 @@
#ifndef HAVE_STRSEP
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
strsep(char **str, const char *delim)
{
char *save = *str;
diff --git a/source4/heimdal/lib/roken/strsep_copy.c b/source4/heimdal/lib/roken/strsep_copy.c
index 908e37ca40..9624b5a46f 100644
--- a/source4/heimdal/lib/roken/strsep_copy.c
+++ b/source4/heimdal/lib/roken/strsep_copy.c
@@ -41,7 +41,7 @@
/* strsep, but with const stringp, so return string in buf */
-ssize_t ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
strsep_copy(const char **stringp, const char *delim, char *buf, size_t len)
{
const char *save = *stringp;
diff --git a/source4/heimdal/lib/roken/strupr.c b/source4/heimdal/lib/roken/strupr.c
index db2d987f9f..fdff7f44a8 100644
--- a/source4/heimdal/lib/roken/strupr.c
+++ b/source4/heimdal/lib/roken/strupr.c
@@ -38,7 +38,7 @@
#include "roken.h"
#ifndef HAVE_STRUPR
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
strupr(char *str)
{
char *s;
diff --git a/source4/heimdal/lib/roken/vis.c b/source4/heimdal/lib/roken/vis.c
index 155b148e86..19ff29d95c 100644
--- a/source4/heimdal/lib/roken/vis.c
+++ b/source4/heimdal/lib/roken/vis.c
@@ -106,17 +106,17 @@ static char *do_svis(char *, int, int, int, const char *);
#define BELL '\007'
#endif
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_vis (char *, int, int, int);
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_svis (char *, int, int, int, const char *);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strvis (char *, const char *, int);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strsvis (char *, const char *, int, const char *);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strvisx (char *, const char *, size_t, int);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strsvisx (char *, const char *, size_t, int, const char *);
@@ -249,7 +249,7 @@ do_svis(char *dst, int c, int flag, int nextc, const char *extra)
* svis - visually encode characters, also encoding the characters
* pointed to by `extra'
*/
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_svis(char *dst, int c, int flag, int nextc, const char *extra)
{
char *nextra = NULL;
@@ -286,7 +286,8 @@ rk_svis(char *dst, int c, int flag, int nextc, const char *extra)
* Strsvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
-int ROKEN_LIB_FUNCTION
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strsvis(char *dst, const char *csrc, int flag, const char *extra)
{
int c;
@@ -315,7 +316,7 @@ rk_strsvis(char *dst, const char *csrc, int flag, const char *extra)
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
{
unsigned char c;
@@ -353,7 +354,7 @@ rk_strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra
/*
* vis - visually encode characters
*/
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_vis(char *dst, int c, int flag, int nextc)
{
char *extra = NULL;
@@ -386,7 +387,7 @@ rk_vis(char *dst, int c, int flag, int nextc)
* Strvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strvis(char *dst, const char *src, int flag)
{
char *extra = NULL;
@@ -403,7 +404,7 @@ rk_strvis(char *dst, const char *src, int flag)
}
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strvisx(char *dst, const char *src, size_t len, int flag)
{
char *extra = NULL;
diff --git a/source4/heimdal/lib/roken/vis.hin b/source4/heimdal/lib/roken/vis.hin
index a1481b789e..25d662a980 100644
--- a/source4/heimdal/lib/roken/vis.hin
+++ b/source4/heimdal/lib/roken/vis.hin
@@ -36,9 +36,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
-#define ROKEN_LIB_FUNCTION _stdcall
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
#endif
#endif
@@ -84,24 +86,25 @@
ROKEN_CPP_START
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_vis(char *, int, int, int);
-char * ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_svis(char *, int, int, int, const char *);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strvis(char *, const char *, int);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strsvis(char *, const char *, int, const char *);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strvisx(char *, const char *, size_t, int);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strsvisx(char *, const char *, size_t, int, const char *);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strunvis(char *, const char *);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_strunvisx(char *, const char *, int);
-int ROKEN_LIB_FUNCTION
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_unvis(char *, int, int *, int);
+
ROKEN_CPP_END
#ifndef HAVE_VIS
diff --git a/source4/heimdal/lib/roken/xfree.c b/source4/heimdal/lib/roken/xfree.c
index 13366ce132..c7e30daf85 100644
--- a/source4/heimdal/lib/roken/xfree.c
+++ b/source4/heimdal/lib/roken/xfree.c
@@ -33,8 +33,6 @@
#include <config.h>
-#include <unistd.h>
-
#include "roken.h"
void ROKEN_LIB_FUNCTION