Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
60 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source4/heimdal/lib/roken/base64.c

    r414 r745  
    3636#include <stdlib.h>
    3737#include <string.h>
     38#include <limits.h>
    3839#include "base64.h"
    3940
     
    5152}
    5253
    53 int ROKEN_LIB_FUNCTION
     54ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    5455base64_encode(const void *data, int size, char **str)
    5556{
     
    9394    *p = 0;
    9495    *str = s;
    95     return strlen(s);
     96    return (int) strlen(s);
    9697}
    9798
     
    120121}
    121122
    122 int ROKEN_LIB_FUNCTION
     123ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    123124base64_decode(const char *str, void *data)
    124125{
  • trunk/server/source4/heimdal/lib/roken/base64.h

    r414 r745  
    3939#ifndef ROKEN_LIB_FUNCTION
    4040#ifdef _WIN32
    41 #define ROKEN_LIB_FUNCTION _stdcall
     41#define ROKEN_LIB_FUNCTION
     42#define ROKEN_LIB_CALL __cdecl
    4243#else
    4344#define ROKEN_LIB_FUNCTION
     45#define ROKEN_LIB_CALL
    4446#endif
    4547#endif
    4648
    47 int ROKEN_LIB_FUNCTION
     49ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    4850base64_encode(const void *, int, char **);
    4951
    50 int ROKEN_LIB_FUNCTION
     52ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    5153base64_decode(const char *, void *);
    5254
  • trunk/server/source4/heimdal/lib/roken/bswap.c

    r414 r745  
    3737#ifndef HAVE_BSWAP32
    3838
    39 unsigned int ROKEN_LIB_FUNCTION
     39ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
    4040bswap32 (unsigned int val)
    4141{
     
    4949#ifndef HAVE_BSWAP16
    5050
    51 unsigned short ROKEN_LIB_FUNCTION
     51ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL
    5252bswap16 (unsigned short val)
    5353{
  • trunk/server/source4/heimdal/lib/roken/cloexec.c

    r414 r745  
    3434#include <config.h>
    3535
    36 #include <unistd.h>
    37 #include <fcntl.h>
    38 
    3936#include "roken.h"
    4037
     
    4239rk_cloexec(int fd)
    4340{
     41#ifdef HAVE_FCNTL
    4442    int ret;
    4543
     
    4947    if (fcntl(fd, F_SETFD, ret | FD_CLOEXEC) == -1)
    5048        return;
     49#endif
    5150}
    5251
     
    5453rk_cloexec_file(FILE *f)
    5554{
     55#ifdef HAVE_FCNTL
    5656    rk_cloexec(fileno(f));
     57#endif
    5758}
     59
     60void ROKEN_LIB_FUNCTION
     61rk_cloexec_dir(DIR * d)
     62{
     63#ifndef _WIN32
     64    rk_cloexec(dirfd(d));
     65#endif
     66}
  • trunk/server/source4/heimdal/lib/roken/closefrom.c

    r414 r745  
    4343#include "roken.h"
    4444
    45 int ROKEN_LIB_FUNCTION
     45ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    4646closefrom(int fd)
    4747{
  • trunk/server/source4/heimdal/lib/roken/copyhostent.c

    r414 r745  
    4040 */
    4141
    42 struct hostent * ROKEN_LIB_FUNCTION
     42ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
    4343copyhostent (const struct hostent *h)
    4444{
  • trunk/server/source4/heimdal/lib/roken/dumpdata.c

    r414 r745  
    3434#include <config.h>
    3535
    36 #include <unistd.h>
    37 
    3836#include "roken.h"
    3937
     
    4240 */
    4341
    44 void ROKEN_LIB_FUNCTION
     42ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    4543rk_dumpdata (const char *filename, const void *buf, size_t size)
    4644{
     
    5856 */
    5957
    60 int ROKEN_LIB_FUNCTION
     58ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    6159rk_undumpdata(const char *filename, void **buf, size_t *size)
    6260{
  • trunk/server/source4/heimdal/lib/roken/ecalloc.c

    r414 r745  
    4343 */
    4444
    45 void * ROKEN_LIB_FUNCTION
     45ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
    4646ecalloc (size_t number, size_t size)
    4747{
  • trunk/server/source4/heimdal/lib/roken/emalloc.c

    r414 r745  
    4343 */
    4444
    45 void * ROKEN_LIB_FUNCTION
     45ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
    4646emalloc (size_t sz)
    4747{
  • trunk/server/source4/heimdal/lib/roken/erealloc.c

    r414 r745  
    4343 */
    4444
    45 void * ROKEN_LIB_FUNCTION
     45ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
    4646erealloc (void *ptr, size_t sz)
    4747{
  • trunk/server/source4/heimdal/lib/roken/err.hin

    r414 r745  
    4949#ifndef ROKEN_LIB_FUNCTION
    5050#ifdef _WIN32
    51 #define ROKEN_LIB_FUNCTION _stdcall
     51#define ROKEN_LIB_FUNCTION
     52#define ROKEN_LIB_CALL     __cdecl
    5253#else
    5354#define ROKEN_LIB_FUNCTION
     55#define ROKEN_LIB_CALL
    5456#endif
    5557#endif
    5658
    57 void ROKEN_LIB_FUNCTION
     59ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    5860verr(int eval, const char *fmt, va_list ap)
    5961     __attribute__ ((noreturn, format (printf, 2, 0)));
    6062
    61 void ROKEN_LIB_FUNCTION
     63ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    6264err(int eval, const char *fmt, ...)
    6365     __attribute__ ((noreturn, format (printf, 2, 3)));
    6466
    65 void ROKEN_LIB_FUNCTION
     67ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    6668verrx(int eval, const char *fmt, va_list ap)
    6769     __attribute__ ((noreturn, format (printf, 2, 0)));
    6870
    69 void ROKEN_LIB_FUNCTION
     71ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    7072errx(int eval, const char *fmt, ...)
    7173     __attribute__ ((noreturn, format (printf, 2, 3)));
    72 void ROKEN_LIB_FUNCTION
     74ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    7375vwarn(const char *fmt, va_list ap)
    7476     __attribute__ ((format (printf, 1, 0)));
    7577
    76 void ROKEN_LIB_FUNCTION
     78ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    7779warn(const char *fmt, ...)
    7880     __attribute__ ((format (printf, 1, 2)));
    7981
    80 void ROKEN_LIB_FUNCTION
     82ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    8183vwarnx(const char *fmt, va_list ap)
    8284     __attribute__ ((format (printf, 1, 0)));
    8385
    84 void ROKEN_LIB_FUNCTION
     86ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    8587warnx(const char *fmt, ...)
    8688     __attribute__ ((format (printf, 1, 2)));
  • trunk/server/source4/heimdal/lib/roken/estrdup.c

    r414 r745  
    4343 */
    4444
    45 char * ROKEN_LIB_FUNCTION
     45ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    4646estrdup (const char *str)
    4747{
  • trunk/server/source4/heimdal/lib/roken/freeaddrinfo.c

    r414 r745  
    4040 */
    4141
    42 void ROKEN_LIB_FUNCTION
     42ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    4343freeaddrinfo(struct addrinfo *ai)
    4444{
  • trunk/server/source4/heimdal/lib/roken/freehostent.c

    r414 r745  
    4040 */
    4141
    42 void ROKEN_LIB_FUNCTION
     42ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    4343freehostent (struct hostent *h)
    4444{
  • trunk/server/source4/heimdal/lib/roken/gai_strerror.c

    r414 r745  
    6363 */
    6464
    65 const char * ROKEN_LIB_FUNCTION
     65ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    6666gai_strerror(int ecode)
    6767{
  • trunk/server/source4/heimdal/lib/roken/get_window_size.c

    r414 r745  
    5858#include "roken.h"
    5959
    60 int ROKEN_LIB_FUNCTION
     60ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    6161get_window_size(int fd, struct winsize *wp)
    6262{
     
    8686        ret = 0;
    8787    }
     88#elif defined(_WIN32)
     89    {
     90        intptr_t fh = 0;
     91        CONSOLE_SCREEN_BUFFER_INFO sb_info;
     92
     93        fh = _get_osfhandle(fd);
     94        if (fh != (intptr_t) INVALID_HANDLE_VALUE &&
     95            GetConsoleScreenBufferInfo((HANDLE) fh, &sb_info)) {
     96            wp->ws_row = 1 + sb_info.srWindow.Bottom - sb_info.srWindow.Top;
     97            wp->ws_col = 1 + sb_info.srWindow.Right - sb_info.srWindow.Left;
     98
     99            ret = 0;
     100        }
     101    }
    88102#endif
    89103    if (ret != 0) {
  • trunk/server/source4/heimdal/lib/roken/getaddrinfo.c

    r414 r745  
    366366 */
    367367
    368 int ROKEN_LIB_FUNCTION
     368ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    369369getaddrinfo(const char *nodename,
    370370            const char *servname,
  • trunk/server/source4/heimdal/lib/roken/getarg.c

    r414 r745  
    9292                char *(i18n)(const char *))
    9393{
    94     int i;
     94    size_t i;
    9595    char timestr[64], cmd[64];
    9696    char buf[128];
     
    208208}
    209209
    210 void ROKEN_LIB_FUNCTION
     210ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    211211arg_printusage (struct getargs *args,
    212212                size_t num_args,
     
    218218}
    219219
    220 void ROKEN_LIB_FUNCTION
     220ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    221221arg_printusage_i18n (struct getargs *args,
    222222                     size_t num_args,
     
    224224                     const char *progname,
    225225                     const char *extra_string,
    226                      char *(i18n)(const char *))
    227 {
    228     int i;
    229     size_t max_len = 0;
     226                     char *(*i18n)(const char *))
     227{
     228    size_t i, max_len = 0;
    230229    char buf[128];
    231230    int col = 0, columns;
     
    437436            return 0;
    438437        } else if (*goptarg && strcmp(goptarg + 1, "maybe") == 0) {
    439 #ifdef HAVE_RANDOM
    440             *flag = random() & 1;
    441 #else
    442             *flag = rand() & 1;
    443 #endif
     438            *flag = rk_random() & 1;
    444439        } else {
    445440            *flag = negate;
     
    475470    default:
    476471        abort ();
    477     }
    478 
    479     /* not reached */
    480     return ARG_ERR_NO_MATCH;
     472        UNREACHABLE(return 0);
     473    }
    481474}
    482475
     
    551544}
    552545
    553 int ROKEN_LIB_FUNCTION
     546ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    554547getarg(struct getargs *args, size_t num_args,
    555548       int argc, char **argv, int *goptind)
     
    558551    int ret = 0;
    559552
    560 #if defined(HAVE_SRANDOMDEV)
    561     srandomdev();
    562 #elif defined(HAVE_RANDOM)
    563     srandom(time(NULL));
    564 #else
    565     srand (time(NULL));
    566 #endif
     553    rk_random_init();
    567554    (*goptind)++;
    568555    for(i = *goptind; i < argc; i++) {
     
    587574}
    588575
    589 void ROKEN_LIB_FUNCTION
     576ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    590577free_getarg_strings (getarg_strings *s)
    591578{
  • trunk/server/source4/heimdal/lib/roken/getarg.h

    r414 r745  
    4141#ifndef ROKEN_LIB_FUNCTION
    4242#ifdef _WIN32
    43 #define ROKEN_LIB_FUNCTION _stdcall
     43#define ROKEN_LIB_FUNCTION
     44#define ROKEN_LIB_CALL     __cdecl
    4445#else
    4546#define ROKEN_LIB_FUNCTION
     47#define ROKEN_LIB_CALL
    4648#endif
    4749#endif
     
    8789} getarg_collect_info;
    8890
    89 int ROKEN_LIB_FUNCTION
     91ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    9092getarg(struct getargs *args, size_t num_args,
    9193       int argc, char **argv, int *goptind);
    9294
    93 void ROKEN_LIB_FUNCTION
     95ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    9496arg_printusage (struct getargs *args,
    9597                size_t num_args,
     
    9799                const char *extra_string);
    98100
    99 void ROKEN_LIB_FUNCTION
     101ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    100102arg_printusage_i18n (struct getargs *args,
    101103                     size_t num_args,
     
    103105                     const char *progname,
    104106                     const char *extra_string,
    105                      char *(i18n)(const char *));
     107                     char *(*i18n)(const char *));
    106108
    107 void ROKEN_LIB_FUNCTION
     109ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    108110free_getarg_strings (getarg_strings *);
    109111
  • trunk/server/source4/heimdal/lib/roken/getdtablesize.c

    r414 r745  
    6262#endif
    6363
    64 int ROKEN_LIB_FUNCTION
     64ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    6565getdtablesize(void)
    6666{
  • trunk/server/source4/heimdal/lib/roken/getipnodebyaddr.c

    r414 r745  
    4141 */
    4242
    43 struct hostent * ROKEN_LIB_FUNCTION
     43ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
    4444getipnodebyaddr (const void *src, size_t len, int af, int *error_num)
    4545{
  • trunk/server/source4/heimdal/lib/roken/getipnodebyname.c

    r414 r745  
    4545 */
    4646
    47 struct hostent * ROKEN_LIB_FUNCTION
     47ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
    4848getipnodebyname (const char *name, int af, int flags, int *error_num)
    4949{
  • trunk/server/source4/heimdal/lib/roken/getnameinfo.c

    r414 r745  
    9292 */
    9393
    94 int ROKEN_LIB_FUNCTION
     94ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    9595getnameinfo(const struct sockaddr *sa, socklen_t salen,
    9696            char *host, size_t hostlen,
  • trunk/server/source4/heimdal/lib/roken/getprogname.c

    r414 r745  
    4141
    4242#ifndef HAVE_GETPROGNAME
    43 const char * ROKEN_LIB_FUNCTION
     43ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    4444getprogname(void)
    4545{
  • trunk/server/source4/heimdal/lib/roken/hex.c

    r414 r745  
    5151}
    5252
    53 ssize_t ROKEN_LIB_FUNCTION
     53ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    5454hex_encode(const void *data, size_t size, char **str)
    5555{
     
    8181}
    8282
    83 ssize_t ROKEN_LIB_FUNCTION
     83ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    8484hex_decode(const char *str, void *data, size_t len)
    8585{
  • trunk/server/source4/heimdal/lib/roken/hex.h

    r414 r745  
    3939#ifndef ROKEN_LIB_FUNCTION
    4040#ifdef _WIN32
    41 #define ROKEN_LIB_FUNCTION _stdcall
     41#define ROKEN_LIB_FUNCTION
     42#define ROKEN_LIB_CALL     __cdecl
    4243#else
    4344#define ROKEN_LIB_FUNCTION
     45#define ROKEN_LIB_CALL
    4446#endif
    4547#endif
     
    4850#define hex_decode rk_hex_decode
    4951
    50 ssize_t ROKEN_LIB_FUNCTION
     52ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    5153        hex_encode(const void *, size_t, char **);
    52 ssize_t ROKEN_LIB_FUNCTION
     54ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    5355        hex_decode(const char *, void *, size_t);
    5456
  • trunk/server/source4/heimdal/lib/roken/hostent_find_fqdn.c

    r414 r745  
    4040 */
    4141
    42 const char * ROKEN_LIB_FUNCTION
     42ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    4343hostent_find_fqdn (const struct hostent *he)
    4444{
  • trunk/server/source4/heimdal/lib/roken/inet_aton.c

    r414 r745  
    3939 * Cannot distinguish between failure and a local broadcast address. */
    4040
    41 int ROKEN_LIB_FUNCTION
     41ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    4242inet_aton(const char *cp, struct in_addr *addr)
    4343{
  • trunk/server/source4/heimdal/lib/roken/inet_ntop.c

    r414 r745  
    8484    const u_char *ptr = addr->s6_addr;
    8585    const char *orig_dst = dst;
     86    int compressed = 0;
    8687
    8788    if (size < INET6_ADDRSTRLEN) {
     
    9192    for (i = 0; i < 8; ++i) {
    9293        int non_zerop = 0;
     94
     95        if (compressed == 0 &&
     96            ptr[0] == 0 && ptr[1] == 0 &&
     97            i <= 5 &&
     98            ptr[2] == 0 && ptr[3] == 0 &&
     99            ptr[4] == 0 && ptr[5] == 0) {
     100
     101            compressed = 1;
     102
     103            if (i == 0)
     104                *dst++ = ':';
     105            *dst++ = ':';
     106
     107            for (ptr += 6, i += 3;
     108                 i < 8 && ptr[0] == 0 && ptr[1] == 0;
     109                 ++i, ptr += 2);
     110
     111            if (i >= 8)
     112                break;
     113        }
    93114
    94115        if (non_zerop || (ptr[0] >> 4)) {
     
    114135#endif /* HAVE_IPV6 */
    115136
    116 const char * ROKEN_LIB_FUNCTION
     137ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    117138inet_ntop(int af, const void *src, char *dst, size_t size)
    118139{
  • trunk/server/source4/heimdal/lib/roken/inet_pton.c

    r414 r745  
    3636#include "roken.h"
    3737
    38 int ROKEN_LIB_FUNCTION
     38#ifdef HAVE_WINSOCK
     39
     40ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     41inet_pton(int af, const char *csrc, void *dst)
     42{
     43    char * src;
     44
     45    if (csrc == NULL || (src = strdup(csrc)) == NULL) {
     46        _set_errno( ENOMEM );
     47        return 0;
     48    }
     49
     50    switch (af) {
     51    case AF_INET:
     52        {
     53            struct sockaddr_in  si4;
     54            INT r;
     55            INT s = sizeof(si4);
     56
     57            si4.sin_family = AF_INET;
     58            r = WSAStringToAddress(src, AF_INET, NULL, (LPSOCKADDR) &si4, &s);
     59            free(src);
     60            src = NULL;
     61
     62            if (r == 0) {
     63                memcpy(dst, &si4.sin_addr, sizeof(si4.sin_addr));
     64                return 1;
     65            }
     66        }
     67        break;
     68
     69    case AF_INET6:
     70        {
     71            struct sockaddr_in6 si6;
     72            INT r;
     73            INT s = sizeof(si6);
     74
     75            si6.sin6_family = AF_INET6;
     76            r = WSAStringToAddress(src, AF_INET6, NULL, (LPSOCKADDR) &si6, &s);
     77            free(src);
     78            src = NULL;
     79
     80            if (r == 0) {
     81                memcpy(dst, &si6.sin6_addr, sizeof(si6.sin6_addr));
     82                return 1;
     83            }
     84        }
     85        break;
     86
     87    default:
     88        _set_errno( EAFNOSUPPORT );
     89        return -1;
     90    }
     91
     92    /* the call failed */
     93    {
     94        int le = WSAGetLastError();
     95
     96        if (le == WSAEINVAL)
     97            return 0;
     98
     99        _set_errno(le);
     100        return -1;
     101    }
     102}
     103
     104#else  /* !HAVE_WINSOCK */
     105
     106ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    39107inet_pton(int af, const char *src, void *dst)
    40108{
     
    45113    return inet_aton (src, dst);
    46114}
     115
     116#endif
  • trunk/server/source4/heimdal/lib/roken/issuid.c

    r414 r745  
    3636#include "roken.h"
    3737
    38 int ROKEN_LIB_FUNCTION
     38ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    3939issuid(void)
    4040{
  • trunk/server/source4/heimdal/lib/roken/net_read.c

    r414 r745  
    3434#include <config.h>
    3535
    36 #include <sys/types.h>
    37 #include <unistd.h>
    38 #include <errno.h>
    39 
    4036#include "roken.h"
    4137
     
    4440 */
    4541
    46 ssize_t ROKEN_LIB_FUNCTION
    47 net_read (int fd, void *buf, size_t nbytes)
     42#ifndef _WIN32
     43
     44ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
     45net_read (rk_socket_t fd, void *buf, size_t nbytes)
    4846{
    4947    char *cbuf = (char *)buf;
     
    5250
    5351    while (rem > 0) {
    54 #ifdef WIN32
    55         count = recv (fd, cbuf, rem, 0);
    56 #else
    5752        count = read (fd, cbuf, rem);
    58 #endif
    5953        if (count < 0) {
    6054            if (errno == EINTR)
     
    7064    return nbytes;
    7165}
     66
     67#else
     68
     69ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
     70net_read(rk_socket_t sock, void *buf, size_t nbytes)
     71{
     72    char *cbuf = (char *)buf;
     73    ssize_t count;
     74    size_t rem = nbytes;
     75
     76#ifdef SOCKET_IS_NOT_AN_FD
     77    int use_read = 0;
     78#endif
     79
     80    while (rem > 0) {
     81#ifdef SOCKET_IS_NOT_AN_FD
     82        if (use_read)
     83            count = _read (sock, cbuf, rem);
     84        else
     85            count = recv (sock, cbuf, rem, 0);
     86
     87        if (use_read == 0 &&
     88            rk_IS_SOCKET_ERROR(count) &&
     89            (rk_SOCK_ERRNO == WSANOTINITIALISED ||
     90             rk_SOCK_ERRNO == WSAENOTSOCK)) {
     91            use_read = 1;
     92
     93            count = _read (sock, cbuf, rem);
     94        }
     95#else
     96        count = recv (sock, cbuf, rem, 0);
     97#endif
     98        if (count < 0) {
     99
     100            /* With WinSock, the error EINTR (WSAEINTR), is used to
     101               indicate that a blocking call was cancelled using
     102               WSACancelBlockingCall(). */
     103
     104#ifndef HAVE_WINSOCK
     105            if (rk_SOCK_ERRNO == EINTR)
     106                continue;
     107#endif
     108            return count;
     109        } else if (count == 0) {
     110            return count;
     111        }
     112        cbuf += count;
     113        rem -= count;
     114    }
     115    return nbytes;
     116}
     117
     118#endif
  • trunk/server/source4/heimdal/lib/roken/net_write.c

    r414 r745  
    3434#include <config.h>
    3535
    36 #include <sys/types.h>
    37 #include <unistd.h>
    38 #include <errno.h>
    39 
    4036#include "roken.h"
    4137
     
    4440 */
    4541
    46 ssize_t ROKEN_LIB_FUNCTION
    47 net_write (int fd, const void *buf, size_t nbytes)
     42#ifndef _WIN32
     43
     44ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
     45net_write (rk_socket_t fd, const void *buf, size_t nbytes)
    4846{
    4947    const char *cbuf = (const char *)buf;
     
    5250
    5351    while (rem > 0) {
    54 #ifdef WIN32
    55         count = send (fd, cbuf, rem, 0);
     52        count = write (fd, cbuf, rem);
     53        if (count < 0) {
     54            if (errno == EINTR)
     55                continue;
     56            else
     57                return count;
     58        }
     59        cbuf += count;
     60        rem -= count;
     61    }
     62    return nbytes;
     63}
     64
    5665#else
    57         count = write (fd, cbuf, rem);
     66
     67ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
     68net_write(rk_socket_t sock, const void *buf, size_t nbytes)
     69{
     70    const char *cbuf = (const char *)buf;
     71    ssize_t count;
     72    size_t rem = nbytes;
     73#ifdef SOCKET_IS_NOT_AN_FD
     74    int use_write = 0;
     75#endif
     76
     77    while (rem > 0) {
     78#ifdef SOCKET_IS_NOT_AN_FD
     79        if (use_write)
     80            count = _write (sock, cbuf, rem);
     81        else
     82            count = send (sock, cbuf, rem, 0);
     83
     84        if (use_write == 0 &&
     85            rk_IS_SOCKET_ERROR(count) &&
     86            (rk_SOCK_ERRNO == WSANOTINITIALISED ||
     87             rk_SOCK_ERRNO == WSAENOTSOCK)) {
     88            use_write = 1;
     89
     90            count = _write (sock, cbuf, rem);
     91        }
     92#else
     93        count = send (sock, cbuf, rem, 0);
    5894#endif
    5995        if (count < 0) {
     
    68104    return nbytes;
    69105}
     106
     107#endif
  • trunk/server/source4/heimdal/lib/roken/parse_bytes.h

    r414 r745  
    3939#ifndef ROKEN_LIB_FUNCTION
    4040#ifdef _WIN32
    41 #define ROKEN_LIB_FUNCTION _stdcall
     41#define ROKEN_LIB_FUNCTION
     42#define ROKEN_LIB_CALL     __cdecl
    4243#else
    4344#define ROKEN_LIB_FUNCTION
     45#define ROKEN_LIB_CALL
    4446#endif
    4547#endif
    4648
    47 int ROKEN_LIB_FUNCTION
     49ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    4850parse_bytes (const char *s, const char *def_unit);
    4951
    50 int ROKEN_LIB_FUNCTION
     52ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    5153unparse_bytes (int t, char *s, size_t len);
    5254
    53 int ROKEN_LIB_FUNCTION
     55ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    5456unparse_bytes_short (int t, char *s, size_t len);
    5557
  • trunk/server/source4/heimdal/lib/roken/parse_time.c

    r414 r745  
    5151};
    5252
    53 int ROKEN_LIB_FUNCTION
     53ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    5454parse_time (const char *s, const char *def_unit)
    5555{
     
    5757}
    5858
    59 size_t ROKEN_LIB_FUNCTION
     59ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    6060unparse_time (int t, char *s, size_t len)
    6161{
     
    6363}
    6464
    65 size_t ROKEN_LIB_FUNCTION
     65ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    6666unparse_time_approx (int t, char *s, size_t len)
    6767{
     
    6969}
    7070
    71 void ROKEN_LIB_FUNCTION
     71ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    7272print_time_table (FILE *f)
    7373{
  • trunk/server/source4/heimdal/lib/roken/parse_time.h

    r414 r745  
    3939#ifndef ROKEN_LIB_FUNCTION
    4040#ifdef _WIN32
    41 #define ROKEN_LIB_FUNCTION _stdcall
     41#define ROKEN_LIB_FUNCTION
     42#define ROKEN_LIB_CALL     __cdecl
    4243#else
    4344#define ROKEN_LIB_FUNCTION
     45#define ROKEN_LIB_CALL
    4446#endif
    4547#endif
    4648
    47 int
     49ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    4850parse_time (const char *s, const char *def_unit);
    4951
    50 size_t
     52ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    5153unparse_time (int t, char *s, size_t len);
    5254
    53 size_t
     55ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    5456unparse_time_approx (int t, char *s, size_t len);
    5557
    56 void
     58ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    5759print_time_table (FILE *f);
    5860
  • trunk/server/source4/heimdal/lib/roken/parse_units.c

    r414 r745  
    7171    p = s;
    7272    while (*p) {
    73         double val;
     73        int val;
    7474        char *next;
    7575        const struct units *u, *partial_unit;
     
    8181            ++p;
    8282
    83         val = strtod (p, &next); /* strtol(p, &next, 0); */
     83        val = strtol(p, &next, 0);
    8484        if (p == next) {
    8585            val = 0;
     
    150150}
    151151
    152 int ROKEN_LIB_FUNCTION
     152ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    153153parse_units (const char *s, const struct units *units,
    154154             const char *def_unit)
     
    176176}
    177177
    178 int ROKEN_LIB_FUNCTION
     178ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    179179parse_flags (const char *s, const struct units *units,
    180180             int orig)
     
    209209            if (tmp < 0)
    210210                return tmp;
    211             if (tmp > len) {
     211            if (tmp > (int) len) {
    212212                len = 0;
    213213                s = NULL;
     
    246246}
    247247
    248 int ROKEN_LIB_FUNCTION
     248ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    249249unparse_units (int num, const struct units *units, char *s, size_t len)
    250250{
     
    255255}
    256256
    257 int ROKEN_LIB_FUNCTION
     257ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    258258unparse_units_approx (int num, const struct units *units, char *s, size_t len)
    259259{
     
    264264}
    265265
    266 void ROKEN_LIB_FUNCTION
     266ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    267267print_units_table (const struct units *units, FILE *f)
    268268{
     
    309309}
    310310
    311 int ROKEN_LIB_FUNCTION
     311ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    312312unparse_flags (int num, const struct units *units, char *s, size_t len)
    313313{
     
    318318}
    319319
    320 void ROKEN_LIB_FUNCTION
     320ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    321321print_flags_table (const struct units *units, FILE *f)
    322322{
  • trunk/server/source4/heimdal/lib/roken/parse_units.h

    r414 r745  
    4242#ifndef ROKEN_LIB_FUNCTION
    4343#ifdef _WIN32
    44 #define ROKEN_LIB_FUNCTION _stdcall
     44#define ROKEN_LIB_FUNCTION
     45#define ROKEN_LIB_CALL     __cdecl
    4546#else
    4647#define ROKEN_LIB_FUNCTION
     48#define ROKEN_LIB_CALL
    4749#endif
    4850#endif
     
    5355};
    5456
    55 int ROKEN_LIB_FUNCTION
     57ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    5658parse_units (const char *s, const struct units *units,
    5759             const char *def_unit);
    5860
    59 void ROKEN_LIB_FUNCTION
     61ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    6062print_units_table (const struct units *units, FILE *f);
    6163
    62 int ROKEN_LIB_FUNCTION
     64ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    6365parse_flags (const char *s, const struct units *units,
    6466             int orig);
    6567
    66 int ROKEN_LIB_FUNCTION
     68ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    6769unparse_units (int num, const struct units *units, char *s, size_t len);
    6870
    69 int ROKEN_LIB_FUNCTION
     71ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7072unparse_units_approx (int num, const struct units *units, char *s,
    7173                      size_t len);
    7274
    73 int ROKEN_LIB_FUNCTION
     75ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7476unparse_flags (int num, const struct units *units, char *s, size_t len);
    7577
    76 void ROKEN_LIB_FUNCTION
     78ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    7779print_flags_table (const struct units *units, FILE *f);
    7880
  • trunk/server/source4/heimdal/lib/roken/resolve.c

    r414 r745  
    4949#include <assert.h>
    5050
    51 RCSID("$Id$");
    52 
    5351#ifdef _AIX /* AIX have broken res_nsearch() in 5.1 (5.0 also ?) */
    5452#undef HAVE_RES_NSEARCH
     
    8179int _resolve_debug = 0;
    8280
    83 int ROKEN_LIB_FUNCTION
     81ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    8482rk_dns_string_to_type(const char *name)
    8583{
     
    9189}
    9290
    93 const char * ROKEN_LIB_FUNCTION
     91ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    9492rk_dns_type_to_string(int type)
    9593{
     
    10199}
    102100
    103 #if (defined(HAVE_RES_SEARCH) || defined(HAVE_RES_NSEARCH)) && defined(HAVE_DN_EXPAND)
     101#if ((defined(HAVE_RES_SEARCH) || defined(HAVE_RES_NSEARCH)) && defined(HAVE_DN_EXPAND)) || defined(HAVE_WINDNS)
    104102
    105103static void
     
    113111}
    114112
    115 void ROKEN_LIB_FUNCTION
     113ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    116114rk_dns_free_data(struct rk_dns_reply *r)
    117115{
     
    126124    free (r);
    127125}
     126
     127#ifndef HAVE_WINDNS
    128128
    129129static int
     
    524524    struct rk_dns_reply *r;
    525525    void *reply = NULL;
    526     int size;
    527     int len;
     526    int size, len;
    528527#if defined(HAVE_DNS_SEARCH)
    529528    struct sockaddr_storage from;
     
    543542#endif
    544543
    545     size = 0;
    546     len = 1000;
    547     do {
     544    len = 1500;
     545    while(1) {
    548546        if (reply) {
    549547            free(reply);
    550548            reply = NULL;
    551549        }
    552         if (size <= len)
    553             size = len;
    554550        if (_resolve_debug) {
    555551#if defined(HAVE_DNS_SEARCH)
     
    559555#endif
    560556            fprintf(stderr, "dns_lookup(%s, %d, %s), buffer size %d\n", domain,
    561                     rr_class, rk_dns_type_to_string(rr_type), size);
    562         }
    563         reply = malloc(size);
     557                    rr_class, rk_dns_type_to_string(rr_type), len);
     558        }
     559        reply = malloc(len);
    564560        if (reply == NULL) {
    565561            resolve_free_handle(handle);
     
    567563        }
    568564
    569         len = resolve_search(handle, domain, rr_class, rr_type, reply, size);
     565        size = resolve_search(handle, domain, rr_class, rr_type, reply, len);
    570566
    571567        if (_resolve_debug) {
    572568            fprintf(stderr, "dns_lookup(%s, %d, %s) --> %d\n",
    573                     domain, rr_class, rk_dns_type_to_string(rr_type), len);
    574         }
    575         if (len <= 0) {
     569                    domain, rr_class, rk_dns_type_to_string(rr_type), size);
     570        }
     571        if (size > len) {
     572            /* resolver thinks it know better, go for it */
     573            len = size;
     574        } else if (size > 0) {
     575            /* got a good reply */
     576            break;
     577        } else if (size <= 0 && len < rk_DNS_MAX_PACKET_SIZE) {
     578            len *= 2;
     579            if (len > rk_DNS_MAX_PACKET_SIZE)
     580                len = rk_DNS_MAX_PACKET_SIZE;
     581        } else {
     582            /* the end, leave */
    576583            resolve_free_handle(handle);
    577584            free(reply);
    578585            return NULL;
    579586        }
    580     } while (size < len && len < rk_DNS_MAX_PACKET_SIZE);
    581     resolve_free_handle(handle);
     587    }
    582588
    583589    len = min(len, size);
     
    587593}
    588594
    589 struct rk_dns_reply * ROKEN_LIB_FUNCTION
     595ROKEN_LIB_FUNCTION struct rk_dns_reply * ROKEN_LIB_CALL
    590596rk_dns_lookup(const char *domain, const char *type_name)
    591597{
     
    602608}
    603609
     610#endif  /* !HAVE_WINDNS */
     611
    604612static int
    605613compare_srv(const void *a, const void *b)
     
    612620}
    613621
    614 #ifndef HAVE_RANDOM
    615 #define random() rand()
    616 #endif
    617 
    618622/* try to rearrange the srv-records by the algorithm in RFC2782 */
    619 void ROKEN_LIB_FUNCTION
     623ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    620624rk_dns_srv_order(struct rk_dns_reply *r)
    621625{
     
    628632    char *oldstate;
    629633#endif
     634
     635    rk_random_init();
    630636
    631637    for(rr = r->head; rr; rr = rr->next)
     
    675681           first of the next */
    676682        while(ss < ee) {
    677             rnd = random() % (sum + 1);
     683            rnd = rk_random() % (sum + 1);
    678684            for(count = 0, tt = ss; ; tt++) {
    679685                if(*tt == NULL)
     
    705711}
    706712
     713#ifdef HAVE_WINDNS
     714
     715#include <WinDNS.h>
     716
     717static struct rk_resource_record *
     718parse_dns_record(PDNS_RECORD pRec)
     719{
     720    struct rk_resource_record * rr;
     721
     722    if (pRec == NULL)
     723        return NULL;
     724
     725    rr = calloc(1, sizeof(*rr));
     726
     727    rr->domain = strdup(pRec->pName);
     728    rr->type = pRec->wType;
     729    rr->class = 0;
     730    rr->ttl = pRec->dwTtl;
     731    rr->size = 0;
     732
     733    switch (rr->type) {
     734    case rk_ns_t_ns:
     735    case rk_ns_t_cname:
     736    case rk_ns_t_ptr:
     737        rr->u.txt = strdup(pRec->Data.NS.pNameHost);
     738        if(rr->u.txt == NULL) {
     739            dns_free_rr(rr);
     740            return NULL;
     741        }
     742        break;
     743
     744    case rk_ns_t_mx:
     745    case rk_ns_t_afsdb:{
     746        size_t hostlen = strnlen(pRec->Data.MX.pNameExchange, DNS_MAX_NAME_LENGTH);
     747
     748        rr->u.mx = (struct mx_record *)malloc(sizeof(struct mx_record) +
     749                                              hostlen);
     750        if (rr->u.mx == NULL) {
     751            dns_free_rr(rr);
     752            return NULL;
     753        }
     754
     755        strcpy_s(rr->u.mx->domain, hostlen + 1, pRec->Data.MX.pNameExchange);
     756        rr->u.mx->preference = pRec->Data.MX.wPreference;
     757        break;
     758    }
     759
     760    case rk_ns_t_srv:{
     761        size_t hostlen = strnlen(pRec->Data.SRV.pNameTarget, DNS_MAX_NAME_LENGTH);
     762
     763        rr->u.srv =
     764            (struct srv_record*)malloc(sizeof(struct srv_record) +
     765                                       hostlen);
     766        if(rr->u.srv == NULL) {
     767            dns_free_rr(rr);
     768            return NULL;
     769        }
     770
     771        rr->u.srv->priority = pRec->Data.SRV.wPriority;
     772        rr->u.srv->weight = pRec->Data.SRV.wWeight;
     773        rr->u.srv->port = pRec->Data.SRV.wPort;
     774        strcpy_s(rr->u.srv->target, hostlen + 1, pRec->Data.SRV.pNameTarget);
     775
     776        break;
     777    }
     778
     779    case rk_ns_t_txt:{
     780        size_t len;
     781
     782        if (pRec->Data.TXT.dwStringCount == 0) {
     783            rr->u.txt = strdup("");
     784            break;
     785        }
     786
     787        len = strnlen(pRec->Data.TXT.pStringArray[0], DNS_MAX_TEXT_STRING_LENGTH);
     788
     789        rr->u.txt = (char *)malloc(len + 1);
     790        strcpy_s(rr->u.txt, len + 1, pRec->Data.TXT.pStringArray[0]);
     791
     792        break;
     793    }
     794
     795    case rk_ns_t_key : {
     796        size_t key_len;
     797
     798        if (pRec->wDataLength < 4) {
     799            dns_free_rr(rr);
     800            return NULL;
     801        }
     802
     803        key_len = pRec->wDataLength - 4;
     804        rr->u.key = malloc (sizeof(*rr->u.key) + key_len - 1);
     805        if (rr->u.key == NULL) {
     806            dns_free_rr(rr);
     807            return NULL;
     808        }
     809
     810        rr->u.key->flags     = pRec->Data.KEY.wFlags;
     811        rr->u.key->protocol  = pRec->Data.KEY.chProtocol;
     812        rr->u.key->algorithm = pRec->Data.KEY.chAlgorithm;
     813        rr->u.key->key_len   = key_len;
     814        memcpy_s (rr->u.key->key_data, key_len,
     815                  pRec->Data.KEY.Key, key_len);
     816        break;
     817    }
     818
     819    case rk_ns_t_sig : {
     820        size_t sig_len, hostlen;
     821
     822        if(pRec->wDataLength <= 18) {
     823            dns_free_rr(rr);
     824            return NULL;
     825        }
     826
     827        sig_len = pRec->wDataLength;
     828
     829        hostlen = strnlen(pRec->Data.SIG.pNameSigner, DNS_MAX_NAME_LENGTH);
     830
     831        rr->u.sig = malloc(sizeof(*rr->u.sig)
     832                              + hostlen + sig_len);
     833        if (rr->u.sig == NULL) {
     834            dns_free_rr(rr);
     835            return NULL;
     836        }
     837        rr->u.sig->type           = pRec->Data.SIG.wTypeCovered;
     838        rr->u.sig->algorithm      = pRec->Data.SIG.chAlgorithm;
     839        rr->u.sig->labels         = pRec->Data.SIG.chLabelCount;
     840        rr->u.sig->orig_ttl       = pRec->Data.SIG.dwOriginalTtl;
     841        rr->u.sig->sig_expiration = pRec->Data.SIG.dwExpiration;
     842        rr->u.sig->sig_inception  = pRec->Data.SIG.dwTimeSigned;
     843        rr->u.sig->key_tag        = pRec->Data.SIG.wKeyTag;
     844        rr->u.sig->sig_len        = sig_len;
     845        memcpy_s (rr->u.sig->sig_data, sig_len,
     846                  pRec->Data.SIG.Signature, sig_len);
     847        rr->u.sig->signer         = &rr->u.sig->sig_data[sig_len];
     848        strcpy_s(rr->u.sig->signer, hostlen + 1, pRec->Data.SIG.pNameSigner);
     849        break;
     850    }
     851
     852#ifdef DNS_TYPE_DS
     853    case rk_ns_t_ds: {
     854        rr->u.ds = malloc (sizeof(*rr->u.ds) + pRec->Data.DS.wDigestLength - 1);
     855        if (rr->u.ds == NULL) {
     856            dns_free_rr(rr);
     857            return NULL;
     858        }
     859
     860        rr->u.ds->key_tag     = pRec->Data.DS.wKeyTag;
     861        rr->u.ds->algorithm   = pRec->Data.DS.chAlgorithm;
     862        rr->u.ds->digest_type = pRec->Data.DS.chDigestType;
     863        rr->u.ds->digest_len  = pRec->Data.DS.wDigestLength;
     864        memcpy_s (rr->u.ds->digest_data, pRec->Data.DS.wDigestLength,
     865                  pRec->Data.DS.Digest, pRec->Data.DS.wDigestLength);
     866        break;
     867    }
     868#endif
     869
     870    default:
     871        dns_free_rr(rr);
     872        return NULL;
     873    }
     874
     875    rr->next = parse_dns_record(pRec->pNext);
     876    return rr;
     877}
     878
     879ROKEN_LIB_FUNCTION struct rk_dns_reply * ROKEN_LIB_CALL
     880rk_dns_lookup(const char *domain, const char *type_name)
     881{
     882    DNS_STATUS status;
     883    int type;
     884    PDNS_RECORD pRec = NULL;
     885    struct rk_dns_reply * r = NULL;
     886
     887    __try {
     888
     889        type = rk_dns_string_to_type(type_name);
     890        if(type == -1) {
     891            if(_resolve_debug)
     892                fprintf(stderr, "dns_lookup: unknown resource type: `%s'\n",
     893                        type_name);
     894            return NULL;
     895        }
     896
     897        status = DnsQuery_UTF8(domain, type, DNS_QUERY_STANDARD, NULL,
     898                               &pRec, NULL);
     899        if (status != ERROR_SUCCESS)
     900            return NULL;
     901
     902        r = calloc(1, sizeof(*r));
     903        r->q.domain = strdup(domain);
     904        r->q.type = type;
     905        r->q.class = 0;
     906
     907        r->head = parse_dns_record(pRec);
     908
     909        if (r->head == NULL) {
     910            rk_dns_free_data(r);
     911            return NULL;
     912        } else {
     913            return r;
     914        }
     915
     916    } __finally {
     917
     918        if (pRec)
     919            DnsRecordListFree(pRec, DnsFreeRecordList);
     920
     921    }
     922}
     923#endif  /* HAVE_WINDNS */
     924
    707925#else /* NOT defined(HAVE_RES_SEARCH) && defined(HAVE_DN_EXPAND) */
    708926
    709 struct rk_dns_reply * ROKEN_LIB_FUNCTION
     927ROKEN_LIB_FUNCTION struct rk_dns_reply * ROKEN_LIB_CALL
    710928rk_dns_lookup(const char *domain, const char *type_name)
    711929{
     
    713931}
    714932
    715 void ROKEN_LIB_FUNCTION
     933ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    716934rk_dns_free_data(struct rk_dns_reply *r)
    717935{
    718936}
    719937
    720 void ROKEN_LIB_FUNCTION
     938ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    721939rk_dns_srv_order(struct rk_dns_reply *r)
    722940{
  • trunk/server/source4/heimdal/lib/roken/resolve.h

    r414 r745  
    3939#ifndef ROKEN_LIB_FUNCTION
    4040#ifdef _WIN32
    41 #define ROKEN_LIB_FUNCTION _stdcall
     41#define ROKEN_LIB_FUNCTION
     42#define ROKEN_LIB_CALL     __cdecl
    4243#else
    4344#define ROKEN_LIB_FUNCTION
     45#define ROKEN_LIB_CALL
    4446#endif
    4547#endif
     
    152154    unsigned key_tag;
    153155    char     *signer;
    154     unsigned sig_len;
     156    size_t  sig_len;
    155157    char     sig_data[1];       /* also includes signer */
    156158};
     
    175177    unsigned algorithm;
    176178    unsigned digest_type;
    177     unsigned digest_len;
     179    size_t digest_len;
    178180    u_char digest_data[1];
    179181};
     
    232234#endif
    233235
    234 struct rk_dns_reply* ROKEN_LIB_FUNCTION
     236ROKEN_LIB_FUNCTION struct rk_dns_reply* ROKEN_LIB_CALL
    235237        rk_dns_lookup(const char *, const char *);
    236 void ROKEN_LIB_FUNCTION
     238ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    237239        rk_dns_free_data(struct rk_dns_reply *);
    238 int ROKEN_LIB_FUNCTION
     240ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    239241        rk_dns_string_to_type(const char *name);
    240 const char *ROKEN_LIB_FUNCTION
     242ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    241243        rk_dns_type_to_string(int type);
    242 void ROKEN_LIB_FUNCTION
     244ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    243245        rk_dns_srv_order(struct rk_dns_reply*);
    244246
  • trunk/server/source4/heimdal/lib/roken/rkpty.c

    r414 r745  
    4242#include <stdio.h>
    4343#include <stdlib.h>
     44#ifdef HAVE_UNISTD_H
    4445#include <unistd.h>
     46#endif
    4547#ifdef HAVE_PTY_H
    4648#include <pty.h>
     
    9496open_pty(void)
    9597{
     98#ifdef _AIX
     99    printf("implement open_pty\n");
     100    exit(77);
     101#endif
    96102#if defined(HAVE_OPENPTY) || defined(__linux) || defined(__osf__) /* XXX */
    97103    if(openpty(&master, &slave, line, 0, 0) == 0)
     
    121127                slave = open(line, O_RDWR);
    122128                if (slave < 0)
    123                     errx(1, "failed to open slave when using %s", q);
     129                    errx(1, "failed to open slave when using %s", *q);
    124130                ioctl(slave, I_PUSH, "ptem");
    125131                ioctl(slave, I_PUSH, "ldterm");
  • trunk/server/source4/heimdal/lib/roken/roken-common.h

    r414 r745  
    3939#ifndef ROKEN_LIB_FUNCTION
    4040#ifdef _WIN32
    41 #define ROKEN_LIB_FUNCTION _stdcall
     41#define ROKEN_LIB_FUNCTION
     42#define ROKEN_LIB_CALL     __cdecl
    4243#else
    4344#define ROKEN_LIB_FUNCTION
     45#define ROKEN_LIB_CALL
    4446#endif
    4547#endif
     
    121123#endif
    122124
     125#ifndef _WIN32
     126
    123127#ifndef _PATH_DEV
    124128#define _PATH_DEV "/dev/"
     
    143147#ifndef MAXPATHLEN
    144148#define MAXPATHLEN (1024+4)
     149#endif
     150
     151#endif  /* !_WIN32 */
     152
     153#ifndef PATH_MAX
     154#define PATH_MAX MAX_PATH
     155#endif
     156
     157#ifndef RETSIGTYPE
     158#define RETSIGTYPE void
    145159#endif
    146160
     
    208222#endif
    209223
     224#ifndef AI_NUMERICSERV
     225#define AI_NUMERICSERV  0x08
     226#endif
     227
    210228/* flags for getnameinfo() */
    211229
     
    262280
    263281#ifndef IRIX4 /* fix for compiler bug */
     282#ifndef _WIN32
    264283#ifdef RETSIGTYPE
    265284typedef RETSIGTYPE (*SigAction)(int);
     
    267286#endif
    268287#endif
     288#endif
     289
     290#define SE_E_UNSPECIFIED (-1)
     291#define SE_E_FORKFAILED  (-2)
     292#define SE_E_WAITPIDFAILED (-3)
     293#define SE_E_EXECTIMEOUT (-4)
     294#define SE_E_NOEXEC   126
     295#define SE_E_NOTFOUND 127
     296
     297#define SE_PROCSTATUS(st) (((st) >= 0 && (st) < 126)? st: -1)
     298#define SE_PROCSIGNAL(st) (((st) >= 128)? (st) - 128: -1)
     299#define SE_IS_ERROR(st) ((st) < 0 || (st) >= 126)
     300
    269301
    270302#define simple_execve rk_simple_execve
    271 int ROKEN_LIB_FUNCTION
     303ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    272304simple_execve(const char*, char*const[], char*const[]);
    273305
    274306#define simple_execve_timed rk_simple_execve_timed
    275 int ROKEN_LIB_FUNCTION
     307ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    276308simple_execve_timed(const char *, char *const[],
    277309                    char *const [], time_t (*)(void *),
     
    279311
    280312#define simple_execvp rk_simple_execvp
    281 int ROKEN_LIB_FUNCTION
     313ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    282314simple_execvp(const char*, char *const[]);
    283315
    284316#define simple_execvp_timed rk_simple_execvp_timed
    285 int ROKEN_LIB_FUNCTION
     317ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    286318simple_execvp_timed(const char *, char *const[],
    287319                    time_t (*)(void *), void *, time_t);
    288320
    289321#define simple_execlp rk_simple_execlp
    290 int ROKEN_LIB_FUNCTION
     322ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    291323simple_execlp(const char*, ...);
    292324
    293325#define simple_execle rk_simple_execle
    294 int ROKEN_LIB_FUNCTION
     326ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    295327simple_execle(const char*, ...);
    296328
    297329#define wait_for_process rk_wait_for_process
    298 int ROKEN_LIB_FUNCTION
     330ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    299331wait_for_process(pid_t);
    300332
    301333#define wait_for_process_timed rk_wait_for_process_timed
    302 int ROKEN_LIB_FUNCTION
     334ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    303335wait_for_process_timed(pid_t, time_t (*)(void *),
    304                                               void *, time_t);
     336                       void *, time_t);
     337
    305338#define pipe_execv rk_pipe_execv
    306 int ROKEN_LIB_FUNCTION
     339ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    307340pipe_execv(FILE**, FILE**, FILE**, const char*, ...);
    308341
    309342#define print_version rk_print_version
    310 void ROKEN_LIB_FUNCTION
     343ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    311344print_version(const char *);
    312345
    313346#define eread rk_eread
    314 ssize_t ROKEN_LIB_FUNCTION
     347ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    315348eread (int fd, void *buf, size_t nbytes);
    316349
    317350#define ewrite rk_ewrite
    318 ssize_t ROKEN_LIB_FUNCTION
     351ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    319352ewrite (int fd, const void *buf, size_t nbytes);
    320353
     
    322355
    323356#define hostent_find_fqdn rk_hostent_find_fqdn
    324 const char * ROKEN_LIB_FUNCTION
     357ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    325358hostent_find_fqdn (const struct hostent *);
    326359
    327360#define esetenv rk_esetenv
    328 void ROKEN_LIB_FUNCTION
     361ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    329362esetenv(const char *, const char *, int);
    330363
    331364#define socket_set_address_and_port rk_socket_set_address_and_port
    332 void ROKEN_LIB_FUNCTION
     365ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    333366socket_set_address_and_port (struct sockaddr *, const void *, int);
    334367
    335368#define socket_addr_size rk_socket_addr_size
    336 size_t ROKEN_LIB_FUNCTION
     369ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    337370socket_addr_size (const struct sockaddr *);
    338371
    339372#define socket_set_any rk_socket_set_any
    340 void ROKEN_LIB_FUNCTION
     373ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    341374socket_set_any (struct sockaddr *, int);
    342375
    343376#define socket_sockaddr_size rk_socket_sockaddr_size
    344 size_t ROKEN_LIB_FUNCTION
     377ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    345378socket_sockaddr_size (const struct sockaddr *);
    346379
    347380#define socket_get_address rk_socket_get_address
    348 void * ROKEN_LIB_FUNCTION
     381ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
    349382socket_get_address (const struct sockaddr *);
    350383
    351384#define socket_get_port rk_socket_get_port
    352 int ROKEN_LIB_FUNCTION
     385ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    353386socket_get_port (const struct sockaddr *);
    354387
    355388#define socket_set_port rk_socket_set_port
    356 void ROKEN_LIB_FUNCTION
     389ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    357390socket_set_port (struct sockaddr *, int);
    358391
    359392#define socket_set_portrange rk_socket_set_portrange
    360 void ROKEN_LIB_FUNCTION
    361 socket_set_portrange (int, int, int);
     393ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     394socket_set_portrange (rk_socket_t, int, int);
    362395
    363396#define socket_set_debug rk_socket_set_debug
    364 void ROKEN_LIB_FUNCTION
    365 socket_set_debug (int);
     397ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     398socket_set_debug (rk_socket_t);
    366399
    367400#define socket_set_tos rk_socket_set_tos
    368 void ROKEN_LIB_FUNCTION
    369 socket_set_tos (int, int);
     401ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     402socket_set_tos (rk_socket_t, int);
    370403
    371404#define socket_set_reuseaddr rk_socket_set_reuseaddr
    372 void ROKEN_LIB_FUNCTION
    373 socket_set_reuseaddr (int, int);
     405ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     406socket_set_reuseaddr (rk_socket_t, int);
    374407
    375408#define socket_set_ipv6only rk_socket_set_ipv6only
    376 void ROKEN_LIB_FUNCTION
    377 socket_set_ipv6only (int, int);
     409ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     410socket_set_ipv6only (rk_socket_t, int);
     411
     412#define socket_to_fd rk_socket_to_fd
     413ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     414socket_to_fd(rk_socket_t, int);
    378415
    379416#define vstrcollect rk_vstrcollect
    380 char ** ROKEN_LIB_FUNCTION
     417ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
    381418vstrcollect(va_list *ap);
    382419
    383420#define strcollect rk_strcollect
    384 char ** ROKEN_LIB_FUNCTION
     421ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
    385422strcollect(char *first, ...);
    386423
    387424#define timevalfix rk_timevalfix
    388 void ROKEN_LIB_FUNCTION
     425ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    389426timevalfix(struct timeval *t1);
    390427
    391428#define timevaladd rk_timevaladd
    392 void ROKEN_LIB_FUNCTION
     429ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    393430timevaladd(struct timeval *t1, const struct timeval *t2);
    394431
    395432#define timevalsub rk_timevalsub
    396 void ROKEN_LIB_FUNCTION
     433ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    397434timevalsub(struct timeval *t1, const struct timeval *t2);
    398435
    399436#define pid_file_write rk_pid_file_write
    400 char *ROKEN_LIB_FUNCTION
     437ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    401438pid_file_write (const char *progname);
    402439
    403440#define pid_file_delete rk_pid_file_delete
    404 void ROKEN_LIB_FUNCTION
     441ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    405442pid_file_delete (char **);
    406443
    407444#define read_environment rk_read_environment
    408 int ROKEN_LIB_FUNCTION
     445ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    409446read_environment(const char *file, char ***env);
    410447
    411448#define free_environment rk_free_environment
    412 void ROKEN_LIB_FUNCTION
     449ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    413450free_environment(char **);
    414451
    415452#define warnerr rk_warnerr
    416 void ROKEN_LIB_FUNCTION
     453ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    417454rk_warnerr(int doerrno, const char *fmt, va_list ap)
    418455    __attribute__ ((format (printf, 2, 0)));
    419456
    420 void * ROKEN_LIB_FUNCTION
     457ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
    421458rk_realloc(void *, size_t);
    422459
    423460struct rk_strpool;
    424461
    425 char * ROKEN_LIB_FUNCTION
     462ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    426463rk_strpoolcollect(struct rk_strpool *);
    427464
    428 struct rk_strpool * ROKEN_LIB_FUNCTION
     465ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL
    429466rk_strpoolprintf(struct rk_strpool *, const char *, ...)
    430467    __attribute__ ((format (printf, 2, 3)));
    431468
     469ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     470rk_strpoolfree(struct rk_strpool *);
     471
     472ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     473rk_dumpdata (const char *, const void *, size_t);
     474
     475ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     476rk_undumpdata (const char *, void **, size_t *);
     477
     478ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     479rk_xfree (void *);
     480
     481ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     482rk_cloexec(int);
     483
     484ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     485rk_cloexec_file(FILE *);
     486
     487ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     488rk_cloexec_dir(DIR *);
     489
     490ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     491ct_memcmp(const void *, const void *, size_t);
     492
    432493void ROKEN_LIB_FUNCTION
    433 rk_strpoolfree(struct rk_strpool *);
    434 
    435 void ROKEN_LIB_FUNCTION
    436 rk_dumpdata (const char *, const void *, size_t);
    437 
    438 int ROKEN_LIB_FUNCTION
    439 rk_undumpdata (const char *, void **, size_t *);
    440 
    441 void ROKEN_LIB_FUNCTION
    442 rk_xfree (void *);
    443 
    444 void ROKEN_LIB_FUNCTION
    445 rk_cloexec(int);
    446 
    447 void ROKEN_LIB_FUNCTION
    448 rk_cloexec_file(FILE *);
    449 
     494rk_random_init(void);
    450495
    451496ROKEN_CPP_END
  • trunk/server/source4/heimdal/lib/roken/roken.h.in

    r414 r745  
    3333 */
    3434
    35 /* $Id$ */
    36 
    3735#include <stdio.h>
    3836#include <stdlib.h>
     
    4442#include <signal.h>
    4543
     44#ifndef ROKEN_LIB_FUNCTION
     45#ifdef _WIN32
     46#  define ROKEN_LIB_CALL     __cdecl
     47#  ifdef ROKEN_LIB_DYNAMIC
     48#    define ROKEN_LIB_FUNCTION __declspec(dllimport)
     49#    define ROKEN_LIB_VARIABLE __declspec(dllimport)
     50#  else
     51#    define ROKEN_LIB_FUNCTION
     52#    define ROKEN_LIB_VARIABLE
     53#  endif
     54#else
     55#define ROKEN_LIB_FUNCTION
     56#define ROKEN_LIB_CALL
     57#define ROKEN_LIB_VARIABLE
     58#endif
     59#endif
     60
     61#ifdef HAVE_WINSOCK
     62/* Declarations for Microsoft Windows */
     63
     64#include <winsock2.h>
     65#include <ws2tcpip.h>
     66
     67/*
     68 * error codes for inet_ntop/inet_pton
     69 */
     70#define EAFNOSUPPORT WSAEAFNOSUPPORT
     71
     72typedef SOCKET rk_socket_t;
     73
     74#define rk_closesocket(x) closesocket(x)
     75#define rk_INVALID_SOCKET INVALID_SOCKET
     76#define rk_IS_BAD_SOCKET(s) ((s) == INVALID_SOCKET)
     77#define rk_IS_SOCKET_ERROR(rv) ((rv) == SOCKET_ERROR)
     78#define rk_SOCK_ERRNO WSAGetLastError()
     79
     80ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_SOCK_IOCTL(SOCKET s, long cmd, int * argp);
     81
     82#define ETIMEDOUT               WSAETIMEDOUT
     83#define EWOULDBLOCK             WSAEWOULDBLOCK
     84#define ENOTSOCK                WSAENOTSOCK
     85
     86#define rk_SOCK_INIT() rk_WSAStartup()
     87#define rk_SOCK_EXIT() rk_WSACleanup()
     88
     89ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSAStartup(void);
     90ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSACleanup(void);
     91
     92#else  /* not WinSock */
     93
     94typedef int rk_socket_t;
     95
     96#define rk_closesocket(x) close(x)
     97#define rk_SOCK_IOCTL(s,c,a) ioctl((s),(c),(a))
     98#define rk_IS_BAD_SOCKET(s) ((s) < 0)
     99#define rk_IS_SOCKET_ERROR(rv) ((rv) < 0)
     100#define rk_SOCK_ERRNO errno
     101#define rk_INVALID_SOCKET (-1)
     102
     103#define rk_SOCK_INIT() 0
     104#define rk_SOCK_EXIT() do { } while(0)
     105
     106#endif
     107
     108#ifdef _MSC_VER
     109/* Declarations for Microsoft Visual C runtime on Windows */
     110
     111#include<process.h>
     112
     113#include<io.h>
     114
     115#ifndef __BIT_TYPES_DEFINED__
     116#define __BIT_TYPES_DEFINED__
     117
     118typedef __int8             int8_t;
     119typedef __int16            int16_t;
     120typedef __int32            int32_t;
     121typedef __int64            int64_t;
     122typedef unsigned __int8    uint8_t;
     123typedef unsigned __int16   uint16_t;
     124typedef unsigned __int32   uint32_t;
     125typedef unsigned __int64   uint64_t;
     126typedef uint8_t            u_int8_t;
     127typedef uint16_t           u_int16_t;
     128typedef uint32_t           u_int32_t;
     129typedef uint64_t           u_int64_t;
     130
     131#endif  /* __BIT_TYPES_DEFINED__ */
     132
     133#define UNREACHABLE(x) x
     134#define UNUSED_ARGUMENT(x) ((void) x)
     135
     136#define RETSIGTYPE void
     137
     138#define VOID_RETSIGTYPE 1
     139
     140#ifdef VOID_RETSIGTYPE
     141#define SIGRETURN(x) return
     142#else
     143#define SIGRETURN(x) return (RETSIGTYPE)(x)
     144#endif
     145
     146#ifndef CPP_ONLY
     147
     148typedef int pid_t;
     149
     150typedef unsigned int gid_t;
     151
     152typedef unsigned int uid_t;
     153
     154typedef unsigned short mode_t;
     155
     156#endif
     157
     158#ifndef __cplusplus
     159#define inline __inline
     160#endif
     161
     162#else
     163
     164#define UNREACHABLE(x)
     165#define UNUSED_ARGUMENT(x)
     166
     167#endif
     168
    46169#ifdef _AIX
    47170struct ether_addr;
     
    115238#include <termios.h>
    116239#endif
    117 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 40
     240#ifdef HAVE_SYS_IOCTL_H
    118241#include <sys/ioctl.h>
    119242#endif
     
    131254#endif
    132255
     256#ifdef HAVE_DIRENT_H
     257#include <dirent.h>
     258#endif
     259
     260#ifdef BACKSLASH_PATH_DELIM
     261#define rk_PATH_DELIM '\\'
     262#endif
     263
    133264#ifndef HAVE_SSIZE_T
     265#ifndef SSIZE_T_DEFINED
     266#ifdef ssize_t
     267#undef ssize_t
     268#endif
     269#ifdef _WIN64
     270typedef __int64 ssize_t;
     271#else
    134272typedef int ssize_t;
    135273#endif
     274#define SSIZE_T_DEFINED
     275#endif  /* SSIZE_T_DEFINED */
     276#endif  /* HAVE_SSIZE_T */
    136277
    137278#include <roken-common.h>
     
    149290#endif
    150291
     292#ifdef _MSC_VER
     293/* Additional macros for Visual C/C++ runtime */
     294
     295#define close   _close
     296
     297#define getpid  _getpid
     298
     299#define open    _open
     300
     301#define chdir   _chdir
     302
     303#define fsync   _commit
     304
     305/* The MSVC implementation of snprintf is not C99 compliant.  */
     306#define snprintf    rk_snprintf
     307#define vsnprintf   rk_vsnprintf
     308#define vasnprintf  rk_vasnprintf
     309#define vasprintf   rk_vasprintf
     310#define asnprintf   rk_asnprintf
     311#define asprintf    rk_asprintf
     312
     313#define _PIPE_BUFFER_SZ 8192
     314#define pipe(fds) _pipe((fds), _PIPE_BUFFER_SZ, O_BINARY);
     315
     316#define ftruncate(fd, sz) _chsize((fd), (sz))
     317
     318ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     319rk_snprintf (char *str, size_t sz, const char *format, ...);
     320
     321ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     322rk_asprintf (char **ret, const char *format, ...);
     323
     324ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     325rk_asnprintf (char **ret, size_t max_sz, const char *format, ...);
     326
     327ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     328rk_vasprintf (char **ret, const char *format, va_list args);
     329
     330ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     331rk_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args);
     332
     333ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     334rk_vsnprintf (char *str, size_t sz, const char *format, va_list args);
     335
     336/* missing stat.h predicates */
     337
     338#define S_ISREG(m) (((m) & _S_IFREG) == _S_IFREG)
     339
     340#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
     341
     342#define S_ISCHR(m) (((m) & _S_IFCHR) == _S_IFCHR)
     343
     344#define S_ISFIFO(m) (((m) & _S_IFIFO) == _S_IFIFO)
     345
     346/* The following are not implemented:
     347
     348 S_ISLNK(m)
     349 S_ISSOCK(m)
     350 S_ISBLK(m)
     351*/
     352
     353#endif  /* _MSC_VER */
     354
     355#ifdef HAVE_WINSOCK
     356
     357/* While we are at it, define WinSock specific scatter gather socket
     358   I/O. */
     359
     360#define iovec    _WSABUF
     361#define iov_base buf
     362#define iov_len  len
     363
     364struct msghdr {
     365    void           *msg_name;
     366    socklen_t       msg_namelen;
     367    struct iovec   *msg_iov;
     368    size_t          msg_iovlen;
     369    void           *msg_control;
     370    socklen_t       msg_controllen;
     371    int             msg_flags;
     372};
     373
     374#define sendmsg sendmsg_w32
     375
     376ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
     377sendmsg_w32(rk_socket_t s, const struct msghdr * msg, int flags);
     378
     379#endif  /* HAVE_WINSOCK */
     380
    151381#ifndef HAVE_PUTENV
    152382#define putenv rk_putenv
    153 int ROKEN_LIB_FUNCTION putenv(const char *);
     383ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL putenv(const char *);
    154384#endif
    155385
     
    158388#define setenv rk_setenv
    159389#endif
    160 int ROKEN_LIB_FUNCTION setenv(const char *, const char *, int);
     390ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setenv(const char *, const char *, int);
    161391#endif
    162392
     
    165395#define unsetenv rk_unsetenv
    166396#endif
    167 void ROKEN_LIB_FUNCTION unsetenv(const char *);
     397ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL unsetenv(const char *);
    168398#endif
    169399
     
    173403#define endusershell rk_endusershell
    174404#endif
    175 char * ROKEN_LIB_FUNCTION getusershell(void);
    176 void ROKEN_LIB_FUNCTION endusershell(void);
     405ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL getusershell(void);
     406ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL endusershell(void);
    177407#endif
    178408
     
    181411#define snprintf rk_snprintf
    182412#endif
    183 int ROKEN_LIB_FUNCTION
     413ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    184414     rk_snprintf (char *, size_t, const char *, ...)
    185415     __attribute__ ((format (printf, 3, 4)));
     
    190420#define vsnprintf rk_vsnprintf
    191421#endif
    192 int ROKEN_LIB_FUNCTION
     422ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    193423     rk_vsnprintf (char *, size_t, const char *, va_list)
    194424     __attribute__((format (printf, 3, 0)));
     
    199429#define asprintf rk_asprintf
    200430#endif
    201 int ROKEN_LIB_FUNCTION
     431ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    202432     rk_asprintf (char **, const char *, ...)
    203433     __attribute__ ((format (printf, 2, 3)));
     
    208438#define vasprintf rk_vasprintf
    209439#endif
    210 int ROKEN_LIB_FUNCTION
     440ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    211441    rk_vasprintf (char **, const char *, va_list)
    212442     __attribute__((format (printf, 2, 0)));
     
    217447#define asnprintf rk_asnprintf
    218448#endif
    219 int ROKEN_LIB_FUNCTION
     449ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    220450    rk_asnprintf (char **, size_t, const char *, ...)
    221451     __attribute__ ((format (printf, 3, 4)));
     
    226456#define vasnprintf rk_vasnprintf
    227457#endif
    228 int ROKEN_LIB_FUNCTION
     458ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    229459    vasnprintf (char **, size_t, const char *, va_list)
    230460     __attribute__((format (printf, 3, 0)));
     
    233463#ifndef HAVE_STRDUP
    234464#define strdup rk_strdup
    235 char * ROKEN_LIB_FUNCTION strdup(const char *);
     465ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strdup(const char *);
    236466#endif
    237467
     
    240470#define strndup rk_strndup
    241471#endif
    242 char * ROKEN_LIB_FUNCTION strndup(const char *, size_t);
     472ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strndup(const char *, size_t);
    243473#endif
    244474
    245475#ifndef HAVE_STRLWR
    246476#define strlwr rk_strlwr
    247 char * ROKEN_LIB_FUNCTION strlwr(char *);
     477ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strlwr(char *);
    248478#endif
    249479
    250480#ifndef HAVE_STRNLEN
    251481#define strnlen rk_strnlen
    252 size_t ROKEN_LIB_FUNCTION strnlen(const char*, size_t);
     482ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strnlen(const char*, size_t);
    253483#endif
    254484
     
    257487#define strsep rk_strsep
    258488#endif
    259 char * ROKEN_LIB_FUNCTION strsep(char**, const char*);
     489ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strsep(char**, const char*);
    260490#endif
    261491
     
    264494#define strsep_copy rk_strsep_copy
    265495#endif
    266 ssize_t ROKEN_LIB_FUNCTION strsep_copy(const char**, const char*, char*, size_t);
     496ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL strsep_copy(const char**, const char*, char*, size_t);
    267497#endif
    268498
    269499#ifndef HAVE_STRCASECMP
    270500#define strcasecmp rk_strcasecmp
    271 int ROKEN_LIB_FUNCTION strcasecmp(const char *, const char *);
     501ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL strcasecmp(const char *, const char *);
    272502#endif
    273503
    274504#ifdef NEED_FCLOSE_PROTO
    275 int ROKEN_LIB_FUNCTION fclose(FILE *);
     505ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fclose(FILE *);
    276506#endif
    277507
    278508#ifdef NEED_STRTOK_R_PROTO
    279 char * ROKEN_LIB_FUNCTION strtok_r(char *, const char *, char **);
     509ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strtok_r(char *, const char *, char **);
    280510#endif
    281511
    282512#ifndef HAVE_STRUPR
    283513#define strupr rk_strupr
    284 char * ROKEN_LIB_FUNCTION strupr(char *);
     514ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strupr(char *);
    285515#endif
    286516
    287517#ifndef HAVE_STRLCPY
    288518#define strlcpy rk_strlcpy
    289 size_t ROKEN_LIB_FUNCTION strlcpy (char *, const char *, size_t);
     519ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcpy (char *, const char *, size_t);
    290520#endif
    291521
    292522#ifndef HAVE_STRLCAT
    293523#define strlcat rk_strlcat
    294 size_t ROKEN_LIB_FUNCTION strlcat (char *, const char *, size_t);
     524ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcat (char *, const char *, size_t);
    295525#endif
    296526
    297527#ifndef HAVE_GETDTABLESIZE
    298528#define getdtablesize rk_getdtablesize
    299 int ROKEN_LIB_FUNCTION getdtablesize(void);
     529ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL getdtablesize(void);
    300530#endif
    301531
    302532#if !defined(HAVE_STRERROR) && !defined(strerror)
    303533#define strerror rk_strerror
    304 char * ROKEN_LIB_FUNCTION strerror(int);
     534ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strerror(int);
     535#endif
     536
     537#if (!defined(HAVE_STRERROR_R) && !defined(strerror_r)) || (!defined(STRERROR_R_PROTO_COMPATIBLE) && defined(HAVE_STRERROR_R))
     538int ROKEN_LIB_FUNCTION rk_strerror_r(int, char *, size_t);
     539#else
     540#define rk_strerror_r strerror_r
    305541#endif
    306542
     
    310546#endif
    311547/* This causes a fatal error under Psoriasis */
    312 #if !(defined(SunOS) && (SunOS >= 50))
    313 const char * ROKEN_LIB_FUNCTION hstrerror(int);
     548#ifndef SunOS
     549ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL hstrerror(int);
    314550#endif
    315551#endif
     
    323559#define inet_aton rk_inet_aton
    324560#endif
    325 int ROKEN_LIB_FUNCTION inet_aton(const char *, struct in_addr *);
     561ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL inet_aton(const char *, struct in_addr *);
    326562#endif
    327563
    328564#ifndef HAVE_INET_NTOP
    329565#define inet_ntop rk_inet_ntop
    330 const char * ROKEN_LIB_FUNCTION
     566ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    331567inet_ntop(int af, const void *src, char *dst, size_t size);
    332568#endif
     
    334570#ifndef HAVE_INET_PTON
    335571#define inet_pton rk_inet_pton
    336 int ROKEN_LIB_FUNCTION
     572ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    337573inet_pton(int, const char *, void *);
    338574#endif
    339575
    340 #if !defined(HAVE_GETCWD)
     576#ifndef HAVE_GETCWD
    341577#define getcwd rk_getcwd
    342 char* ROKEN_LIB_FUNCTION getcwd(char *, size_t);
     578ROKEN_LIB_FUNCTION char* ROKEN_LIB_CALL getcwd(char *, size_t);
    343579#endif
    344580
    345581#ifdef HAVE_PWD_H
    346582#include <pwd.h>
    347 struct passwd * ROKEN_LIB_FUNCTION k_getpwnam (const char *);
    348 struct passwd * ROKEN_LIB_FUNCTION k_getpwuid (uid_t);
    349 #endif
    350 
    351 const char * ROKEN_LIB_FUNCTION get_default_username (void);
     583ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwnam (const char *);
     584ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwuid (uid_t);
     585#endif
     586
     587ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL get_default_username (void);
    352588
    353589#ifndef HAVE_SETEUID
    354590#define seteuid rk_seteuid
    355 int ROKEN_LIB_FUNCTION seteuid(uid_t);
     591ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL seteuid(uid_t);
    356592#endif
    357593
    358594#ifndef HAVE_SETEGID
    359595#define setegid rk_setegid
    360 int ROKEN_LIB_FUNCTION setegid(gid_t);
     596ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setegid(gid_t);
    361597#endif
    362598
    363599#ifndef HAVE_LSTAT
    364600#define lstat rk_lstat
    365 int ROKEN_LIB_FUNCTION lstat(const char *, struct stat *);
     601ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL lstat(const char *, struct stat *);
    366602#endif
    367603
     
    370606#define mkstemp rk_mkstemp
    371607#endif
    372 int ROKEN_LIB_FUNCTION mkstemp(char *);
     608ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL mkstemp(char *);
    373609#endif
    374610
     
    376612#define cgetent rk_cgetent
    377613#define cgetstr rk_cgetstr
    378 int ROKEN_LIB_FUNCTION cgetent(char **, char **, const char *);
    379 int ROKEN_LIB_FUNCTION cgetstr(char *, const char *, char **);
     614ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **, char **, const char *);
     615ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *, const char *, char **);
    380616#endif
    381617
    382618#ifndef HAVE_INITGROUPS
    383619#define initgroups rk_initgroups
    384 int ROKEN_LIB_FUNCTION initgroups(const char *, gid_t);
     620ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL initgroups(const char *, gid_t);
    385621#endif
    386622
    387623#ifndef HAVE_FCHOWN
    388624#define fchown rk_fchown
    389 int ROKEN_LIB_FUNCTION fchown(int, uid_t, gid_t);
     625ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fchown(int, uid_t, gid_t);
     626#endif
     627
     628#ifdef RENAME_DOES_NOT_UNLINK
     629ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_rename(const char *, const char *);
     630#else
     631#define rk_rename(__rk_rn_from,__rk_rn_to) rename(__rk_rn_from,__rk_rn_to)
    390632#endif
    391633
     
    394636#define daemon rk_daemon
    395637#endif
    396 int ROKEN_LIB_FUNCTION daemon(int, int);
     638ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL daemon(int, int);
    397639#endif
    398640
    399641#ifndef HAVE_CHOWN
    400642#define chown rk_chown
    401 int ROKEN_LIB_FUNCTION chown(const char *, uid_t, gid_t);
     643ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL chown(const char *, uid_t, gid_t);
    402644#endif
    403645
    404646#ifndef HAVE_RCMD
    405647#define rcmd rk_rcmd
    406 int ROKEN_LIB_FUNCTION
     648ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    407649    rcmd(char **, unsigned short, const char *,
    408650         const char *, const char *, int *);
     
    413655#define innetgr rk_innetgr
    414656#endif
    415 int ROKEN_LIB_FUNCTION innetgr(const char*, const char*,
     657ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL innetgr(const char*, const char*,
    416658    const char*, const char*);
    417659#endif
     
    419661#ifndef HAVE_IRUSEROK
    420662#define iruserok rk_iruserok
    421 int ROKEN_LIB_FUNCTION iruserok(unsigned, int,
     663ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int,
    422664    const char *, const char *);
    423665#endif
     
    427669#define gethostname rk_gethostname
    428670#endif
    429 int ROKEN_LIB_FUNCTION gethostname(char *, int);
     671ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL gethostname(char *, int);
    430672#endif
    431673
    432674#ifndef HAVE_WRITEV
    433675#define writev rk_writev
    434 ssize_t ROKEN_LIB_FUNCTION
     676ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    435677writev(int, const struct iovec *, int);
    436678#endif
     
    438680#ifndef HAVE_READV
    439681#define readv rk_readv
    440 ssize_t ROKEN_LIB_FUNCTION
     682ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    441683readv(int, const struct iovec *, int);
    442684#endif
    443685
    444686#ifndef HAVE_PIDFILE
     687#ifdef NO_PIDFILES
     688#define pidfile(x) ((void) 0)
     689#else
    445690#define pidfile rk_pidfile
    446 void ROKEN_LIB_FUNCTION pidfile (const char*);
     691ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL pidfile (const char*);
     692#endif
    447693#endif
    448694
    449695#ifndef HAVE_BSWAP32
    450696#define bswap32 rk_bswap32
    451 unsigned int ROKEN_LIB_FUNCTION bswap32(unsigned int);
     697ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL bswap32(unsigned int);
    452698#endif
    453699
    454700#ifndef HAVE_BSWAP16
    455701#define bswap16 rk_bswap16
    456 unsigned short ROKEN_LIB_FUNCTION bswap16(unsigned short);
     702ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL bswap16(unsigned short);
    457703#endif
    458704
     
    471717#endif
    472718
    473 #define flock rk_flock
    474 int flock(int fd, int operation);
     719#define flock(_x,_y) rk_flock(_x,_y)
     720int rk_flock(int fd, int operation);
    475721#endif /* HAVE_FLOCK */
    476722
    477 time_t ROKEN_LIB_FUNCTION tm2time (struct tm, int);
    478 
    479 int ROKEN_LIB_FUNCTION unix_verify_user(char *, char *);
    480 
    481 int ROKEN_LIB_FUNCTION roken_concat (char *, size_t, ...);
    482 
    483 size_t ROKEN_LIB_FUNCTION roken_mconcat (char **, size_t, ...);
    484 
    485 int ROKEN_LIB_FUNCTION roken_vconcat (char *, size_t, va_list);
    486 
    487 size_t ROKEN_LIB_FUNCTION
     723#ifndef HAVE_DIRFD
     724#ifdef HAVE_DIR_DD_FD
     725#define dirfd(x) ((x)->dd_fd)
     726#else
     727#ifndef _WIN32 /* Windows code never calls dirfd */
     728#error Missing dirfd() and ->dd_fd
     729#endif
     730#endif
     731#endif
     732
     733ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL tm2time (struct tm, int);
     734
     735ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL unix_verify_user(char *, char *);
     736
     737ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_concat (char *, size_t, ...);
     738
     739ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_mconcat (char **, size_t, ...);
     740
     741ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_vconcat (char *, size_t, va_list);
     742
     743ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    488744    roken_vmconcat (char **, size_t, va_list);
    489745
    490 ssize_t ROKEN_LIB_FUNCTION net_write (int, const void *, size_t);
    491 
    492 ssize_t ROKEN_LIB_FUNCTION net_read (int, void *, size_t);
    493 
    494 int ROKEN_LIB_FUNCTION issuid(void);
     746ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
     747    net_write (rk_socket_t, const void *, size_t);
     748
     749ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
     750    net_read (rk_socket_t, void *, size_t);
     751
     752ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     753    issuid(void);
    495754
    496755#ifndef HAVE_STRUCT_WINSIZE
     
    501760#endif
    502761
    503 int ROKEN_LIB_FUNCTION get_window_size(int fd, struct winsize *);
     762ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, struct winsize *);
    504763
    505764#ifndef HAVE_VSYSLOG
    506765#define vsyslog rk_vsyslog
    507 void ROKEN_LIB_FUNCTION vsyslog(int, const char *, va_list);
     766ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL vsyslog(int, const char *, va_list);
     767#endif
     768
     769#ifndef HAVE_GETOPT
     770#define getopt rk_getopt
     771#define optarg rk_optarg
     772#define optind rk_optind
     773#define opterr rk_opterr
     774ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     775getopt(int nargc, char * const *nargv, const char *ostr);
    508776#endif
    509777
    510778#if !HAVE_DECL_OPTARG
    511 extern char *optarg;
     779ROKEN_LIB_VARIABLE extern char *optarg;
    512780#endif
    513781#if !HAVE_DECL_OPTIND
    514 extern int optind;
     782ROKEN_LIB_VARIABLE extern int optind;
    515783#endif
    516784#if !HAVE_DECL_OPTERR
    517 extern int opterr;
     785ROKEN_LIB_VARIABLE extern int opterr;
    518786#endif
    519787
    520788#ifndef HAVE_GETIPNODEBYNAME
    521789#define getipnodebyname rk_getipnodebyname
    522 struct hostent * ROKEN_LIB_FUNCTION
     790ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
    523791getipnodebyname (const char *, int, int, int *);
    524792#endif
     
    526794#ifndef HAVE_GETIPNODEBYADDR
    527795#define getipnodebyaddr rk_getipnodebyaddr
    528 struct hostent * ROKEN_LIB_FUNCTION
     796ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
    529797getipnodebyaddr (const void *, size_t, int, int *);
    530798#endif
     
    532800#ifndef HAVE_FREEHOSTENT
    533801#define freehostent rk_freehostent
    534 void ROKEN_LIB_FUNCTION
     802ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    535803freehostent (struct hostent *);
    536804#endif
     
    538806#ifndef HAVE_COPYHOSTENT
    539807#define copyhostent rk_copyhostent
    540 struct hostent * ROKEN_LIB_FUNCTION
     808ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
    541809copyhostent (const struct hostent *);
    542810#endif
     
    606874#ifndef HAVE_GETADDRINFO
    607875#define getaddrinfo rk_getaddrinfo
    608 int ROKEN_LIB_FUNCTION
     876ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    609877getaddrinfo(const char *,
    610878            const char *,
     
    615883#ifndef HAVE_GETNAMEINFO
    616884#define getnameinfo rk_getnameinfo
    617 int ROKEN_LIB_FUNCTION
     885ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    618886getnameinfo(const struct sockaddr *, socklen_t,
    619887                char *, size_t,
     
    624892#ifndef HAVE_FREEADDRINFO
    625893#define freeaddrinfo rk_freeaddrinfo
    626 void ROKEN_LIB_FUNCTION
     894ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    627895freeaddrinfo(struct addrinfo *);
    628896#endif
     
    630898#ifndef HAVE_GAI_STRERROR
    631899#define gai_strerror rk_gai_strerror
    632 const char * ROKEN_LIB_FUNCTION
     900ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    633901gai_strerror(int);
    634902#endif
    635903
    636 int ROKEN_LIB_FUNCTION
     904#ifdef NO_SLEEP
     905
     906ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
     907sleep(unsigned int seconds);
     908
     909#endif
     910
     911ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    637912getnameinfo_verified(const struct sockaddr *, socklen_t,
    638913                     char *, size_t,
     
    640915                     int);
    641916
    642 int ROKEN_LIB_FUNCTION
     917ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    643918roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **);
    644 int ROKEN_LIB_FUNCTION
     919ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    645920roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);
    646921
    647922#ifndef HAVE_STRFTIME
    648923#define strftime rk_strftime
    649 size_t ROKEN_LIB_FUNCTION
     924ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    650925strftime (char *, size_t, const char *, const struct tm *);
    651926#endif
     
    653928#ifndef HAVE_STRPTIME
    654929#define strptime rk_strptime
    655 char * ROKEN_LIB_FUNCTION
     930ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    656931strptime (const char *, const char *, struct tm *);
     932#endif
     933
     934#ifndef HAVE_GETTIMEOFDAY
     935ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     936gettimeofday (struct timeval *, void *);
    657937#endif
    658938
    659939#ifndef HAVE_EMALLOC
    660940#define emalloc rk_emalloc
    661 void * ROKEN_LIB_FUNCTION emalloc (size_t);
     941ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL emalloc (size_t);
    662942#endif
    663943#ifndef HAVE_ECALLOC
    664944#define ecalloc rk_ecalloc
    665 void * ROKEN_LIB_FUNCTION ecalloc(size_t, size_t);
     945ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ecalloc(size_t, size_t);
    666946#endif
    667947#ifndef HAVE_EREALLOC
    668948#define erealloc rk_erealloc
    669 void * ROKEN_LIB_FUNCTION erealloc (void *, size_t);
     949ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL erealloc (void *, size_t);
    670950#endif
    671951#ifndef HAVE_ESTRDUP
    672952#define estrdup rk_estrdup
    673 char * ROKEN_LIB_FUNCTION estrdup (const char *);
     953ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL estrdup (const char *);
    674954#endif
    675955
     
    678958 */
    679959
    680 #if 1
    681 int ROKEN_LIB_FUNCTION
     960ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    682961roken_gethostby_setup(const char*, const char*);
    683 struct hostent* ROKEN_LIB_FUNCTION
     962ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
    684963roken_gethostbyname(const char*);
    685 struct hostent* ROKEN_LIB_FUNCTION
     964ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
    686965roken_gethostbyaddr(const void*, size_t, int);
    687 #else
    688 #ifdef GETHOSTBYNAME_PROTO_COMPATIBLE
    689 #define roken_gethostbyname(x) gethostbyname(x)
    690 #else
    691 #define roken_gethostbyname(x) gethostbyname((char *)x)
    692 #endif
    693 
    694 #ifdef GETHOSTBYADDR_PROTO_COMPATIBLE
    695 #define roken_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t)
    696 #else
    697 #define roken_gethostbyaddr(a, l, t) gethostbyaddr((char *)a, l, t)
    698 #endif
    699 #endif
    700966
    701967#ifdef GETSERVBYNAME_PROTO_COMPATIBLE
     
    719985#ifndef HAVE_SETPROGNAME
    720986#define setprogname rk_setprogname
    721 void ROKEN_LIB_FUNCTION setprogname(const char *);
     987ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL setprogname(const char *);
    722988#endif
    723989
    724990#ifndef HAVE_GETPROGNAME
    725991#define getprogname rk_getprogname
    726 const char * ROKEN_LIB_FUNCTION getprogname(void);
     992ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void);
    727993#endif
    728994
     
    731997#endif
    732998
    733 void ROKEN_LIB_FUNCTION mini_inetd_addrinfo (struct addrinfo*);
    734 void ROKEN_LIB_FUNCTION mini_inetd (int);
     999ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     1000mini_inetd_addrinfo (struct addrinfo*, rk_socket_t *);
     1001
     1002ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     1003mini_inetd (int, rk_socket_t *);
    7351004
    7361005#ifndef HAVE_LOCALTIME_R
    7371006#define localtime_r rk_localtime_r
    738 struct tm * ROKEN_LIB_FUNCTION
     1007ROKEN_LIB_FUNCTION struct tm * ROKEN_LIB_CALL
    7391008localtime_r(const time_t *, struct tm *);
    7401009#endif
     
    7441013#define strsvis rk_strsvis
    7451014#endif
    746 int ROKEN_LIB_FUNCTION
     1015ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7471016strsvis(char *, const char *, int, const char *);
     1017#endif
     1018
     1019#if !defined(HAVE_STRSVISX) || defined(NEED_STRSVISX_PROTO)
     1020#ifndef HAVE_STRSVISX
     1021#define strsvisx rk_strsvisx
     1022#endif
     1023ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     1024strsvisx(char *, const char *, size_t, int, const char *);
    7481025#endif
    7491026
     
    7521029#define strunvis rk_strunvis
    7531030#endif
    754 int ROKEN_LIB_FUNCTION
     1031ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7551032strunvis(char *, const char *);
    7561033#endif
     
    7601037#define strvis rk_strvis
    7611038#endif
    762 int ROKEN_LIB_FUNCTION
     1039ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7631040strvis(char *, const char *, int);
    7641041#endif
     
    7681045#define strvisx rk_strvisx
    7691046#endif
    770 int ROKEN_LIB_FUNCTION
     1047ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7711048strvisx(char *, const char *, size_t, int);
    7721049#endif
     
    7761053#define svis rk_svis
    7771054#endif
    778 char * ROKEN_LIB_FUNCTION
     1055ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    7791056svis(char *, int, int, int, const char *);
    7801057#endif
     
    7841061#define unvis rk_unvis
    7851062#endif
    786 int ROKEN_LIB_FUNCTION
     1063ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7871064unvis(char *, int, int *, int);
    7881065#endif
     
    7921069#define vis rk_vis
    7931070#endif
    794 char * ROKEN_LIB_FUNCTION
     1071ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    7951072vis(char *, int, int, int);
    7961073#endif
     
    7981075#if !defined(HAVE_CLOSEFROM)
    7991076#define closefrom rk_closefrom
    800 int ROKEN_LIB_FUNCTION
     1077ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    8011078closefrom(int);
    8021079#endif
     
    8041081#if !defined(HAVE_TIMEGM)
    8051082#define timegm rk_timegm
    806 time_t ROKEN_LIB_FUNCTION
     1083ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL
    8071084rk_timegm(struct tm *tm);
     1085#endif
     1086
     1087#ifdef NEED_QSORT
     1088#define qsort rk_qsort
     1089void
     1090rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
     1091#endif
     1092
     1093#if defined(HAVE_ARC4RANDOM)
     1094#define rk_random() arc4random()
     1095#elif defined(HAVE_RANDOM)
     1096#define rk_random() random()
     1097#else
     1098#define rk_random() rand()
     1099#endif
     1100
     1101
     1102#if defined(__linux__) && defined(SOCK_CLOEXEC) && !defined(SOCKET_WRAPPER_REPLACE) && !defined(__SOCKET_WRAPPER_H__)
     1103#undef socket
     1104#define socket(_fam,_type,_prot) rk_socket(_fam,_type,_prot)
     1105int ROKEN_LIB_FUNCTION rk_socket(int, int, int);
    8081106#endif
    8091107
  • trunk/server/source4/heimdal/lib/roken/roken_gethostby.c

    r414 r745  
    6767    if(dns_req)
    6868        free(dns_req);
     69    dns_req = NULL;
    6970    if(proxy_host) {
    7071        if(make_address(proxy_host, &dns_addr.sin_addr) != 0)
    7172            return -1;
    7273        dns_addr.sin_port = htons(proxy_port);
    73         asprintf(&dns_req, "http://%s:%d%s", dns_host, dns_port, dns_path);
     74        if (asprintf(&dns_req, "http://%s:%d%s", dns_host, dns_port, dns_path) < 0)
     75            return -1;
    7476    } else {
    7577        if(make_address(dns_host, &dns_addr.sin_addr) != 0)
     
    105107
    106108
    107 int ROKEN_LIB_FUNCTION
     109ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    108110roken_gethostby_setup(const char *proxy_spec, const char *dns_spec)
    109111{
     
    136138    int s;
    137139    struct sockaddr_in addr;
    138     char *request;
     140    char *request = NULL;
    139141    char buf[1024];
    140142    int offset = 0;
     
    145147        return NULL; /* no configured host */
    146148    addr = dns_addr;
    147     asprintf(&request, "GET %s?%s HTTP/1.0\r\n\r\n", dns_req, hostname);
     149    if (asprintf(&request, "GET %s?%s HTTP/1.0\r\n\r\n", dns_req, hostname) < 0)
     150        return NULL;
    148151    if(request == NULL)
    149152        return NULL;
     
    208211}
    209212
    210 struct hostent*
     213ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
    211214roken_gethostbyname(const char *hostname)
    212215{
     
    218221}
    219222
    220 struct hostent* ROKEN_LIB_FUNCTION
     223ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
    221224roken_gethostbyaddr(const void *addr, size_t len, int type)
    222225{
  • trunk/server/source4/heimdal/lib/roken/rtbl.c

    r414 r745  
    6060};
    6161
    62 rtbl_t ROKEN_LIB_FUNCTION
     62ROKEN_LIB_FUNCTION rtbl_t ROKEN_LIB_CALL
    6363rtbl_create (void)
    6464{
     
    6666}
    6767
    68 void ROKEN_LIB_FUNCTION
     68ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    6969rtbl_set_flags (rtbl_t table, unsigned int flags)
    7070{
     
    7272}
    7373
    74 unsigned int ROKEN_LIB_FUNCTION
     74ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
    7575rtbl_get_flags (rtbl_t table)
    7676{
     
    8181rtbl_get_column_by_id (rtbl_t table, unsigned int id)
    8282{
    83     int i;
     83    size_t i;
    8484    for(i = 0; i < table->num_columns; i++)
    8585        if(table->columns[i]->column_id == id)
     
    9191rtbl_get_column (rtbl_t table, const char *column)
    9292{
    93     int i;
     93    size_t i;
    9494    for(i = 0; i < table->num_columns; i++)
    9595        if(strcmp(table->columns[i]->header, column) == 0)
     
    9898}
    9999
    100 void ROKEN_LIB_FUNCTION
     100ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    101101rtbl_destroy (rtbl_t table)
    102102{
    103     int i, j;
     103    size_t i, j;
    104104
    105105    for (i = 0; i < table->num_columns; i++) {
     
    120120}
    121121
    122 int ROKEN_LIB_FUNCTION
     122ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    123123rtbl_add_column_by_id (rtbl_t table, unsigned int id,
    124124                       const char *header, unsigned int flags)
     
    149149}
    150150
    151 int ROKEN_LIB_FUNCTION
     151ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    152152rtbl_add_column (rtbl_t table, const char *header, unsigned int flags)
    153153{
     
    155155}
    156156
    157 int ROKEN_LIB_FUNCTION
     157ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    158158rtbl_new_row(rtbl_t table)
    159159{
     
    184184column_compute_width (rtbl_t table, struct column_data *column)
    185185{
    186     int i;
     186    size_t i;
    187187
    188188    if(table->flags & RTBL_HEADER_STYLE_NONE)
     
    191191        column->width = strlen (column->header);
    192192    for (i = 0; i < column->num_rows; i++)
    193         column->width = max (column->width, strlen (column->rows[i].data));
     193        column->width = max (column->width, (int) strlen (column->rows[i].data));
    194194}
    195195
    196196/* DEPRECATED */
    197 int ROKEN_LIB_FUNCTION
     197ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    198198rtbl_set_prefix (rtbl_t table, const char *prefix)
    199199{
     
    206206}
    207207
    208 int ROKEN_LIB_FUNCTION
     208ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    209209rtbl_set_separator (rtbl_t table, const char *separator)
    210210{
     
    217217}
    218218
    219 int ROKEN_LIB_FUNCTION
     219ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    220220rtbl_set_column_prefix (rtbl_t table, const char *column,
    221221                        const char *prefix)
     
    233233}
    234234
    235 int ROKEN_LIB_FUNCTION
     235ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    236236rtbl_set_column_affix_by_id(rtbl_t table, unsigned int id,
    237237                            const char *prefix, const char *suffix)
     
    302302}
    303303
    304 int ROKEN_LIB_FUNCTION
     304ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    305305rtbl_add_column_entry_by_id (rtbl_t table, unsigned int id, const char *data)
    306306{
     
    313313}
    314314
    315 int ROKEN_LIB_FUNCTION
     315ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    316316rtbl_add_column_entryv_by_id (rtbl_t table, unsigned int id,
    317317                              const char *fmt, ...)
     
    331331}
    332332
    333 int ROKEN_LIB_FUNCTION
     333ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    334334rtbl_add_column_entry (rtbl_t table, const char *column, const char *data)
    335335{
     
    342342}
    343343
    344 int ROKEN_LIB_FUNCTION
     344ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    345345rtbl_add_column_entryv (rtbl_t table, const char *column, const char *fmt, ...)
    346346{
     
    360360
    361361
    362 int ROKEN_LIB_FUNCTION
     362ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    363363rtbl_format (rtbl_t table, FILE * f)
    364364{
    365     int i, j;
     365    size_t i, j;
    366366
    367367    for (i = 0; i < table->num_columns; i++)
  • trunk/server/source4/heimdal/lib/roken/rtbl.h

    r414 r745  
    3838#ifndef ROKEN_LIB_FUNCTION
    3939#ifdef _WIN32
    40 #define ROKEN_LIB_FUNCTION _stdcall
     40#define ROKEN_LIB_FUNCTION
     41#define ROKEN_LIB_CALL     __cdecl
    4142#else
    4243#define ROKEN_LIB_FUNCTION
     44#define ROKEN_LIB_CALL
    4345#endif
    4446#endif
     
    6163#define RTBL_HEADER_STYLE_NONE  1
    6264
    63 int ROKEN_LIB_FUNCTION
     65ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    6466rtbl_add_column (rtbl_t, const char*, unsigned int);
    6567
    66 int ROKEN_LIB_FUNCTION
     68ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    6769rtbl_add_column_by_id (rtbl_t, unsigned int, const char*, unsigned int);
    6870
    69 int ROKEN_LIB_FUNCTION
     71ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7072rtbl_add_column_entryv_by_id (rtbl_t table, unsigned int id,
    7173                              const char *fmt, ...)
    7274        __attribute__ ((format (printf, 3, 0)));
    7375
    74 int ROKEN_LIB_FUNCTION
     76ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7577rtbl_add_column_entry (rtbl_t, const char*, const char*);
    7678
    77 int ROKEN_LIB_FUNCTION
     79ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    7880rtbl_add_column_entryv (rtbl_t, const char*, const char*, ...)
    7981        __attribute__ ((format (printf, 3, 0)));
    8082
    81 int ROKEN_LIB_FUNCTION
     83ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    8284rtbl_add_column_entry_by_id (rtbl_t, unsigned int, const char*);
    8385
    84 rtbl_t ROKEN_LIB_FUNCTION
     86ROKEN_LIB_FUNCTION rtbl_t ROKEN_LIB_CALL
    8587rtbl_create (void);
    8688
    87 void ROKEN_LIB_FUNCTION
     89ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    8890rtbl_destroy (rtbl_t);
    8991
    90 int ROKEN_LIB_FUNCTION
     92ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    9193rtbl_format (rtbl_t, FILE*);
    9294
    93 unsigned int ROKEN_LIB_FUNCTION
     95ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
    9496rtbl_get_flags (rtbl_t);
    9597
    96 int ROKEN_LIB_FUNCTION
     98ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    9799rtbl_new_row (rtbl_t);
    98100
    99 int ROKEN_LIB_FUNCTION
     101ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    100102rtbl_set_column_affix_by_id (rtbl_t, unsigned int, const char*, const char*);
    101103
    102 int ROKEN_LIB_FUNCTION
     104ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    103105rtbl_set_column_prefix (rtbl_t, const char*, const char*);
    104106
    105 void ROKEN_LIB_FUNCTION
     107ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    106108rtbl_set_flags (rtbl_t, unsigned int);
    107109
    108 int ROKEN_LIB_FUNCTION
     110ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    109111rtbl_set_prefix (rtbl_t, const char*);
    110112
    111 int ROKEN_LIB_FUNCTION
     113ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    112114rtbl_set_separator (rtbl_t, const char*);
    113115
  • trunk/server/source4/heimdal/lib/roken/setprogname.c

    r414 r745  
    4141
    4242#ifndef HAVE_SETPROGNAME
    43 void ROKEN_LIB_FUNCTION
     43
     44ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    4445setprogname(const char *argv0)
    4546{
     47
    4648#ifndef HAVE___PROGNAME
     49
    4750    const char *p;
    4851    if(argv0 == NULL)
    4952        return;
    5053    p = strrchr(argv0, '/');
     54
     55#ifdef BACKSLASH_PATH_DELIM
     56    {
     57        const char * pb;
     58
     59        pb = strrchr((p != NULL)? p : argv0, '\\');
     60        if (pb != NULL)
     61            p = pb;
     62    }
     63#endif
     64
    5165    if(p == NULL)
    5266        p = argv0;
    5367    else
    5468        p++;
     69
     70#ifdef _WIN32
     71    {
     72        char * fn = strdup(p);
     73        char * ext;
     74
     75        strlwr(fn);
     76        ext = strrchr(fn, '.');
     77        if (ext != NULL && !strcmp(ext, ".exe"))
     78            *ext = '\0';
     79
     80        __progname = fn;
     81    }
     82#else
     83
    5584    __progname = p;
     85
    5686#endif
     87
     88#endif  /* HAVE___PROGNAME */
    5789}
     90
    5891#endif /* HAVE_SETPROGNAME */
  • trunk/server/source4/heimdal/lib/roken/signal.c

    r414 r745  
    4848 */
    4949
    50 SigAction ROKEN_LIB_FUNCTION
     50ROKEN_LIB_FUNCTION SigAction ROKEN_LIB_CALL
    5151signal(int iSig, SigAction pAction)
    5252{
  • trunk/server/source4/heimdal/lib/roken/simple_exec.c

    r414 r745  
    5353
    5454/* return values:
    55    -1   on `unspecified' system errors
    56    -2   on fork failures
    57    -3  on waitpid errors
    58    -4   exec timeout
     55   SE_E_UNSPECIFIED   on `unspecified' system errors
     56   SE_E_FORKFAILED    on fork failures
     57   SE_E_WAITPIDFAILED on waitpid errors
     58   SE_E_EXECTIMEOUT   exec timeout
    5959   0-   is return value from subprocess
    60    126  if the program couldn't be executed
    61    127  if the program couldn't be found
     60   SE_E_NOEXEC        if the program couldn't be executed
     61   SE_E_NOTFOUND      if the program couldn't be found
    6262   128- is 128 + signal that killed subprocess
    6363
     
    7979}
    8080
    81 int ROKEN_LIB_FUNCTION
     81ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    8282wait_for_process_timed(pid_t pid, time_t (*func)(void *),
    8383                       void *ptr, time_t timeout)
     
    9999        while(waitpid(pid, &status, 0) < 0) {
    100100            if (errno != EINTR) {
    101                 ret = -3;
     101                ret = SE_E_WAITPIDFAILED;
    102102                goto out;
    103103            }
     
    111111                continue;
    112112            } else if (timeout == (time_t)-2) {
    113                 ret = -4;
     113                ret = SE_E_EXECTIMEOUT;
    114114                goto out;
    115115            }
     
    135135}
    136136
    137 int ROKEN_LIB_FUNCTION
     137ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    138138wait_for_process(pid_t pid)
    139139{
     
    141141}
    142142
    143 int ROKEN_LIB_FUNCTION
     143ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    144144pipe_execv(FILE **stdin_fd, FILE **stdout_fd, FILE **stderr_fd,
    145145           const char *file, ...)
     
    212212            close(err_fd[1]);
    213213        }
    214         return -2;
     214        return SE_E_FORKFAILED;
    215215    default:
    216216        if(stdin_fd != NULL) {
     
    230230}
    231231
    232 int ROKEN_LIB_FUNCTION
     232ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    233233simple_execvp_timed(const char *file, char *const args[],
    234234                    time_t (*func)(void *), void *ptr, time_t timeout)
     
    237237    switch(pid){
    238238    case -1:
    239         return -2;
     239        return SE_E_FORKFAILED;
    240240    case 0:
    241241        execvp(file, args);
     
    246246}
    247247
    248 int ROKEN_LIB_FUNCTION
     248ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    249249simple_execvp(const char *file, char *const args[])
    250250{
     
    253253
    254254/* gee, I'd like a execvpe */
    255 int ROKEN_LIB_FUNCTION
     255ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    256256simple_execve_timed(const char *file, char *const args[], char *const envp[],
    257257                    time_t (*func)(void *), void *ptr, time_t timeout)
     
    260260    switch(pid){
    261261    case -1:
    262         return -2;
     262        return SE_E_FORKFAILED;
    263263    case 0:
    264264        execve(file, args, envp);
     
    269269}
    270270
    271 int ROKEN_LIB_FUNCTION
     271ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    272272simple_execve(const char *file, char *const args[], char *const envp[])
    273273{
     
    275275}
    276276
    277 int ROKEN_LIB_FUNCTION
     277ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    278278simple_execlp(const char *file, ...)
    279279{
     
    286286    va_end(ap);
    287287    if(argv == NULL)
    288         return -1;
     288        return SE_E_UNSPECIFIED;
    289289    ret = simple_execvp(file, argv);
    290290    free(argv);
     
    292292}
    293293
    294 int ROKEN_LIB_FUNCTION
     294ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    295295simple_execle(const char *file, ... /* ,char *const envp[] */)
    296296{
     
    305305    va_end(ap);
    306306    if(argv == NULL)
    307         return -1;
     307        return SE_E_UNSPECIFIED;
    308308    ret = simple_execve(file, argv, envp);
    309309    free(argv);
  • trunk/server/source4/heimdal/lib/roken/socket.c

    r414 r745  
    4141 */
    4242
    43 void ROKEN_LIB_FUNCTION
     43ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    4444socket_set_any (struct sockaddr *sa, int af)
    4545{
     
    7575 */
    7676
    77 void ROKEN_LIB_FUNCTION
     77ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    7878socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port)
    7979{
     
    109109 */
    110110
    111 size_t ROKEN_LIB_FUNCTION
     111ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    112112socket_addr_size (const struct sockaddr *sa)
    113113{
     
    120120#endif
    121121    default :
    122         errx (1, "unknown address family %d", sa->sa_family);
    123         break;
     122        return 0;
    124123    }
    125124}
     
    129128 */
    130129
    131 size_t ROKEN_LIB_FUNCTION
     130ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    132131socket_sockaddr_size (const struct sockaddr *sa)
    133132{
     
    139138        return sizeof(struct sockaddr_in6);
    140139#endif
    141     default :
    142         errx (1, "unknown address family %d", sa->sa_family);
    143         break;
     140    default:
     141        return 0;
    144142    }
    145143}
     
    149147 */
    150148
    151 void * ROKEN_LIB_FUNCTION
     149ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
    152150socket_get_address (const struct sockaddr *sa)
    153151{
     
    163161    }
    164162#endif
    165     default :
    166         errx (1, "unknown address family %d", sa->sa_family);
    167         break;
     163    default:
     164        return NULL;
    168165    }
    169166}
     
    173170 */
    174171
    175 int ROKEN_LIB_FUNCTION
     172ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    176173socket_get_port (const struct sockaddr *sa)
    177174{
     
    188185#endif
    189186    default :
    190         errx (1, "unknown address family %d", sa->sa_family);
    191         break;
     187        return 0;
    192188    }
    193189}
     
    197193 */
    198194
    199 void ROKEN_LIB_FUNCTION
     195ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    200196socket_set_port (struct sockaddr *sa, int port)
    201197{
     
    222218 * Set the range of ports to use when binding with port = 0.
    223219 */
    224 void ROKEN_LIB_FUNCTION
    225 socket_set_portrange (int sock, int restr, int af)
     220ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     221socket_set_portrange (rk_socket_t sock, int restr, int af)
    226222{
    227223#if defined(IP_PORTRANGE)
    228224        if (af == AF_INET) {
    229225                int on = restr ? IP_PORTRANGE_HIGH : IP_PORTRANGE_DEFAULT;
    230                 if (setsockopt (sock, IPPROTO_IP, IP_PORTRANGE, &on,
    231                     sizeof(on)) < 0)
    232                         warn ("setsockopt IP_PORTRANGE (ignored)");
     226                setsockopt (sock, IPPROTO_IP, IP_PORTRANGE, &on, sizeof(on));
    233227        }
    234228#endif
    235229#if defined(IPV6_PORTRANGE)
    236230        if (af == AF_INET6) {
    237                 int on = restr ? IPV6_PORTRANGE_HIGH :
    238                     IPV6_PORTRANGE_DEFAULT;
    239                 if (setsockopt (sock, IPPROTO_IPV6, IPV6_PORTRANGE, &on,
    240                     sizeof(on)) < 0)
    241                         warn ("setsockopt IPV6_PORTRANGE (ignored)");
     231                int on = restr ? IPV6_PORTRANGE_HIGH : IPV6_PORTRANGE_DEFAULT;
     232                setsockopt (sock, IPPROTO_IPV6, IPV6_PORTRANGE, &on, sizeof(on));
    242233        }
    243234#endif
     
    248239 */
    249240
    250 void ROKEN_LIB_FUNCTION
    251 socket_set_debug (int sock)
     241ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     242socket_set_debug (rk_socket_t sock)
    252243{
    253244#if defined(SO_DEBUG) && defined(HAVE_SETSOCKOPT)
    254245    int on = 1;
    255 
    256     if (setsockopt (sock, SOL_SOCKET, SO_DEBUG, (void *) &on, sizeof (on)) < 0)
    257         warn ("setsockopt SO_DEBUG (ignored)");
     246    setsockopt (sock, SOL_SOCKET, SO_DEBUG, (void *) &on, sizeof (on));
    258247#endif
    259248}
     
    263252 */
    264253
    265 void ROKEN_LIB_FUNCTION
    266 socket_set_tos (int sock, int tos)
     254ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     255socket_set_tos (rk_socket_t sock, int tos)
    267256{
    268257#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
    269     if (setsockopt (sock, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof (int)) < 0)
    270         if (errno != EINVAL)
    271             warn ("setsockopt TOS (ignored)");
     258    setsockopt (sock, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(int));
    272259#endif
    273260}
     
    277264 */
    278265
    279 void ROKEN_LIB_FUNCTION
    280 socket_set_reuseaddr (int sock, int val)
     266ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     267socket_set_reuseaddr (rk_socket_t sock, int val)
    281268{
    282269#if defined(SO_REUSEADDR) && defined(HAVE_SETSOCKOPT)
    283     if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&val,
    284                   sizeof(val)) < 0)
    285         err (1, "setsockopt SO_REUSEADDR");
     270    setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&val, sizeof(val));
    286271#endif
    287272}
     
    291276 */
    292277
    293 void ROKEN_LIB_FUNCTION
    294 socket_set_ipv6only (int sock, int val)
     278ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     279socket_set_ipv6only (rk_socket_t sock, int val)
    295280{
    296281#if defined(IPV6_V6ONLY) && defined(HAVE_SETSOCKOPT)
     
    298283#endif
    299284}
     285
     286/**
     287 * Create a file descriptor from a socket
     288 *
     289 * While the socket handle in \a sock can be used with WinSock
     290 * functions after calling socket_to_fd(), it should not be closed
     291 * with rk_closesocket().  The socket will be closed when the associated
     292 * file descriptor is closed.
     293 */
     294ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     295socket_to_fd(rk_socket_t sock, int flags)
     296{
     297#ifndef _WIN32
     298    return sock;
     299#else
     300    return _open_osfhandle((intptr_t) sock, flags);
     301#endif
     302}
     303
     304#ifdef HAVE_WINSOCK
     305ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     306rk_SOCK_IOCTL(SOCKET s, long cmd, int * argp) {
     307    u_long ul = (argp)? *argp : 0;
     308    int rv;
     309
     310    rv = ioctlsocket(s, cmd, &ul);
     311    if (argp)
     312        *argp = (int) ul;
     313    return rv;
     314}
     315#endif
     316
     317#ifndef HEIMDAL_SMALLER
     318#undef socket
     319
     320int rk_socket(int, int, int);
     321
     322int
     323rk_socket(int domain, int type, int protocol)
     324{
     325    int s;
     326    s = socket (domain, type, protocol);
     327#ifdef SOCK_CLOEXEC
     328    if ((SOCK_CLOEXEC & type) && s < 0 && errno == EINVAL) {
     329        type &= ~SOCK_CLOEXEC;
     330        s = socket (domain, type, protocol);
     331    }
     332#endif
     333    return s;
     334}
     335
     336#endif /* HEIMDAL_SMALLER */
  • trunk/server/source4/heimdal/lib/roken/strcollect.c

    r414 r745  
    6767 */
    6868
    69 char ** ROKEN_LIB_FUNCTION
     69ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
    7070vstrcollect(va_list *ap)
    7171{
     
    7777 */
    7878
    79 char ** ROKEN_LIB_FUNCTION
     79ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
    8080strcollect(char *first, ...)
    8181{
  • trunk/server/source4/heimdal/lib/roken/strlwr.c

    r414 r745  
    3939
    4040#ifndef HAVE_STRLWR
    41 char * ROKEN_LIB_FUNCTION
     41ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    4242strlwr(char *str)
    4343{
  • trunk/server/source4/heimdal/lib/roken/strpool.c

    r414 r745  
    4747 */
    4848
    49 void ROKEN_LIB_FUNCTION
     49ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    5050rk_strpoolfree(struct rk_strpool *p)
    5151{
     
    6161 */
    6262
    63 struct rk_strpool * ROKEN_LIB_FUNCTION
     63ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL
    6464rk_strpoolprintf(struct rk_strpool *p, const char *fmt, ...)
    6565{
     
    9898 */
    9999
    100 char * ROKEN_LIB_FUNCTION
     100ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    101101rk_strpoolcollect(struct rk_strpool *p)
    102102{
  • trunk/server/source4/heimdal/lib/roken/strsep.c

    r414 r745  
    4040#ifndef HAVE_STRSEP
    4141
    42 char * ROKEN_LIB_FUNCTION
     42ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    4343strsep(char **str, const char *delim)
    4444{
  • trunk/server/source4/heimdal/lib/roken/strsep_copy.c

    r414 r745  
    4242/* strsep, but with const stringp, so return string in buf */
    4343
    44 ssize_t ROKEN_LIB_FUNCTION
     44ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    4545strsep_copy(const char **stringp, const char *delim, char *buf, size_t len)
    4646{
  • trunk/server/source4/heimdal/lib/roken/strupr.c

    r414 r745  
    3939
    4040#ifndef HAVE_STRUPR
    41 char * ROKEN_LIB_FUNCTION
     41ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    4242strupr(char *str)
    4343{
  • trunk/server/source4/heimdal/lib/roken/vis.c

    r414 r745  
    107107#endif
    108108
    109 char * ROKEN_LIB_FUNCTION
     109ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    110110        rk_vis (char *, int, int, int);
    111 char * ROKEN_LIB_FUNCTION
     111ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    112112        rk_svis (char *, int, int, int, const char *);
    113 int ROKEN_LIB_FUNCTION
     113ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    114114        rk_strvis (char *, const char *, int);
    115 int ROKEN_LIB_FUNCTION
     115ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    116116        rk_strsvis (char *, const char *, int, const char *);
    117 int ROKEN_LIB_FUNCTION
     117ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    118118        rk_strvisx (char *, const char *, size_t, int);
    119 int ROKEN_LIB_FUNCTION
     119ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    120120        rk_strsvisx (char *, const char *, size_t, int, const char *);
    121121
     
    224224        if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
    225225                *dst++ = '\\';
    226                 *dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + '0';
    227                 *dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + '0';
    228                 *dst++ =                             (c       & 07) + '0';
     226                *dst++ = (u_char)(((unsigned int)(u_char)c >> 6) & 03) + '0';
     227                *dst++ = (u_char)(((unsigned int)(u_char)c >> 3) & 07) + '0';
     228                *dst++ = (u_char)(                       c       & 07) + '0';
    229229        } else {
    230230                if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\';
     
    250250 *        pointed to by `extra'
    251251 */
    252 char * ROKEN_LIB_FUNCTION
     252ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    253253rk_svis(char *dst, int c, int flag, int nextc, const char *extra)
    254254{
     
    287287 *      This is useful for encoding a block of data.
    288288 */
    289 int ROKEN_LIB_FUNCTION
     289
     290ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    290291rk_strsvis(char *dst, const char *csrc, int flag, const char *extra)
    291292{
     
    316317
    317318
    318 int ROKEN_LIB_FUNCTION
     319ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    319320rk_strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
    320321{
     
    354355 * vis - visually encode characters
    355356 */
    356 char * ROKEN_LIB_FUNCTION
     357ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    357358rk_vis(char *dst, int c, int flag, int nextc)
    358359{
     
    387388 *      This is useful for encoding a block of data.
    388389 */
    389 int ROKEN_LIB_FUNCTION
     390ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    390391rk_strvis(char *dst, const char *src, int flag)
    391392{
     
    404405
    405406
    406 int ROKEN_LIB_FUNCTION
     407ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    407408rk_strvisx(char *dst, const char *src, size_t len, int flag)
    408409{
  • trunk/server/source4/heimdal/lib/roken/vis.hin

    r414 r745  
    3737#ifndef ROKEN_LIB_FUNCTION
    3838#ifdef _WIN32
    39 #define ROKEN_LIB_FUNCTION _stdcall
     39#define ROKEN_LIB_FUNCTION
     40#define ROKEN_LIB_CALL     __cdecl
    4041#else
    4142#define ROKEN_LIB_FUNCTION
     43#define ROKEN_LIB_CALL
    4244#endif
    4345#endif
     
    8587ROKEN_CPP_START
    8688
    87 char * ROKEN_LIB_FUNCTION
     89ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    8890        rk_vis(char *, int, int, int);
    89 char * ROKEN_LIB_FUNCTION
     91ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    9092        rk_svis(char *, int, int, int, const char *);
    91 int ROKEN_LIB_FUNCTION
     93ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    9294        rk_strvis(char *, const char *, int);
    93 int ROKEN_LIB_FUNCTION
     95ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    9496        rk_strsvis(char *, const char *, int, const char *);
    95 int ROKEN_LIB_FUNCTION
     97ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    9698        rk_strvisx(char *, const char *, size_t, int);
    97 int ROKEN_LIB_FUNCTION
     99ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    98100        rk_strsvisx(char *, const char *, size_t, int, const char *);
    99 int ROKEN_LIB_FUNCTION
     101ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    100102        rk_strunvis(char *, const char *);
    101 int ROKEN_LIB_FUNCTION
     103ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    102104        rk_strunvisx(char *, const char *, int);
    103 int ROKEN_LIB_FUNCTION
     105ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    104106        rk_unvis(char *, int, int *, int);
     107
    105108ROKEN_CPP_END
    106109
  • trunk/server/source4/heimdal/lib/roken/xfree.c

    r414 r745  
    3434#include <config.h>
    3535
    36 #include <unistd.h>
    37 
    3836#include "roken.h"
    3937
Note: See TracChangeset for help on using the changeset viewer.