Initial Windows port

This commit is contained in:
Asanka Herath
2009-07-22 15:55:45 -04:00
committed by Love Hornquist Astrand
parent 25a2ac726b
commit b1063ea8fc
361 changed files with 11994 additions and 1334 deletions
+243
View File
@@ -0,0 +1,243 @@
########################################################################
#
# Copyright (c) 2009, Secure Endpoints Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
RELDIR=lib\roken
!include ../../windows/NTMakefile.w32
libroken_la_OBJS = \
$(OBJ)\base64.obj \
$(OBJ)\bswap.obj \
$(OBJ)\concat.obj \
$(OBJ)\dirent.obj \
$(OBJ)\dlfcn_w32.obj \
$(OBJ)\dumpdata.obj \
$(OBJ)\ecalloc.obj \
$(OBJ)\emalloc.obj \
$(OBJ)\environment.obj \
$(OBJ)\eread.obj \
$(OBJ)\erealloc.obj \
$(OBJ)\err.obj \
$(OBJ)\errx.obj \
$(OBJ)\esetenv.obj \
$(OBJ)\estrdup.obj \
$(OBJ)\ewrite.obj \
$(OBJ)\flock.obj \
$(OBJ)\fnmatch.obj \
$(OBJ)\getaddrinfo_hostspec.obj \
$(OBJ)\get_default_username.obj \
$(OBJ)\get_window_size.obj \
$(OBJ)\getarg.obj \
$(OBJ)\getifaddrs_w32.obj \
$(OBJ)\getnameinfo_verified.obj \
$(OBJ)\getprogname.obj \
$(OBJ)\gettimeofday.obj \
$(OBJ)\hex.obj \
$(OBJ)\hostent_find_fqdn.obj \
$(OBJ)\inet_aton.obj \
$(OBJ)\inet_ntop.obj \
$(OBJ)\inet_pton.obj \
$(OBJ)\issuid.obj \
$(OBJ)\lstat.obj \
$(OBJ)\mini_inetd.obj \
$(OBJ)\mkstemp.obj \
$(OBJ)\net_read.obj \
$(OBJ)\net_write.obj \
$(OBJ)\parse_bytes.obj \
$(OBJ)\parse_time.obj \
$(OBJ)\parse_units.obj \
$(OBJ)\realloc.obj \
$(OBJ)\resolve.obj \
$(OBJ)\roken_gethostby.obj \
$(OBJ)\rtbl.obj \
$(OBJ)\sendmsg_w32.obj \
$(OBJ)\setprogname.obj \
$(OBJ)\simple_exec_w32.obj \
$(OBJ)\sleep.obj \
$(OBJ)\snprintf.obj \
$(OBJ)\socket.obj \
$(OBJ)\sockstartup_w32.obj \
$(OBJ)\strcollect.obj \
$(OBJ)\strpool.obj \
$(OBJ)\strptime.obj \
$(OBJ)\strsep.obj \
$(OBJ)\strsep_copy.obj \
$(OBJ)\strtok_r.obj \
$(OBJ)\syslogc.obj \
$(OBJ)\timeval.obj \
$(OBJ)\tm2time.obj \
$(OBJ)\unvis.obj \
$(OBJ)\verr.obj \
$(OBJ)\verrx.obj \
$(OBJ)\vis.obj \
$(OBJ)\vwarn.obj \
$(OBJ)\vwarnx.obj \
$(OBJ)\warn.obj \
$(OBJ)\warnerr.obj \
$(OBJ)\warnx.obj
{}.c{$(OBJ)}.obj:
$(C2OBJ) -DBUILD_ROKEN_LIB
$(LIBROKEN): $(libroken_la_OBJS)
$(LIBCON)
$(OBJ)\make-roken.exe: $(OBJ)\make-roken.obj
$(EXECONLINK)
$(OBJ)\make-roken.c: roken.h.in roken.awk $(INCDIR)\config.h
$(AWK) -f roken.awk roken.h.in > $(OBJ)\make-roken.c || $(RM) $(OBJ)\make-roken.c
$(INCDIR)\roken.h: $(OBJ)\make-roken.exe
$(OBJ)\make-roken.exe > $@ || $(RM) $@
INCFILES = \
$(INCDIR)\base64.h \
$(INCDIR)\dirent.h \
$(INCDIR)\dlfcn.h \
$(INCDIR)\err.h \
$(INCDIR)\fnmatch.h \
$(INCDIR)\getarg.h \
$(INCDIR)\glob.h \
$(INCDIR)\hex.h \
$(INCDIR)\ifaddrs.h \
$(INCDIR)\parse_bytes.h \
$(INCDIR)\parse_time.h \
$(INCDIR)\parse_units.h \
$(INCDIR)\resolve.h \
$(INCDIR)\roken.h \
$(INCDIR)\roken-common.h \
$(INCDIR)\rtbl.h \
$(INCDIR)\syslog.h \
$(INCDIR)\vis.h \
$(INCDIR)\xdbm.h
clean::
-$(RM) $(XHEADERS)
all:: $(INCFILES) $(LIBROKEN)
clean::
-$(RM) $(LIBROKEN)
TMP_PROGS = $(OBJ)\snprintf-test.exe $(OBJ)\resolve-test.exe
# Tests
TEST_PROGS = \
$(OBJ)\base64-test.exe \
$(OBJ)\getaddrinfo-test.exe \
$(OBJ)\getifaddrs-test.exe \
$(OBJ)\hex-test.exe \
$(OBJ)\test-readenv.exe \
$(OBJ)\parse_bytes-test.exe \
$(OBJ)\parse_reply-test.exe \
$(OBJ)\parse_time-test.exe \
$(OBJ)\snprintf-test.exe \
$(OBJ)\strpftime-test.exe \
$(OBJ)\dirent-test.exe
$(OBJ)\strftime_test.obj: strftime.c
$(C2OBJ) -DTEST_SNPRINTF -DTEST_STRPFTIME -DBUILD_ROKEN_LIB
$(OBJ)\strptime_test.obj: strptime.c
$(C2OBJ) -DTEST_SNPRINTF -DTEST_STRPFTIME -DBUILD_ROKEN_LIB
$(OBJ)\snprintf_test.obj: snprintf.c
$(C2OBJ) -DTEST_SNPRINTF -DTEST_STRPFTIME -DBUILD_ROKEN_LIB
$(OBJ)\libtest.lib: $(OBJ)\strftime_test.obj $(OBJ)\strptime_test.obj $(OBJ)\snprintf_test.obj
$(LIBCON)
$(OBJ)\parse_reply-test.obj: parse_reply-test.c
$(C2OBJ) -DTEST_RESOLVE -DBUILD_ROKEN_LIB
$(OBJ)\resolve_test.obj: resolve.c
$(C2OBJ) -DTEST_RESOLVE -DBUILD_ROKEN_LIB
$(OBJ)\parse_reply-test.exe: $(OBJ)\parse_reply-test.obj $(OBJ)\resolve_test.obj
$(EXECONLINK)
$(OBJ)\test-readenv.exe: $(OBJ)\test-readenv.obj $(OBJ)\test-mem.obj
$(EXECONLINK)
$(OBJ)\parse_time-test.exe: $(OBJ)\parse_time-test.obj $(OBJ)\test-mem.obj $(LIBROKEN)
$(EXECONLINK)
$(OBJ)\strpftime-test.obj: strpftime-test.c
$(C2OBJ) -DTEST_STRPFTIME -DBUILD_ROKEN_LIB
$(OBJ)\strpftime-test.exe: $(OBJ)\strpftime-test.obj $(OBJ)\libtest.lib $(LIBROKEN)
$(EXECONLINK)
$(OBJ)\snprintf-test.obj: snprintf-test.c
$(C2OBJ) -DTEST_SNPRINTF -DBUILD_ROKEN_LIB
$(OBJ)\snprintf-test.exe: $(OBJ)\snprintf-test.obj $(OBJ)\libtest.lib $(LIBROKEN)
$(OBJ)\resolve-test.exe: $(OBJ)\resolve-test.obj $(LIBROKEN)
$(OBJ)\base64-test.exe: $(OBJ)\base64-test.obj $(OBJ)\base64.obj
$(OBJ)\getaddrinfo-test.exe: $(OBJ)\getaddrinfo-test.obj $(LIBROKEN)
$(OBJ)\hex-test.exe: $(OBJ)\hex-test.obj $(LIBROKEN)
$(OBJ)\test-readenv.exe: $(OBJ)\test-readenv.obj $(LIBROKEN)
$(OBJ)\parse_bytes-test.exe: $(OBJ)\parse_bytes-test.obj $(LIBROKEN)
$(OBJ)\parse_reply-test.exe: $(OBJ)\parse_reply-test.obj $(LIBROKEN)
$(OBJ)\dirent-test.exe: $(OBJ)\dirent-test.obj $(LIBROKEN)
$(OBJ)\getifaddrs-test.exe: $(OBJ)\getifaddrs-test.obj $(LIBROKEN)
test-binaries: $(TEST_PROGS) $(TMP_PROGS)
test-run:
cd $(OBJ)
dirent-test.exe
base64-test.exe
getaddrinfo-test.exe
getifaddrs-test.exe
hex-test.exe
test-readenv.exe
parse_bytes-test.exe
# Need to rewrite this test:
# parse_reply-test.exe
parse_time-test.exe
snprintf-test.exe
strpftime-test.exe
cd $(SRCDIR)
test:: test-binaries test-run
+2 -2
View File
@@ -51,7 +51,7 @@ pos(char c)
return -1;
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
base64_encode(const void *data, int size, char **str)
{
char *s, *p;
@@ -120,7 +120,7 @@ token_decode(const char *token)
return (marker << 24) | val;
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
base64_decode(const char *str, void *data)
{
const char *p;
+5 -3
View File
@@ -38,16 +38,18 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
base64_encode(const void *, int, char **);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
base64_decode(const char *, void *);
#endif
+2 -2
View File
@@ -36,7 +36,7 @@
#ifndef HAVE_BSWAP32
unsigned int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
bswap32 (unsigned int val)
{
return (val & 0xff) << 24 |
@@ -48,7 +48,7 @@ bswap32 (unsigned int val)
#ifndef HAVE_BSWAP16
unsigned short ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL
bswap16 (unsigned short val)
{
return (val & 0xff) << 8 |
+1 -1
View File
@@ -35,7 +35,7 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
chown(const char *path, uid_t owner, gid_t group)
{
return 0;
+1 -1
View File
@@ -42,7 +42,7 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
closefrom(int fd)
{
int num = getdtablesize();
+4 -4
View File
@@ -35,7 +35,7 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_concat (char *s, size_t len, ...)
{
int ret;
@@ -47,7 +47,7 @@ roken_concat (char *s, size_t len, ...)
return ret;
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_vconcat (char *s, size_t len, va_list args)
{
const char *a;
@@ -65,7 +65,7 @@ roken_vconcat (char *s, size_t len, va_list args)
return 0;
}
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
roken_vmconcat (char **s, size_t max_len, va_list args)
{
const char *a;
@@ -97,7 +97,7 @@ roken_vmconcat (char **s, size_t max_len, va_list args)
return len;
}
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
roken_mconcat (char **s, size_t max_len, ...)
{
int ret;
+1 -1
View File
@@ -39,7 +39,7 @@
* return a malloced copy of `h'
*/
struct hostent * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
copyhostent (const struct hostent *h)
{
struct hostent *res;
+1 -1
View File
@@ -47,7 +47,7 @@ static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93";
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
daemon(int nochdir, int noclose)
{
int fd;
+278
View File
@@ -0,0 +1,278 @@
/***********************************************************************
* Copyright (c) 2009, Secure Endpoints Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
**********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <direct.h>
#include <errno.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h>
#include "dirent.h"
/* Note that we create a known directory structure in a subdirectory
of the current directory to run our tests. */
#define TESTDIR "dirent-test-dir"
const char * dir_entries[] = {
"A",
"B",
"C",
"CAA",
"CAAA",
"CABBBB",
"CAABBB.txt",
"A filename with spaces"
};
const char * entries_begin_with_C[] = {
"C",
"CAA",
"CAAA",
"CABBBB",
"CAABBB.txt"
};
const char * entries_end_with_A[] = {
"A",
"CAA",
"CAAA"
};
const int n_dir_entries = sizeof(dir_entries)/sizeof(dir_entries[0]);
int teardown_test(void);
void fail_test(const char * reason, ...)
{
va_list args;
va_start(args, reason);
vfprintf(stderr, reason, args);
va_end(args);
fprintf(stderr, " : errno = %d (%s)\n", errno, strerror(errno));
teardown_test();
abort();
}
void fail_test_nf(const char * format, ...)
{
va_list args;
fprintf(stderr, "FAIL:");
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
fprintf(stderr, " : errno = %d (%s)\n", errno, strerror(errno));
}
int touch(const char * filename)
{
int fd;
fd = _open(filename, _O_CREAT, _S_IREAD| _S_IWRITE);
if (fd == -1)
return -1;
return _close(fd);
}
int setup_test(void)
{
int i;
fprintf(stderr, "Creating test directory %s ...\n", TESTDIR);
if (_mkdir(TESTDIR))
fail_test("Can't create test directory \"" TESTDIR "\"");
if (_chdir(TESTDIR))
fail_test("Can't change to test directory");
for (i=0; i < n_dir_entries; i++) {
if (touch(dir_entries[i]))
fail_test("Can't create test file '%s'", dir_entries[i]);
}
fprintf(stderr, "Done with test setup.\n");
return 0;
}
int teardown_test(void)
{
char dirname[_MAX_PATH];
size_t len;
int i;
printf ("Begin cleanup...\n");
if (_getcwd(dirname, sizeof(dirname)/sizeof(char)) != NULL &&
(len = strlen(dirname)) > sizeof(TESTDIR)/sizeof(char) &&
!strcmp(dirname + len + 1 - sizeof(TESTDIR)/sizeof(char), TESTDIR)) {
/* fallthrough */
} else {
/* did we create the directory? */
if (!_rmdir( TESTDIR )) {
fprintf(stderr, "Removed test directory\n");
return 0;
} else {
if (errno == ENOTEMPTY) {
if (_chdir(TESTDIR)) {
fprintf(stderr, "Can't change to test directory. Aborting cleanup.\n");
return -1;
} else {
/* fallthrough */
}
} else {
return -1;
}
}
}
fprintf(stderr, "Cleaning up test directory %s ...\n", TESTDIR);
for (i=0; i < n_dir_entries; i++) {
if (_unlink(dir_entries[i])) {
/* if the test setup failed, we expect this to happen for
at least some files */
}
}
if (_chdir("..")) {
fprintf(stderr, "Can't escape test directory. Giving in.\n");
return -1;
}
if (_rmdir( TESTDIR )) {
fprintf(stderr, "Can't remove test directory.\n");
return -1;
}
printf("Cleaned up test directory\n");
return 0;
}
int check_list(const char * filespec, const char ** list, int n, int expect_dot_and_dotdot)
{
DIR * d;
struct dirent * e;
int n_found = 0;
int i;
int rv = 0;
int retry = 1;
d = opendir(filespec);
if (d == NULL) {
fail_test_nf("opendir failed for [%s]", filespec);
return -1;
}
printf("Checking filespec [%s]... ", filespec);
retry:
while ((e = readdir(d)) != NULL) {
n_found ++;
if (expect_dot_and_dotdot &&
(!strcmp(e->d_name, ".") ||
!strcmp(e->d_name, "..")))
continue;
for (i=0; i < n; i++) {
if (!strcmp(list[i], e->d_name))
break;
}
if (i == n) {
fail_test_nf("Found unexpected entry [%s]", e->d_name);
rv = -1;
}
}
if (n_found != n) {
fail_test_nf("Unexpected number of entries [%d]. Expected %d", n_found, n);
rv = -1;
}
if (retry) {
retry = 0;
n_found = 0;
rewinddir(d);
goto retry;
}
if (closedir(d)) {
fail_test_nf("closedir() failed");
}
printf("done\n");
return rv;
}
int run_tests()
{
/* assumes that the test directory has been set up and we have
changed into the test directory. */
check_list("*", dir_entries, n_dir_entries + 2, 1);
check_list("*.*", dir_entries, n_dir_entries + 2, 1);
check_list("C*", entries_begin_with_C, sizeof(entries_begin_with_C)/sizeof(entries_begin_with_C[0]), 0);
check_list("*A", entries_end_with_A, sizeof(entries_end_with_A)/sizeof(entries_end_with_A[0]), 0);
return 0;
}
int main(int argc, char ** argv)
{
if (setup_test())
return 1;
run_tests();
teardown_test();
return 0;
}
+180
View File
@@ -0,0 +1,180 @@
/***********************************************************************
* Copyright (c) 2009, Secure Endpoints Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
**********************************************************************/
#ifdef HAVE_CONFIG_H
#include<config.h>
#endif
#include <stdlib.h>
#include <io.h>
#include <string.h>
#include <errno.h>
#include "dirent.h"
#ifndef _WIN32
#error Only implemented for Win32
#endif
struct _dirent_dirinfo {
int magic;
long n_entries;
long nc_entries;
long cursor;
struct dirent **entries;
};
#define DIRINFO_MAGIC 0xf8c0639d
#define IS_DP(p) ((p) && ((DIR *)(p))->magic == DIRINFO_MAGIC)
#define INITIAL_ENTRIES 16
ROKEN_LIB_FUNCTION DIR * ROKEN_LIB_CALL
opendir(const char * filespec)
{
DIR * dp;
struct _finddata_t fd;
intptr_t fd_handle;
memset(&fd, 0, sizeof(fd));
fd_handle = _findfirst(filespec, &fd);
if (fd_handle == -1)
return NULL;
dp = malloc(sizeof(*dp));
if (dp == NULL)
goto done;
memset(dp, 0, sizeof(*dp));
dp->magic = DIRINFO_MAGIC;
dp->cursor = 0;
dp->n_entries = 0;
dp->nc_entries = INITIAL_ENTRIES;
dp->entries = calloc(dp->nc_entries, sizeof(dp->entries[0]));
if (dp->entries == NULL) {
closedir(dp);
dp = NULL;
goto done;
}
do {
long len = strlen(fd.name);
struct dirent * e;
if (dp->n_entries == dp->nc_entries) {
struct dirent ** ne;
dp->nc_entries *= 2;
ne = realloc(dp->entries, sizeof(dp->entries[0]) * dp->nc_entries);
if (ne == NULL) {
closedir(dp);
dp = NULL;
goto done;
}
dp->entries = ne;
}
e = malloc(sizeof(*e) + len * sizeof(char));
if (e == NULL) {
closedir(dp);
dp = NULL;
goto done;
}
e->d_ino = 0; /* no inodes :( */
strcpy_s(e->d_name, len + 1, fd.name);
dp->entries[dp->n_entries++] = e;
} while (_findnext(fd_handle, &fd) == 0);
done:
if (fd_handle != -1)
_findclose(fd_handle);
return dp;
}
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
closedir(DIR * dp)
{
if (!IS_DP(dp))
return EINVAL;
if (dp->entries) {
long i;
for (i=0; i < dp->n_entries; i++) {
free(dp->entries[i]);
}
free(dp->entries);
}
free(dp);
return 0;
}
ROKEN_LIB_FUNCTION struct dirent * ROKEN_LIB_CALL
readdir(DIR * dp)
{
if (!IS_DP(dp) ||
dp->cursor < 0 ||
dp->cursor >= dp->n_entries)
return NULL;
return dp->entries[dp->cursor++];
}
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rewinddir(DIR * dp)
{
if (IS_DP(dp))
dp->cursor = 0;
}
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
seekdir(DIR * dp, long offset)
{
if (IS_DP(dp) && offset >= 0 && offset < dp->n_entries)
dp->cursor = offset;
}
ROKEN_LIB_FUNCTION long ROKEN_LIB_CALL
telldir(DIR * dp)
{
return dp->cursor;
}
+66
View File
@@ -0,0 +1,66 @@
/***********************************************************************
* Copyright (c) 2009, Secure Endpoints Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
**********************************************************************/
#ifndef __DIRENT_H__
#define __DIRENT_H__
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
#include<sys/types.h>
struct dirent {
ino_t d_ino;
char d_name[1];
};
typedef struct _dirent_dirinfo DIR;
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL closedir(DIR *);
ROKEN_LIB_FUNCTION DIR * ROKEN_LIB_CALL opendir(const char *);
ROKEN_LIB_FUNCTION struct dirent * ROKEN_LIB_CALL readdir(DIR *);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rewinddir(DIR *);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL seekdir(DIR *, long);
ROKEN_LIB_FUNCTION long ROKEN_LIB_CALL telldir(DIR *);
#endif
+78
View File
@@ -0,0 +1,78 @@
/***********************************************************************
* Copyright (c) 2009, Secure Endpoints Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
**********************************************************************/
#ifndef __dlfcn_h__
#define __dlfcn_h__
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
#define DLSYM_RET_TYPE void *
#ifdef __cplusplus
extern "C"
#endif
/* Implementation based on
http://www.opengroup.org/onlinepubs/009695399/basedefs/dlfcn.h.html */
#define RTLD_LAZY (1<<0)
#define RTLD_NOW (1<<1)
#define RTLD_GLOBAL (1<<2)
#define RTLD_LOCAL (1<<3)
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
dlclose(void *);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
dlerror(void);
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
dlopen(const char *, int);
ROKEN_LIB_FUNCTION DLSYM_RET_TYPE ROKEN_LIB_CALL
dlsym(void *, const char *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __dlfcn_h__ */
+96
View File
@@ -0,0 +1,96 @@
/***********************************************************************
* Copyright (c) 2009, Secure Endpoints Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
**********************************************************************/
#include <windows.h>
#include <dlfcn.h>
#include <strsafe.h>
#define ERR_STR_LEN 256
__declspec(thread) static char err_str[ERR_STR_LEN];
static void set_error(const char * e) {
StringCbCopy(err_str, sizeof(err_str), e);
}
static void set_error_from_last(void) {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
0, GetLastError(), 0,
err_str, sizeof(err_str)/sizeof(err_str[0]),
NULL);
}
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
dlclose(void * vhm)
{
BOOL brv;
brv = FreeLibrary((HMODULE) vhm);
if (!brv) {
set_error_from_last();
}
return !brv;
}
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
dlerror(void)
{
return err_str;
}
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
dlopen(const char *fn, int flags)
{
HMODULE hm;
/* We don't support dlopen(0, ...) on Windows.*/
if ( fn == NULL ) {
set_error("Not implemented");
return NULL;
}
hm = LoadLibrary(fn);
if (hm == NULL) {
set_error_from_last();
}
return (void *) hm;
}
ROKEN_LIB_FUNCTION DLSYM_RET_TYPE ROKEN_LIB_CALL
dlsym(void * vhm, const char * func_name)
{
HMODULE hm = (HMODULE) vhm;
return GetProcAddress(hm, func_name);
}
+1 -3
View File
@@ -33,15 +33,13 @@
#include <config.h>
#include <unistd.h>
#include "roken.h"
/*
* Write datablob to a filename, don't care about errors.
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dumpdata (const char *filename, const void *buf, size_t size)
{
int fd;
+1 -1
View File
@@ -42,7 +42,7 @@
* Like calloc but never fails.
*/
void * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
ecalloc (size_t number, size_t size)
{
void *tmp = calloc (number, size);
+1 -1
View File
@@ -42,7 +42,7 @@
* Like malloc but never fails.
*/
void * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
emalloc (size_t sz)
{
void *tmp = malloc (sz);
+2 -2
View File
@@ -127,7 +127,7 @@ read_env_file(FILE *F, char ***env, int *assigned)
* list of malloced strings in `env'
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
read_environment(const char *file, char ***env)
{
int assigned;
@@ -141,7 +141,7 @@ read_environment(const char *file, char ***env)
return assigned;
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
free_environment(char **env)
{
int i;
+1 -2
View File
@@ -33,7 +33,6 @@
#include <config.h>
#include <unistd.h>
#include <err.h>
#include "roken.h"
@@ -42,7 +41,7 @@
* Like read but never fails (and never returns partial data).
*/
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
eread (int fd, void *buf, size_t nbytes)
{
ssize_t ret;
+1 -1
View File
@@ -42,7 +42,7 @@
* Like realloc but never fails.
*/
void * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
erealloc (void *ptr, size_t sz)
{
void *tmp = realloc (ptr, sz);
+1 -1
View File
@@ -35,7 +35,7 @@
#include "err.h"
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
err(int eval, const char *fmt, ...)
{
va_list ap;
+11 -9
View File
@@ -48,40 +48,42 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
verr(int eval, const char *fmt, va_list ap)
__attribute__ ((noreturn, format (printf, 2, 0)));
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
err(int eval, const char *fmt, ...)
__attribute__ ((noreturn, format (printf, 2, 3)));
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
verrx(int eval, const char *fmt, va_list ap)
__attribute__ ((noreturn, format (printf, 2, 0)));
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
errx(int eval, const char *fmt, ...)
__attribute__ ((noreturn, format (printf, 2, 3)));
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
vwarn(const char *fmt, va_list ap)
__attribute__ ((format (printf, 1, 0)));
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
warn(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
vwarnx(const char *fmt, va_list ap)
__attribute__ ((format (printf, 1, 0)));
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
warnx(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
+1 -1
View File
@@ -35,7 +35,7 @@
#include "err.h"
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
errx(int eval, const char *fmt, ...)
{
va_list ap;
+1 -1
View File
@@ -37,7 +37,7 @@
#include <err.h>
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
esetenv(const char *var, const char *val, int rewrite)
{
if (setenv (rk_UNCONST(var), rk_UNCONST(val), rewrite))
+1 -1
View File
@@ -42,7 +42,7 @@
* Like strdup but never fails.
*/
char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
estrdup (const char *str)
{
char *tmp = strdup (str);
+1 -2
View File
@@ -33,7 +33,6 @@
#include <config.h>
#include <unistd.h>
#include <err.h>
#include "roken.h"
@@ -42,7 +41,7 @@
* Like write but never fails (and never returns partial data).
*/
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
ewrite (int fd, const void *buf, size_t nbytes)
{
ssize_t ret;
+1 -1
View File
@@ -35,7 +35,7 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
fchown(int fd, uid_t owner, gid_t group)
{
return 0;
+73 -3
View File
@@ -37,11 +37,11 @@
#include "roken.h"
#define OP_MASK (LOCK_SH | LOCK_EX | LOCK_UN)
int ROKEN_LIB_FUNCTION
rk_flock(int fd, int operation)
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
fk_flock(int fd, int operation)
{
#if defined(HAVE_FCNTL) && defined(F_SETLK)
struct flock arg;
@@ -75,6 +75,76 @@ rk_flock(int fd, int operation)
break;
}
return code;
#elif defined(_WIN32)
/* Windows */
#define FLOCK_OFFSET_LOW 0
#define FLOCK_OFFSET_HIGH 0
#define FLOCK_LENGTH_LOW 0x00000000
#define FLOCK_LENGTH_HIGH 0x80000000
HANDLE hFile;
OVERLAPPED ov;
BOOL rv = FALSE;
DWORD f = 0;
hFile = (HANDLE) _get_osfhandle(fd);
if (hFile == NULL || hFile == INVALID_HANDLE_VALUE) {
_set_errno(EBADF);
return -1;
}
ZeroMemory(&ov, sizeof(ov));
ov.hEvent = NULL;
ov.Offset = FLOCK_OFFSET_LOW;
ov.OffsetHigh = FLOCK_OFFSET_HIGH;
if (operation & LOCK_NB)
f = LOCKFILE_FAIL_IMMEDIATELY;
switch (operation & OP_MASK) {
case LOCK_UN: /* Unlock */
rv = UnlockFileEx(hFile, 0,
FLOCK_LENGTH_LOW, FLOCK_LENGTH_HIGH, &ov);
break;
case LOCK_SH: /* Shared lock */
rv = LockFileEx(hFile, f, 0,
FLOCK_LENGTH_LOW, FLOCK_LENGTH_HIGH, &ov);
break;
case LOCK_EX: /* Exclusive lock */
rv = LockFileEx(hFile, f|LOCKFILE_EXCLUSIVE_LOCK, 0,
FLOCK_LENGTH_LOW, FLOCK_LENGTH_HIGH,
&ov);
break;
default:
_set_errno(EINVAL);
return -1;
}
if (!rv) {
switch (GetLastError()) {
case ERROR_SHARING_VIOLATION:
case ERROR_LOCK_VIOLATION:
case ERROR_IO_PENDING:
_set_errno(EWOULDBLOCK);
break;
case ERROR_ACCESS_DENIED:
_set_errno(EACCES);
break;
default:
_set_errno(ENOLCK);
}
return -1;
}
return 0;
#else
return -1;
#endif
+7 -1
View File
@@ -45,6 +45,12 @@ static char rcsid[] = "$NetBSD: fnmatch.c,v 1.11 1995/02/27 03:43:06 cgd Exp $";
* Compares a filename or pathname to a pattern.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <roken.h>
#include <fnmatch.h>
#include <string.h>
@@ -52,7 +58,7 @@ static char rcsid[] = "$NetBSD: fnmatch.c,v 1.11 1995/02/27 03:43:06 cgd Exp $";
static const char *rangematch (const char *, int, int);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_fnmatch(const char *pattern, const char *string, int flags)
{
const char *stringstart;
+3 -1
View File
@@ -36,9 +36,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION __declspec(dllimport)
#define ROKEN_LIB_CALL __stdcall
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
+1 -1
View File
@@ -39,7 +39,7 @@
* free the list of `struct addrinfo' starting at `ai'
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
freeaddrinfo(struct addrinfo *ai)
{
struct addrinfo *tofree;
+1 -1
View File
@@ -39,7 +39,7 @@
* free a malloced hostent
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
freehostent (struct hostent *h)
{
char **p;
+1 -1
View File
@@ -62,7 +62,7 @@ static struct gai_error {
*
*/
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
gai_strerror(int ecode)
{
struct gai_error *g;
+7 -1
View File
@@ -40,7 +40,7 @@
* NULL if we can't guess at all.
*/
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
get_default_username (void)
{
const char *user;
@@ -73,5 +73,11 @@ get_default_username (void)
return pwd->pw_name;
}
#endif
#ifdef _WIN32
/* TODO: We can call GetUserNameEx() and figure out a
username. However, callers do not free the return value of this
function. */
#endif
return user;
}
+15 -1
View File
@@ -57,7 +57,7 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
get_window_size(int fd, struct winsize *wp)
{
int ret = -1;
@@ -85,6 +85,20 @@ get_window_size(int fd, struct winsize *wp)
wp->ws_col = dst[0];
ret = 0;
}
#elif defined(_WIN32)
{
intptr_t fh = 0;
CONSOLE_SCREEN_BUFFER_INFO sb_info;
fh = _get_osfhandle(fd);
if (fh != (intptr_t) INVALID_HANDLE_VALUE &&
GetConsoleScreenBufferInfo((HANDLE) fh, &sb_info)) {
wp->ws_row = 1 + sb_info.srWindow.Bottom - sb_info.srWindow.Top;
wp->ws_col = 1 + sb_info.srWindow.Right - sb_info.srWindow.Left;
ret = 0;
}
}
#endif
if (ret != 0) {
char *s;
+1 -1
View File
@@ -365,7 +365,7 @@ get_nodes (const char *nodename,
* };
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getaddrinfo(const char *nodename,
const char *servname,
const struct addrinfo *hints,
+2 -2
View File
@@ -37,7 +37,7 @@
/* getaddrinfo via string specifying host and port */
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_getaddrinfo_hostspec2(const char *hostspec,
int socktype,
int port,
@@ -92,7 +92,7 @@ roken_getaddrinfo_hostspec2(const char *hostspec,
return getaddrinfo (host, portstr, &hints, ai);
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_getaddrinfo_hostspec(const char *hostspec,
int port,
struct addrinfo **ai)
+11 -10
View File
@@ -91,7 +91,7 @@ mandoc_template(struct getargs *args,
const char *extra_string,
char *(i18n)(const char *))
{
int i;
size_t i;
char timestr[64], cmd[64];
char buf[128];
const char *p;
@@ -207,7 +207,7 @@ builtin_i18n(const char *str)
return rk_UNCONST(str);
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
arg_printusage (struct getargs *args,
size_t num_args,
const char *progname,
@@ -217,7 +217,7 @@ arg_printusage (struct getargs *args,
progname, extra_string, builtin_i18n);
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
arg_printusage_i18n (struct getargs *args,
size_t num_args,
const char *usage,
@@ -225,8 +225,7 @@ arg_printusage_i18n (struct getargs *args,
const char *extra_string,
char *(i18n)(const char *))
{
int i;
size_t max_len = 0;
size_t i, max_len = 0;
char buf[128];
int col = 0, columns;
struct winsize ws;
@@ -287,6 +286,7 @@ arg_printusage_i18n (struct getargs *args,
}
if (args[i].short_name && !ISFLAG(args[i])) {
snprintf(buf, sizeof(buf), "[-%c", args[i].short_name);
buf[sizeof(buf)/sizeof(buf[0]) - 1] = '\0';
len += 2;
len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf),
0, 0, &args[i], i18n);
@@ -353,7 +353,7 @@ static int
arg_match_long(struct getargs *args, size_t num_args,
char *argv, int argc, char **rargv, int *goptind)
{
int i;
size_t i;
char *goptarg = NULL;
int negate = 0;
int partial_match = 0;
@@ -474,6 +474,7 @@ arg_match_long(struct getargs *args, size_t num_args,
default:
abort ();
return 0; /* Not-reached */
}
/* not reached */
@@ -484,7 +485,7 @@ static int
arg_match_short (struct getargs *args, size_t num_args,
char *argv, int argc, char **rargv, int *goptind)
{
int j, k;
size_t j, k;
for(j = 1; j > 0 && j < strlen(rargv[*goptind]); j++) {
for(k = 0; k < num_args; k++) {
@@ -550,7 +551,7 @@ arg_match_short (struct getargs *args, size_t num_args,
return 0;
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getarg(struct getargs *args, size_t num_args,
int argc, char **argv, int *goptind)
{
@@ -562,7 +563,7 @@ getarg(struct getargs *args, size_t num_args,
#elif defined(HAVE_RANDOM)
srandom(time(NULL));
#else
srand (time(NULL));
srand ((int) time(NULL));
#endif
(*goptind)++;
for(i = *goptind; i < argc; i++) {
@@ -586,7 +587,7 @@ getarg(struct getargs *args, size_t num_args,
return ret;
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
free_getarg_strings (getarg_strings *s)
{
free (s->strings);
+7 -5
View File
@@ -40,9 +40,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
@@ -86,17 +88,17 @@ typedef struct getarg_collect_info {
void *data;
} getarg_collect_info;
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getarg(struct getargs *args, size_t num_args,
int argc, char **argv, int *goptind);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
arg_printusage (struct getargs *args,
size_t num_args,
const char *progname,
const char *extra_string);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
arg_printusage_i18n (struct getargs *args,
size_t num_args,
const char *usage,
@@ -104,7 +106,7 @@ arg_printusage_i18n (struct getargs *args,
const char *extra_string,
char *(i18n)(const char *));
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
free_getarg_strings (getarg_strings *);
#endif /* __GETARG_H__ */
+15 -15
View File
@@ -83,24 +83,24 @@ static int getent (char **, size_t *, char **, int, const char *, int, char *);
static int nfcmp (char *, char *);
int ROKEN_LIB_FUNCTION cgetset(const char *ent);
char *ROKEN_LIB_FUNCTION cgetcap(char *buf, const char *cap, int type);
int ROKEN_LIB_FUNCTION cgetent(char **buf, char **db_array, const char *name);
int ROKEN_LIB_FUNCTION cgetmatch(const char *buf, const char *name);
int ROKEN_LIB_FUNCTION cgetclose(void);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetset(const char *ent);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL cgetcap(char *buf, const char *cap, int type);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **buf, char **db_array, const char *name);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetmatch(const char *buf, const char *name);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetclose(void);
#if 0
int cgetfirst(char **buf, char **db_array);
int cgetnext(char **bp, char **db_array);
#endif
int ROKEN_LIB_FUNCTION cgetstr(char *buf, const char *cap, char **str);
int ROKEN_LIB_FUNCTION cgetustr(char *buf, const char *cap, char **str);
int ROKEN_LIB_FUNCTION cgetnum(char *buf, const char *cap, long *num);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *buf, const char *cap, char **str);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetustr(char *buf, const char *cap, char **str);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetnum(char *buf, const char *cap, long *num);
/*
* Cgetset() allows the addition of a user specified buffer to be added
* to the database array, in effect "pushing" the buffer on top of the
* virtual database. 0 is returned on success, -1 on failure.
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
cgetset(const char *ent)
{
const char *source, *check;
@@ -153,7 +153,7 @@ cgetset(const char *ent)
* If (cap, '@') or (cap, terminator, '@') is found before (cap, terminator)
* return NULL.
*/
char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
cgetcap(char *buf, const char *cap, int type)
{
char *bp;
@@ -204,7 +204,7 @@ cgetcap(char *buf, const char *cap, int type)
* encountered (couldn't open/read a file, etc.), and -3 if a potential
* reference loop is detected.
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
cgetent(char **buf, char **db_array, const char *name)
{
size_t dummy;
@@ -700,7 +700,7 @@ static FILE *pfp;
static int slash;
static char **dbp;
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
cgetclose(void)
{
if (pfp != NULL) {
@@ -847,7 +847,7 @@ cgetnext(char **bp, char **db_array)
* couldn't be found, -2 if a system error was encountered (storage
* allocation failure).
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
cgetstr(char *buf, const char *cap, char **str)
{
u_int m_room;
@@ -980,7 +980,7 @@ cgetstr(char *buf, const char *cap, char **str)
* -1 if the requested string capability couldn't be found, -2 if a system
* error was encountered (storage allocation failure).
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
cgetustr(char *buf, const char *cap, char **str)
{
u_int m_room;
@@ -1049,7 +1049,7 @@ cgetustr(char *buf, const char *cap, char **str)
* the long pointed to by num. 0 is returned on success, -1 if the requested
* numeric capability couldn't be found.
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
cgetnum(char *buf, const char *cap, long *num)
{
long n;
+1 -1
View File
@@ -42,7 +42,7 @@
#include "roken.h"
char* ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char* ROKEN_LIB_CALL
getcwd(char *path, size_t size)
{
char xxx[MaxPathLen];
+1 -1
View File
@@ -61,7 +61,7 @@
#include <sys/sysctl.h>
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getdtablesize(void)
{
int files = -1;
+1 -1
View File
@@ -37,7 +37,7 @@
#ifndef HAVE_GETEGID
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getegid(void)
{
return getgid();
+1 -1
View File
@@ -37,7 +37,7 @@
#ifndef HAVE_GETEUID
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
geteuid(void)
{
return getuid();
+1 -1
View File
@@ -36,7 +36,7 @@
#ifndef HAVE_GETGID
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getgid(void)
{
return 17;
+1 -1
View File
@@ -47,7 +47,7 @@
* interface is identical to gethostname(2).)
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
gethostname(char *name, int namelen)
{
#if defined(HAVE_UNAME)
+46
View File
@@ -3,6 +3,8 @@
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2009, Secure Endpoints Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -38,18 +40,62 @@
#include <ifaddrs.h>
void
print_addr(const char *s, struct sockaddr *sa)
{
int i;
printf(" %s=%d/", s, sa->sa_family);
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
for(i = 0; i < sa->sa_len - ((long)sa->sa_data - (long)&sa->sa_family); i++)
printf("%02x", ((unsigned char*)sa->sa_data)[i]);
#else
for(i = 0; i < sizeof(sa->sa_data); i++)
printf("%02x", ((unsigned char*)sa->sa_data)[i]);
#endif
printf("\n");
}
void
print_ifaddrs(struct ifaddrs *x)
{
struct ifaddrs *p;
for(p = x; p; p = p->ifa_next) {
printf("%s\n", p->ifa_name);
printf(" flags=%x\n", p->ifa_flags);
if(p->ifa_addr)
print_addr("addr", p->ifa_addr);
if(p->ifa_dstaddr)
print_addr("dstaddr", p->ifa_dstaddr);
if(p->ifa_netmask)
print_addr("netmask", p->ifa_netmask);
printf(" %p\n", p->ifa_data);
}
}
int
main(int argc, char **argv)
{
struct ifaddrs *addrs = NULL;
int ret;
if (SOCK_INIT)
errx(1, "Couldn't initialize sockets. Err=%d\n", SOCK_ERRNO);
ret = getifaddrs(&addrs);
if (ret != 0)
err(1, "getifaddrs");
if (addrs == NULL)
errx(1, "address == NULL");
print_ifaddrs(addrs);
/* Check that freeifaddrs doesn't crash */
freeifaddrs(addrs);
if (SOCK_EXIT)
errx(1, "Couldn't uninitialize sockets. Err=%d\n", SOCK_ERRNO);
return 0;
}
+5 -5
View File
@@ -498,7 +498,7 @@ nl_open(void)
}
/* ====================================================================== */
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_getifaddrs(struct ifaddrs **ifap)
{
int sd;
@@ -1165,7 +1165,7 @@ getlifaddrs2(struct ifaddrs **ifap,
}
#endif /* defined(HAVE_IPV6) && defined(SIOCGLIFCONF) && defined(SIOCGLIFFLAGS) */
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_getifaddrs(struct ifaddrs **ifap)
{
int ret = -1;
@@ -1193,7 +1193,9 @@ rk_getifaddrs(struct ifaddrs **ifap)
return ret;
}
void ROKEN_LIB_FUNCTION
#endif /* !AF_NETLINK */
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_freeifaddrs(struct ifaddrs *ifp)
{
struct ifaddrs *p, *q;
@@ -1214,8 +1216,6 @@ rk_freeifaddrs(struct ifaddrs *ifp)
}
}
#endif /* !AF_NETLINK */
#ifdef TEST
void
+163
View File
@@ -0,0 +1,163 @@
/***********************************************************************
* Copyright (c) 2009, Secure Endpoints Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
**********************************************************************/
#ifdef HAVE_CONFIG_H
#include<config.h>
#endif
#include <roken.h>
#include <ifaddrs.h>
#ifndef _WIN32
#error This is a Windows specific implementation.
#endif
static struct sockaddr *
dupaddr(const sockaddr_gen * src)
{
sockaddr_gen * d = malloc(sizeof(*d));
if (d) {
memcpy(d, src, sizeof(*d));
}
return (struct sockaddr *) d;
}
int ROKEN_LIB_FUNCTION
rk_getifaddrs(struct ifaddrs **ifpp)
{
SOCKET s = INVALID_SOCKET;
size_t il_len = 8192;
int ret = -1;
INTERFACE_INFO *il = NULL;
*ifpp = NULL;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s == INVALID_SOCKET)
return -1;
for (;;) {
DWORD cbret = 0;
il = malloc(il_len);
if (!il)
break;
ZeroMemory(il, il_len);
if (WSAIoctl(s, SIO_GET_INTERFACE_LIST, NULL, 0,
(LPVOID) il, il_len, &cbret,
NULL, NULL) == 0) {
il_len = cbret;
break;
}
free (il);
il = NULL;
if (WSAGetLastError() == WSAEFAULT && cbret > il_len) {
il_len = cbret;
} else {
break;
}
}
if (!il)
goto _exit;
/* il is an array of INTERFACE_INFO structures. il_len has the
actual size of the buffer. The number of elements is
il_len/sizeof(INTERFACE_INFO) */
{
size_t n = il_len / sizeof(INTERFACE_INFO);
size_t i;
for (i = 0; i < n; i++ ) {
struct ifaddrs *ifp;
ifp = malloc(sizeof(*ifp));
if (ifp == NULL)
break;
ZeroMemory(ifp, sizeof(*ifp));
ifp->ifa_next = NULL;
ifp->ifa_name = NULL;
ifp->ifa_flags = il[i].iiFlags;
ifp->ifa_addr = dupaddr(&il[i].iiAddress);
ifp->ifa_netmask = dupaddr(&il[i].iiNetmask);
ifp->ifa_broadaddr = dupaddr(&il[i].iiBroadcastAddress);
ifp->ifa_data = NULL;
*ifpp = ifp;
ifpp = &ifp->ifa_next;
}
if (i == n)
ret = 0;
}
_exit:
if (s != INVALID_SOCKET)
closesocket(s);
if (il)
free (il);
return ret;
}
void ROKEN_LIB_FUNCTION
rk_freeifaddrs(struct ifaddrs *ifp)
{
struct ifaddrs *p, *q;
for(p = ifp; p; ) {
if (p->ifa_name)
free(p->ifa_name);
if(p->ifa_addr)
free(p->ifa_addr);
if(p->ifa_dstaddr)
free(p->ifa_dstaddr);
if(p->ifa_netmask)
free(p->ifa_netmask);
if(p->ifa_data)
free(p->ifa_data);
q = p;
p = p->ifa_next;
free(q);
}
}
+1 -1
View File
@@ -40,7 +40,7 @@
* to a malloced struct hostent or NULL.
*/
struct hostent * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
getipnodebyaddr (const void *src, size_t len, int af, int *error_num)
{
struct hostent *tmp;
+1 -1
View File
@@ -44,7 +44,7 @@ static int h_errno = NO_RECOVERY;
* to a malloced struct hostent or NULL.
*/
struct hostent * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
getipnodebyname (const char *name, int af, int flags, int *error_num)
{
struct hostent *tmp;
+1 -1
View File
@@ -91,7 +91,7 @@ doit (int af,
*
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getnameinfo(const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen,
char *serv, size_t servlen,
+1 -1
View File
@@ -43,7 +43,7 @@
* NI_NAMEREQD flag is set or return the numeric address as a string.
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getnameinfo_verified(const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen,
char *serv, size_t servlen,
+1 -1
View File
@@ -51,7 +51,7 @@ char *optarg; /* argument associated with option */
#define BADARG (int)':'
#define EMSG ""
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getopt(nargc, nargv, ostr)
int nargc;
char * const *nargv;
+1 -1
View File
@@ -40,7 +40,7 @@ const char *__progname;
#endif
#ifndef HAVE_GETPROGNAME
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
getprogname(void)
{
return __progname;
+2 -2
View File
@@ -38,13 +38,13 @@
/*
* Simple gettimeofday that only returns seconds.
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
gettimeofday (struct timeval *tp, void *ignore)
{
time_t t;
t = time(NULL);
tp->tv_sec = t;
tp->tv_sec = (long) t;
tp->tv_usec = 0;
return 0;
}
+1 -1
View File
@@ -36,7 +36,7 @@
#ifndef HAVE_GETUID
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getuid(void)
{
return 17;
+3 -3
View File
@@ -81,7 +81,7 @@ static char **initshells (void);
/*
* Get a list of shells from _PATH_SHELLS, if it exists.
*/
char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
getusershell()
{
char *ret;
@@ -94,7 +94,7 @@ getusershell()
return (ret);
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
endusershell()
{
if (shells != NULL)
@@ -106,7 +106,7 @@ endusershell()
curshell = NULL;
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
setusershell()
{
curshell = initshells();
+2 -2
View File
@@ -164,7 +164,7 @@ static int match (Char *, Char *, Char *);
static void qprintf (const char *, Char *);
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
glob(const char *pattern,
int flags,
int (*errfunc)(const char *, int),
@@ -739,7 +739,7 @@ match(Char *name, Char *pat, Char *patend)
}
/* Free allocated data belonging to a glob_t structure. */
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
globfree(glob_t *pglob)
{
int i;
+2 -2
View File
@@ -50,7 +50,7 @@ pos(char c)
return -1;
}
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
hex_encode(const void *data, size_t size, char **str)
{
const unsigned char *q = data;
@@ -80,7 +80,7 @@ hex_encode(const void *data, size_t size, char **str)
return i * 2;
}
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
hex_decode(const char *str, void *data, size_t len)
{
size_t l;
+5 -3
View File
@@ -38,18 +38,20 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
#define hex_encode rk_hex_encode
#define hex_decode rk_hex_decode
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
hex_encode(const void *, size_t, char **);
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
hex_decode(const char *, void *, size_t);
#endif /* _rk_HEX_H_ */
+1 -1
View File
@@ -39,7 +39,7 @@
* Try to find a fqdn (with `.') in he if possible, else return h_name
*/
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
hostent_find_fqdn (const struct hostent *he)
{
const char *ret = he->h_name;
+1 -1
View File
@@ -64,7 +64,7 @@ extern int h_nerr;
#endif
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
hstrerror(int herr)
{
if (0 <= herr && herr < h_nerr)
+1 -1
View File
@@ -38,7 +38,7 @@
/* Minimal implementation of inet_aton.
* Cannot distinguish between failure and a local broadcast address. */
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
inet_aton(const char *cp, struct in_addr *addr)
{
addr->s_addr = inet_addr(cp);
+1 -1
View File
@@ -113,7 +113,7 @@ inet_ntop_v6 (const void *src, char *dst, size_t size)
}
#endif /* HAVE_IPV6 */
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
inet_ntop(int af, const void *src, char *dst, size_t size)
{
switch (af) {
+60 -1
View File
@@ -35,7 +35,64 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
#ifdef HAVE_WINSOCK
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
inet_pton(int af, const char *src, void *dst)
{
switch (af) {
case AF_INET:
{
struct sockaddr_in si4;
INT r;
INT s = sizeof(si4);
si4.sin_family = AF_INET;
r = WSAStringToAddress(src, AF_INET, NULL, &si4, &s);
if (r == 0) {
memcpy(dst, &si4.sin_addr, sizeof(si4.sin_addr));
return 1;
}
}
break;
case AF_INET6:
{
struct sockaddr_in6 si6;
INT r;
INT s = sizeof(si6);
si6.sin6_family = AF_INET6;
r = WSAStringToAddress(src, AF_INET6, NULL, &si6, &s);
if (r == 0) {
memcpy(dst, &si6.sin6_addr, sizeof(si6.sin6_addr));
return 1;
}
}
break;
default:
_set_errno( EAFNOSUPPORT );
return -1;
}
/* the call failed */
{
int le = WSAGetLastError();
if (le == WSAEINVAL)
return 0;
_set_errno(le);
return -1;
}
}
#else /* !HAVE_WINSOCK */
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
inet_pton(int af, const char *src, void *dst)
{
if (af != AF_INET) {
@@ -44,3 +101,5 @@ inet_pton(int af, const char *src, void *dst)
}
return inet_aton (src, dst);
}
#endif
+1 -1
View File
@@ -35,7 +35,7 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
initgroups(const char *name, gid_t basegid)
{
return 0;
+1 -1
View File
@@ -35,7 +35,7 @@
#ifndef HAVE_INNETGR
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
innetgr(const char *netgroup, const char *machine,
const char *user, const char *domain)
{
+1 -1
View File
@@ -214,7 +214,7 @@ __ivaliduser(FILE *hostf, unsigned raddr, const char *luser,
*
* Returns 0 if ok, -1 if not ok.
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
iruserok(unsigned raddr, int superuser, const char *ruser, const char *luser)
{
char *cp;
+1 -1
View File
@@ -35,7 +35,7 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
issuid(void)
{
#if defined(HAVE_ISSETUGID)
+1 -1
View File
@@ -38,7 +38,7 @@
#include <shadow.h>
#endif
struct passwd * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL
k_getpwnam (const char *user)
{
struct passwd *p;
+1 -1
View File
@@ -38,7 +38,7 @@
#include <shadow.h>
#endif
struct passwd * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL
k_getpwuid (uid_t uid)
{
struct passwd *p;
+1 -1
View File
@@ -39,7 +39,7 @@
#ifndef HAVE_LOCALTIME_R
struct tm * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct tm * ROKEN_LIB_CALL
localtime_r(const time_t *timer, struct tm *result)
{
struct tm *tm;
+1 -1
View File
@@ -35,7 +35,7 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
lstat(const char *path, struct stat *buf)
{
return stat(path, buf);
+1 -1
View File
@@ -41,7 +41,7 @@
#include <sys/types.h>
#endif
void* ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void* ROKEN_LIB_CALL
memmove(void *s1, const void *s2, size_t n)
{
char *s=(char*)s2, *d=(char*)s1;
+21 -17
View File
@@ -41,46 +41,48 @@
*/
static void
accept_it (int s)
accept_it (SOCKET s)
{
int s2;
SOCKET s2;
s2 = accept(s, NULL, NULL);
if(s2 < 0)
if(IS_BAD_SOCKET(s2))
err (1, "accept");
close(s);
dup2(s2, STDIN_FILENO);
dup2(s2, STDOUT_FILENO);
/* dup2(s2, STDERR_FILENO); */
close(s2);
closesocket(s);
dup2(fd_from_socket(s2, _O_RDONLY), STDIN_FILENO);
dup2(fd_from_socket(s2, 0), STDOUT_FILENO);
/* dup2(fd_from_socket(s2, 0), STDERR_FILENO); */
closesocket(s2);
}
/*
* Listen on a specified port, emulating inetd.
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
mini_inetd_addrinfo (struct addrinfo *ai)
{
int ret;
struct addrinfo *a;
int n, nalloc, i;
int *fds;
SOCKET *fds;
fd_set orig_read_set, read_set;
int max_fd = -1;
SOCKET max_fd = (SOCKET)-1;
for (nalloc = 0, a = ai; a != NULL; a = a->ai_next)
++nalloc;
fds = malloc (nalloc * sizeof(*fds));
if (fds == NULL)
if (fds == NULL) {
errx (1, "mini_inetd: out of memory");
UNREACHABLE(return);
}
FD_ZERO(&orig_read_set);
for (i = 0, a = ai; a != NULL; a = a->ai_next) {
fds[i] = socket (a->ai_family, a->ai_socktype, a->ai_protocol);
if (fds[i] < 0)
if (IS_BAD_SOCKET(fds[i]))
continue;
socket_set_reuseaddr (fds[i], 1);
socket_set_ipv6only(fds[i], 1);
@@ -91,11 +93,13 @@ mini_inetd_addrinfo (struct addrinfo *ai)
}
if (listen (fds[i], SOMAXCONN) < 0) {
warn ("listen af = %d", a->ai_family);
close(fds[i]);
closesocket(fds[i]);
continue;
}
#ifndef NO_LIMIT_FD_SETSIZE
if (fds[i] >= FD_SETSIZE)
errx (1, "fd too large");
#endif
FD_SET(fds[i], &orig_read_set);
max_fd = max(max_fd, fds[i]);
++i;
@@ -108,7 +112,7 @@ mini_inetd_addrinfo (struct addrinfo *ai)
read_set = orig_read_set;
ret = select (max_fd + 1, &read_set, NULL, NULL, NULL);
if (ret < 0 && errno != EINTR)
if (IS_SOCKET_ERROR(ret) && SOCK_ERRNO != EINTR)
err (1, "select");
} while (ret <= 0);
@@ -116,14 +120,14 @@ mini_inetd_addrinfo (struct addrinfo *ai)
if (FD_ISSET (fds[i], &read_set)) {
accept_it (fds[i]);
for (i = 0; i < n; ++i)
close(fds[i]);
closesocket(fds[i]);
free(fds);
return;
}
abort ();
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
mini_inetd (int port)
{
int error;
+3 -1
View File
@@ -42,9 +42,11 @@
#endif
#include <errno.h>
#include <roken.h>
#ifndef HAVE_MKSTEMP
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
mkstemp(char *template)
{
int start, i;
+8 -8
View File
@@ -60,7 +60,7 @@ static DBC *cursor;
#define D(X) ((DB*)(X))
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
dbm_close (DBM *db)
{
#ifdef HAVE_DB3
@@ -71,7 +71,7 @@ dbm_close (DBM *db)
#endif
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
dbm_delete (DBM *db, datum dkey)
{
DBT key;
@@ -129,19 +129,19 @@ dbm_get (DB *db, int flags)
#define DB_KEYEXIST 1
#endif
datum ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION datum ROKEN_LIB_CALL
dbm_firstkey (DBM *db)
{
return dbm_get(D(db), DB_FIRST);
}
datum ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION datum ROKEN_LIB_CALL
dbm_nextkey (DBM *db)
{
return dbm_get(D(db), DB_NEXT);
}
DBM* ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION DBM* ROKEN_LIB_CALL
dbm_open (const char *file, int flags, mode_t mode)
{
DB *db;
@@ -184,7 +184,7 @@ dbm_open (const char *file, int flags, mode_t mode)
return (DBM*)db;
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
dbm_store (DBM *db, datum dkey, datum dvalue, int flags)
{
int ret;
@@ -204,13 +204,13 @@ dbm_store (DBM *db, datum dkey, datum dvalue, int flags)
RETURN(ret);
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
dbm_error (DBM *db)
{
return 0;
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
dbm_clearerr (DBM *db)
{
return 0;
+12 -10
View File
@@ -41,9 +41,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
@@ -78,14 +80,14 @@ typedef struct {
} DBM;
#endif
int ROKEN_LIB_FUNCTION dbm_clearerr (DBM*);
void ROKEN_LIB_FUNCTION dbm_close (DBM*);
int ROKEN_LIB_FUNCTION dbm_delete (DBM*, datum);
int ROKEN_LIB_FUNCTION dbm_error (DBM*);
datum ROKEN_LIB_FUNCTION dbm_fetch (DBM*, datum);
datum ROKEN_LIB_FUNCTION dbm_firstkey (DBM*);
datum ROKEN_LIB_FUNCTION dbm_nextkey (DBM*);
DBM* ROKEN_LIB_FUNCTION dbm_open (const char*, int, mode_t);
int ROKEN_LIB_FUNCTION dbm_store (DBM*, datum, datum, int);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL dbm_clearerr (DBM*);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL dbm_close (DBM*);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL dbm_delete (DBM*, datum);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL dbm_error (DBM*);
ROKEN_LIB_FUNCTION datum ROKEN_LIB_CALL dbm_fetch (DBM*, datum);
ROKEN_LIB_FUNCTION datum ROKEN_LIB_CALL dbm_firstkey (DBM*);
ROKEN_LIB_FUNCTION datum ROKEN_LIB_CALL dbm_nextkey (DBM*);
ROKEN_LIB_FUNCTION DBM* ROKEN_LIB_CALL dbm_open (const char*, int, mode_t);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL dbm_store (DBM*, datum, datum, int);
#endif /* __ndbm_wrap_h__ */
+28 -9
View File
@@ -33,17 +33,13 @@
#include <config.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include "roken.h"
/*
* Like read but never return partial data.
*/
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
net_read (int fd, void *buf, size_t nbytes)
{
char *cbuf = (char *)buf;
@@ -51,11 +47,7 @@ net_read (int fd, void *buf, size_t nbytes)
size_t rem = nbytes;
while (rem > 0) {
#ifdef WIN32
count = recv (fd, cbuf, rem, 0);
#else
count = read (fd, cbuf, rem);
#endif
if (count < 0) {
if (errno == EINTR)
continue;
@@ -69,3 +61,30 @@ net_read (int fd, void *buf, size_t nbytes)
}
return nbytes;
}
#ifdef SOCKET_IS_NOT_AN_FD
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
net_read_s (SOCKET sock, void *buf, size_t nbytes)
{
char *cbuf = (char *)buf;
ssize_t count;
size_t rem = nbytes;
while (rem > 0) {
count = recv (sock, cbuf, rem, 0);
if (count < 0) {
if (errno == EINTR)
continue;
else
return count;
} else if (count == 0) {
return count;
}
cbuf += count;
rem -= count;
}
return nbytes;
}
#endif
+26 -9
View File
@@ -33,17 +33,13 @@
#include <config.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include "roken.h"
/*
* Like write but never return partial data.
*/
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
net_write (int fd, const void *buf, size_t nbytes)
{
const char *cbuf = (const char *)buf;
@@ -51,11 +47,7 @@ net_write (int fd, const void *buf, size_t nbytes)
size_t rem = nbytes;
while (rem > 0) {
#ifdef WIN32
count = send (fd, cbuf, rem, 0);
#else
count = write (fd, cbuf, rem);
#endif
if (count < 0) {
if (errno == EINTR)
continue;
@@ -67,3 +59,28 @@ net_write (int fd, const void *buf, size_t nbytes)
}
return nbytes;
}
#ifdef SOCKET_IS_NOT_AN_FD
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
net_write_s (SOCKET sock, const void *buf, size_t nbytes)
{
const char *cbuf = (const char *)buf;
ssize_t count;
size_t rem = nbytes;
while (rem > 0) {
count = send (sock, cbuf, rem, 0);
if (count < 0) {
if (errno == EINTR)
continue;
else
return count;
}
cbuf += count;
rem -= count;
}
return nbytes;
}
#endif
+3 -3
View File
@@ -56,19 +56,19 @@ static struct units bytes_short_units[] = {
{ NULL, 0 }
};
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_bytes (const char *s, const char *def_unit)
{
return parse_units (s, bytes_units, def_unit);
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_bytes (int t, char *s, size_t len)
{
return unparse_units (t, bytes_units, s, len);
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_bytes_short (int t, char *s, size_t len)
{
return unparse_units_approx (t, bytes_short_units, s, len);
+6 -4
View File
@@ -38,19 +38,21 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_bytes (const char *s, const char *def_unit);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_bytes (int t, char *s, size_t len);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_bytes_short (int t, char *s, size_t len);
#endif /* __PARSE_BYTES_H__ */
+4 -2
View File
@@ -40,8 +40,8 @@
static struct testcase {
size_t size;
time_t val;
char *str;
int val;
char *str;
} tests[] = {
{ 8, 1, "1 second" },
{ 17, 61, "1 minute 1 second" },
@@ -97,6 +97,7 @@ main(int argc, char **argv)
errx(1, "test %i not zero terminated", i);
rk_test_mem_free("underrun");
}
buf = rk_test_mem_alloc(RK_TM_OVERRUN, "overrun",
tests[i].str, tests[i].size + 1);
j = parse_time(buf, "s");
@@ -110,6 +111,7 @@ main(int argc, char **argv)
if (j != tests[i].val)
errx(1, "parse_time failed for test %d", i);
rk_test_mem_free("underrun");
}
return 0;
}
+4 -4
View File
@@ -50,25 +50,25 @@ static struct units time_units[] = {
{NULL, 0},
};
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_time (const char *s, const char *def_unit)
{
return parse_units (s, time_units, def_unit);
}
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
unparse_time (int t, char *s, size_t len)
{
return unparse_units (t, time_units, s, len);
}
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
unparse_time_approx (int t, char *s, size_t len)
{
return unparse_units_approx (t, time_units, s, len);
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_time_table (FILE *f)
{
print_units_table (time_units, f);
+7 -5
View File
@@ -38,22 +38,24 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
int
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_time (const char *s, const char *def_unit);
size_t
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
unparse_time (int t, char *s, size_t len);
size_t
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
unparse_time_approx (int t, char *s, size_t len);
void
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_time_table (FILE *f);
#endif /* __PARSE_TIME_H__ */
+10 -10
View File
@@ -70,7 +70,7 @@ parse_something (const char *s, const struct units *units,
p = s;
while (*p) {
double val;
int val;
char *next;
const struct units *u, *partial_unit;
size_t u_len;
@@ -80,7 +80,7 @@ parse_something (const char *s, const struct units *units,
while(isspace((unsigned char)*p) || *p == ',')
++p;
val = strtod (p, &next); /* strtol(p, &next, 0); */
val = (int) strtod (p, &next); /* strtol(p, &next, 0); */
if (p == next) {
val = 0;
if(!accept_no_val_p)
@@ -149,7 +149,7 @@ acc_units(int res, int val, unsigned mult)
return res + val * mult;
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_units (const char *s, const struct units *units,
const char *def_unit)
{
@@ -175,7 +175,7 @@ acc_flags(int res, int val, unsigned mult)
return -1;
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_flags (const char *s, const struct units *units,
int orig)
{
@@ -208,7 +208,7 @@ unparse_something (int num, const struct units *units, char *s, size_t len,
tmp = (*print) (s, len, divisor, u->name, num);
if (tmp < 0)
return tmp;
if (tmp > len) {
if (tmp > (int) len) {
len = 0;
s = NULL;
} else {
@@ -245,7 +245,7 @@ update_unit_approx (int in, unsigned mult)
return update_unit (in, mult);
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_units (int num, const struct units *units, char *s, size_t len)
{
return unparse_something (num, units, s, len,
@@ -254,7 +254,7 @@ unparse_units (int num, const struct units *units, char *s, size_t len)
"0");
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_units_approx (int num, const struct units *units, char *s, size_t len)
{
return unparse_something (num, units, s, len,
@@ -263,7 +263,7 @@ unparse_units_approx (int num, const struct units *units, char *s, size_t len)
"0");
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_units_table (const struct units *units, FILE *f)
{
const struct units *u, *u2;
@@ -308,7 +308,7 @@ update_flag (int in, unsigned mult)
return in - mult;
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_flags (int num, const struct units *units, char *s, size_t len)
{
return unparse_something (num, units, s, len,
@@ -317,7 +317,7 @@ unparse_flags (int num, const struct units *units, char *s, size_t len)
"");
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_flags_table (const struct units *units, FILE *f)
{
const struct units *u;
+10 -8
View File
@@ -41,9 +41,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
@@ -52,28 +54,28 @@ struct units {
unsigned mult;
};
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_units (const char *s, const struct units *units,
const char *def_unit);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_units_table (const struct units *units, FILE *f);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
parse_flags (const char *s, const struct units *units,
int orig);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_units (int num, const struct units *units, char *s, size_t len);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_units_approx (int num, const struct units *units, char *s,
size_t len);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unparse_flags (int num, const struct units *units, char *s, size_t len);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_flags_table (const struct units *units, FILE *f);
#endif /* __PARSE_UNITS_H__ */
+1 -1
View File
@@ -47,7 +47,7 @@ extern char **environ;
* value by altering an existing variable or creating a new one.
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
putenv(const char *string)
{
int i;
+1 -1
View File
@@ -36,7 +36,7 @@
#include "roken.h"
#include <stdio.h>
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rcmd(char **ahost,
unsigned short inport,
const char *locuser,
+1 -1
View File
@@ -35,7 +35,7 @@
#include "roken.h"
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
readv(int d, const struct iovec *iov, int iovcnt)
{
ssize_t ret, nb;
+1 -1
View File
@@ -37,7 +37,7 @@
#include <stdlib.h>
#include "roken.h"
void * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
rk_realloc(void *ptr, size_t size)
{
if (ptr == NULL)
+1 -1
View File
@@ -35,7 +35,7 @@
#include "roken.h"
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
recvmsg(int s, struct msghdr *msg, int flags)
{
ssize_t ret, nb;
+2 -2
View File
@@ -144,7 +144,7 @@ main(int argc, char **argv)
}
case rk_ns_t_sshfp : {
struct rk_sshfp_record *sshfp = rr->u.sshfp;
int i;
size_t i;
printf ("alg %u type %u length %lu data ", sshfp->algorithm,
sshfp->type, (unsigned long)sshfp->sshfp_len);
@@ -156,7 +156,7 @@ main(int argc, char **argv)
}
case rk_ns_t_ds : {
struct rk_ds_record *ds = rr->u.ds;
int i;
size_t i;
printf ("key tag %u alg %u type %u length %u data ",
ds->key_tag, ds->algorithm, ds->digest_type,
+8 -8
View File
@@ -78,7 +78,7 @@ static struct stot{
int _resolve_debug = 0;
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_dns_string_to_type(const char *name)
{
struct stot *p = stot;
@@ -88,7 +88,7 @@ rk_dns_string_to_type(const char *name)
return -1;
}
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
rk_dns_type_to_string(int type)
{
struct stot *p = stot;
@@ -110,7 +110,7 @@ dns_free_rr(struct rk_resource_record *rr)
free(rr);
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_free_data(struct rk_dns_reply *r)
{
struct rk_resource_record *rr;
@@ -584,7 +584,7 @@ dns_lookup_int(const char *domain, int rr_class, int rr_type)
return r;
}
struct rk_dns_reply * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct rk_dns_reply * ROKEN_LIB_CALL
rk_dns_lookup(const char *domain, const char *type_name)
{
int type;
@@ -614,7 +614,7 @@ compare_srv(const void *a, const void *b)
#endif
/* try to rearrange the srv-records by the algorithm in RFC2782 */
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_srv_order(struct rk_dns_reply *r)
{
struct rk_resource_record **srvs, **ss, **headp;
@@ -704,18 +704,18 @@ rk_dns_srv_order(struct rk_dns_reply *r)
#else /* NOT defined(HAVE_RES_SEARCH) && defined(HAVE_DN_EXPAND) */
struct rk_dns_reply * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct rk_dns_reply * ROKEN_LIB_CALL
rk_dns_lookup(const char *domain, const char *type_name)
{
return NULL;
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_free_data(struct rk_dns_reply *r)
{
}
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_srv_order(struct rk_dns_reply *r)
{
}
+8 -6
View File
@@ -38,9 +38,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
@@ -231,15 +233,15 @@ struct rk_dns_reply{
extern "C" {
#endif
struct rk_dns_reply* ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct rk_dns_reply* ROKEN_LIB_CALL
rk_dns_lookup(const char *, const char *);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_free_data(struct rk_dns_reply *);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_dns_string_to_type(const char *name);
const char *ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
rk_dns_type_to_string(int type);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dns_srv_order(struct rk_dns_reply*);
#ifdef __cplusplus
+2
View File
@@ -41,7 +41,9 @@
#endif
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_PTY_H
#include <pty.h>
#endif
+65 -46
View File
@@ -38,9 +38,11 @@
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
@@ -120,6 +122,8 @@
#define O_ACCMODE 003
#endif
#ifndef _WIN32
#ifndef _PATH_DEV
#define _PATH_DEV "/dev/"
#endif
@@ -144,6 +148,16 @@
#define MAXPATHLEN (1024+4)
#endif
#endif /* !_WIN32 */
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
#endif
#ifndef RETSIGTYPE
#define RETSIGTYPE void
#endif
#ifndef SIG_ERR
#define SIG_ERR ((RETSIGTYPE (*)(int))-1)
#endif
@@ -238,6 +252,11 @@
#define INET6_ADDRSTRLEN 46
#endif
/*
* error codes for inet_ntop/inet_pton
*/
#define EAFNOSUPPORT WSAEAFNOSUPPORT
/*
* for shutdown(2)
*/
@@ -268,183 +287,183 @@ SigAction signal(int iSig, SigAction pAction); /* BSD compatible */
#endif
#define simple_execve rk_simple_execve
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execve(const char*, char*const[], char*const[]);
#define simple_execve_timed rk_simple_execve_timed
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execve_timed(const char *, char *const[],
char *const [], time_t (*)(void *),
void *, time_t);
#define simple_execvp rk_simple_execvp
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execvp(const char*, char *const[]);
#define simple_execvp_timed rk_simple_execvp_timed
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execvp_timed(const char *, char *const[],
time_t (*)(void *), void *, time_t);
#define simple_execlp rk_simple_execlp
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execlp(const char*, ...);
#define simple_execle rk_simple_execle
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
simple_execle(const char*, ...);
#define wait_for_process rk_wait_for_process
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
wait_for_process(pid_t);
#define wait_for_process_timed rk_wait_for_process_timed
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
wait_for_process_timed(pid_t, time_t (*)(void *),
void *, time_t);
#define pipe_execv rk_pipe_execv
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
pipe_execv(FILE**, FILE**, FILE**, const char*, ...);
#define print_version rk_print_version
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_version(const char *);
#define eread rk_eread
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
eread (int fd, void *buf, size_t nbytes);
#define ewrite rk_ewrite
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
ewrite (int fd, const void *buf, size_t nbytes);
struct hostent;
#define hostent_find_fqdn rk_hostent_find_fqdn
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
hostent_find_fqdn (const struct hostent *);
#define esetenv rk_esetenv
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
esetenv(const char *, const char *, int);
#define socket_set_address_and_port rk_socket_set_address_and_port
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_address_and_port (struct sockaddr *, const void *, int);
#define socket_addr_size rk_socket_addr_size
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_addr_size (const struct sockaddr *);
#define socket_set_any rk_socket_set_any
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_any (struct sockaddr *, int);
#define socket_sockaddr_size rk_socket_sockaddr_size
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_sockaddr_size (const struct sockaddr *);
#define socket_get_address rk_socket_get_address
void * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
socket_get_address (const struct sockaddr *);
#define socket_get_port rk_socket_get_port
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
socket_get_port (const struct sockaddr *);
#define socket_set_port rk_socket_set_port
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_port (struct sockaddr *, int);
#define socket_set_portrange rk_socket_set_portrange
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_portrange (int, int, int);
#define socket_set_debug rk_socket_set_debug
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_debug (int);
#define socket_set_tos rk_socket_set_tos
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_tos (int, int);
#define socket_set_reuseaddr rk_socket_set_reuseaddr
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_reuseaddr (int, int);
#define socket_set_ipv6only rk_socket_set_ipv6only
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_ipv6only (int, int);
#define vstrcollect rk_vstrcollect
char ** ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
vstrcollect(va_list *ap);
#define strcollect rk_strcollect
char ** ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
strcollect(char *first, ...);
#define timevalfix rk_timevalfix
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
timevalfix(struct timeval *t1);
#define timevaladd rk_timevaladd
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
timevaladd(struct timeval *t1, const struct timeval *t2);
#define timevalsub rk_timevalsub
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
timevalsub(struct timeval *t1, const struct timeval *t2);
#define pid_file_write rk_pid_file_write
char *ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
pid_file_write (const char *progname);
#define pid_file_delete rk_pid_file_delete
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
pid_file_delete (char **);
#define read_environment rk_read_environment
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
read_environment(const char *file, char ***env);
#define free_environment rk_free_environment
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
free_environment(char **);
#define warnerr rk_warnerr
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_warnerr(int doerrno, const char *fmt, va_list ap)
__attribute__ ((format (printf, 2, 0)));
void * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
rk_realloc(void *, size_t);
struct rk_strpool;
char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_strpoolcollect(struct rk_strpool *);
struct rk_strpool * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL
rk_strpoolprintf(struct rk_strpool *, const char *, ...)
__attribute__ ((format (printf, 2, 3)));
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_strpoolfree(struct rk_strpool *);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_dumpdata (const char *, const void *, size_t);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_undumpdata (const char *, void **, size_t *);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_xfree (void *);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_cloexec(int);
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
rk_cloexec_file(FILE *);
int ROKEN_LIB_FUNCTION
+178 -96
View File
@@ -41,6 +41,70 @@
#include <string.h>
#include <signal.h>
#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL __cdecl
#else
#define ROKEN_LIB_FUNCTION
#define ROKEN_LIB_CALL
#endif
#endif
#ifdef HAVE_WINSOCK
/* Declarations for Microsoft Windows */
#include<ws2tcpip.h>
#define IS_BAD_SOCKET(s) ((s) == INVALID_SOCKET)
#define IS_SOCKET_ERROR(rv) ((rv) == SOCKET_ERROR)
#define SOCK_ERRNO WSAGetLastError()
#define SOCK_IOCTL(s,c,a) ioctlsocket((s),(c),(a))
#define ETIMEDOUT WSAETIMEDOUT
#define EWOULDBLOCK WSAEWOULDBLOCK
#define SOCK_INIT rk_WSAStartup()
#define SOCK_EXIT rk_WSACleanup()
#define NEED_SOCK_INIT 1
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSAStartup(void);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSACleanup(void);
#else /* not WinSock */
typedef int SOCKET;
#define closesocket(x) close(x)
#define SOCK_IOCTL(s,c,a) ioctl((s),(c),(a))
#define IS_BAD_SOCKET(s) ((s) < 0)
#define IS_SOCKET_ERROR(rv) ((rv) < 0)
#define SOCK_ERRNO errno
#define INVALID_SOCKET (-1)
#define SOCK_INIT (0)
#define SOCK_EXIT (0)
#undef NEED_SOCK_INIT
#endif
#ifdef _MSC_VER
/* Declarations for Microsoft Visual C runtime on Windows */
#include<process.h>
#include<io.h>
#define UNREACHABLE(x) x
#define UNUSED_ARGUMENT(x) ((void) x)
#else
#define UNREACHABLE(x)
#define UNUSED_ARGUMENT(x)
#endif
#ifdef _AIX
struct ether_addr;
struct sockaddr_dl;
@@ -133,8 +197,12 @@ struct sockaddr_dl;
#endif
#ifndef HAVE_SSIZE_T
#ifdef _WIN64
typedef __int64 ssize_t;
#else
typedef int ssize_t;
#endif
#endif
#include <roken-common.h>
@@ -152,21 +220,21 @@ ROKEN_CPP_START
#ifndef HAVE_PUTENV
#define putenv rk_putenv
int ROKEN_LIB_FUNCTION putenv(const char *);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL putenv(const char *);
#endif
#if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO)
#ifndef HAVE_SETENV
#define setenv rk_setenv
#endif
int ROKEN_LIB_FUNCTION setenv(const char *, const char *, int);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setenv(const char *, const char *, int);
#endif
#if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO)
#ifndef HAVE_UNSETENV
#define unsetenv rk_unsetenv
#endif
void ROKEN_LIB_FUNCTION unsetenv(const char *);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL unsetenv(const char *);
#endif
#if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
@@ -174,15 +242,15 @@ void ROKEN_LIB_FUNCTION unsetenv(const char *);
#define getusershell rk_getusershell
#define endusershell rk_endusershell
#endif
char * ROKEN_LIB_FUNCTION getusershell(void);
void ROKEN_LIB_FUNCTION endusershell(void);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL getusershell(void);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL endusershell(void);
#endif
#if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO)
#ifndef HAVE_SNPRINTF
#define snprintf rk_snprintf
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_snprintf (char *, size_t, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
#endif
@@ -191,7 +259,7 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_VSNPRINTF
#define vsnprintf rk_vsnprintf
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_vsnprintf (char *, size_t, const char *, va_list)
__attribute__((format (printf, 3, 0)));
#endif
@@ -200,7 +268,7 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_ASPRINTF
#define asprintf rk_asprintf
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_asprintf (char **, const char *, ...)
__attribute__ ((format (printf, 2, 3)));
#endif
@@ -209,7 +277,7 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_VASPRINTF
#define vasprintf rk_vasprintf
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_vasprintf (char **, const char *, va_list)
__attribute__((format (printf, 2, 0)));
#endif
@@ -218,7 +286,7 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_ASNPRINTF
#define asnprintf rk_asnprintf
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_asnprintf (char **, size_t, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
#endif
@@ -227,83 +295,83 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_VASNPRINTF
#define vasnprintf rk_vasnprintf
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
vasnprintf (char **, size_t, const char *, va_list)
__attribute__((format (printf, 3, 0)));
#endif
#ifndef HAVE_STRDUP
#define strdup rk_strdup
char * ROKEN_LIB_FUNCTION strdup(const char *);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strdup(const char *);
#endif
#if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO)
#ifndef HAVE_STRNDUP
#define strndup rk_strndup
#endif
char * ROKEN_LIB_FUNCTION strndup(const char *, size_t);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strndup(const char *, size_t);
#endif
#ifndef HAVE_STRLWR
#define strlwr rk_strlwr
char * ROKEN_LIB_FUNCTION strlwr(char *);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strlwr(char *);
#endif
#ifndef HAVE_STRNLEN
#define strnlen rk_strnlen
size_t ROKEN_LIB_FUNCTION strnlen(const char*, size_t);
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strnlen(const char*, size_t);
#endif
#if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO)
#ifndef HAVE_STRSEP
#define strsep rk_strsep
#endif
char * ROKEN_LIB_FUNCTION strsep(char**, const char*);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strsep(char**, const char*);
#endif
#if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO)
#ifndef HAVE_STRSEP_COPY
#define strsep_copy rk_strsep_copy
#endif
ssize_t ROKEN_LIB_FUNCTION strsep_copy(const char**, const char*, char*, size_t);
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL strsep_copy(const char**, const char*, char*, size_t);
#endif
#ifndef HAVE_STRCASECMP
#define strcasecmp rk_strcasecmp
int ROKEN_LIB_FUNCTION strcasecmp(const char *, const char *);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL strcasecmp(const char *, const char *);
#endif
#ifdef NEED_FCLOSE_PROTO
int ROKEN_LIB_FUNCTION fclose(FILE *);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fclose(FILE *);
#endif
#ifdef NEED_STRTOK_R_PROTO
char * ROKEN_LIB_FUNCTION strtok_r(char *, const char *, char **);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strtok_r(char *, const char *, char **);
#endif
#ifndef HAVE_STRUPR
#define strupr rk_strupr
char * ROKEN_LIB_FUNCTION strupr(char *);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strupr(char *);
#endif
#ifndef HAVE_STRLCPY
#define strlcpy rk_strlcpy
size_t ROKEN_LIB_FUNCTION strlcpy (char *, const char *, size_t);
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcpy (char *, const char *, size_t);
#endif
#ifndef HAVE_STRLCAT
#define strlcat rk_strlcat
size_t ROKEN_LIB_FUNCTION strlcat (char *, const char *, size_t);
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcat (char *, const char *, size_t);
#endif
#ifndef HAVE_GETDTABLESIZE
#define getdtablesize rk_getdtablesize
int ROKEN_LIB_FUNCTION getdtablesize(void);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL getdtablesize(void);
#endif
#if !defined(HAVE_STRERROR) && !defined(strerror)
#define strerror rk_strerror
char * ROKEN_LIB_FUNCTION strerror(int);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strerror(int);
#endif
#if !defined(HAVE_STRERROR) && !defined(strerror)
@@ -319,6 +387,7 @@ int ROKEN_LIB_FUNCTION strerror_r(int, char *, size_t);
/* This causes a fatal error under Psoriasis */
#ifndef SunOS
const char * ROKEN_LIB_FUNCTION hstrerror(int);
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL hstrerror(int);
#endif
#endif
@@ -330,88 +399,88 @@ extern int h_errno;
#ifndef HAVE_INET_ATON
#define inet_aton rk_inet_aton
#endif
int ROKEN_LIB_FUNCTION inet_aton(const char *, struct in_addr *);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL inet_aton(const char *, struct in_addr *);
#endif
#ifndef HAVE_INET_NTOP
#define inet_ntop rk_inet_ntop
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
inet_ntop(int af, const void *src, char *dst, size_t size);
#endif
#ifndef HAVE_INET_PTON
#define inet_pton rk_inet_pton
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
inet_pton(int, const char *, void *);
#endif
#ifndef HAVE_GETCWD
#define getcwd rk_getcwd
char* ROKEN_LIB_FUNCTION getcwd(char *, size_t);
ROKEN_LIB_FUNCTION char* ROKEN_LIB_CALL getcwd(char *, size_t);
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
struct passwd * ROKEN_LIB_FUNCTION k_getpwnam (const char *);
struct passwd * ROKEN_LIB_FUNCTION k_getpwuid (uid_t);
ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwnam (const char *);
ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwuid (uid_t);
#endif
const char * ROKEN_LIB_FUNCTION get_default_username (void);
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL get_default_username (void);
#ifndef HAVE_SETEUID
#define seteuid rk_seteuid
int ROKEN_LIB_FUNCTION seteuid(uid_t);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL seteuid(uid_t);
#endif
#ifndef HAVE_SETEGID
#define setegid rk_setegid
int ROKEN_LIB_FUNCTION setegid(gid_t);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setegid(gid_t);
#endif
#ifndef HAVE_LSTAT
#define lstat rk_lstat
int ROKEN_LIB_FUNCTION lstat(const char *, struct stat *);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL lstat(const char *, struct stat *);
#endif
#if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO)
#ifndef HAVE_MKSTEMP
#define mkstemp rk_mkstemp
#endif
int ROKEN_LIB_FUNCTION mkstemp(char *);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL mkstemp(char *);
#endif
#ifndef HAVE_CGETENT
#define cgetent rk_cgetent
#define cgetstr rk_cgetstr
int ROKEN_LIB_FUNCTION cgetent(char **, char **, const char *);
int ROKEN_LIB_FUNCTION cgetstr(char *, const char *, char **);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **, char **, const char *);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *, const char *, char **);
#endif
#ifndef HAVE_INITGROUPS
#define initgroups rk_initgroups
int ROKEN_LIB_FUNCTION initgroups(const char *, gid_t);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL initgroups(const char *, gid_t);
#endif
#ifndef HAVE_FCHOWN
#define fchown rk_fchown
int ROKEN_LIB_FUNCTION fchown(int, uid_t, gid_t);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fchown(int, uid_t, gid_t);
#endif
#if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO)
#ifndef HAVE_DAEMON
#define daemon rk_daemon
#endif
int ROKEN_LIB_FUNCTION daemon(int, int);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL daemon(int, int);
#endif
#ifndef HAVE_CHOWN
#define chown rk_chown
int ROKEN_LIB_FUNCTION chown(const char *, uid_t, gid_t);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL chown(const char *, uid_t, gid_t);
#endif
#ifndef HAVE_RCMD
#define rcmd rk_rcmd
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rcmd(char **, unsigned short, const char *,
const char *, const char *, int *);
#endif
@@ -420,13 +489,13 @@ int ROKEN_LIB_FUNCTION
#ifndef HAVE_INNETGR
#define innetgr rk_innetgr
#endif
int ROKEN_LIB_FUNCTION innetgr(const char*, const char*,
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL innetgr(const char*, const char*,
const char*, const char*);
#endif
#ifndef HAVE_IRUSEROK
#define iruserok rk_iruserok
int ROKEN_LIB_FUNCTION iruserok(unsigned, int,
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int,
const char *, const char *);
#endif
@@ -434,34 +503,34 @@ int ROKEN_LIB_FUNCTION iruserok(unsigned, int,
#ifndef HAVE_GETHOSTNAME
#define gethostname rk_gethostname
#endif
int ROKEN_LIB_FUNCTION gethostname(char *, int);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL gethostname(char *, int);
#endif
#ifndef HAVE_WRITEV
#define writev rk_writev
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
writev(int, const struct iovec *, int);
#endif
#ifndef HAVE_READV
#define readv rk_readv
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
readv(int, const struct iovec *, int);
#endif
#ifndef HAVE_PIDFILE
#define pidfile rk_pidfile
void ROKEN_LIB_FUNCTION pidfile (const char*);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL pidfile (const char*);
#endif
#ifndef HAVE_BSWAP32
#define bswap32 rk_bswap32
unsigned int ROKEN_LIB_FUNCTION bswap32(unsigned int);
ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL bswap32(unsigned int);
#endif
#ifndef HAVE_BSWAP16
#define bswap16 rk_bswap16
unsigned short ROKEN_LIB_FUNCTION bswap16(unsigned short);
ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL bswap16(unsigned short);
#endif
#ifndef HAVE_FLOCK
@@ -486,24 +555,37 @@ int rk_flock(int fd, int operation);
#define dirfd(x) ((x)->dd_fd)
#endif
time_t ROKEN_LIB_FUNCTION tm2time (struct tm, int);
ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL tm2time (struct tm, int);
int ROKEN_LIB_FUNCTION unix_verify_user(char *, char *);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL unix_verify_user(char *, char *);
int ROKEN_LIB_FUNCTION roken_concat (char *, size_t, ...);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_concat (char *, size_t, ...);
size_t ROKEN_LIB_FUNCTION roken_mconcat (char **, size_t, ...);
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_mconcat (char **, size_t, ...);
int ROKEN_LIB_FUNCTION roken_vconcat (char *, size_t, va_list);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_vconcat (char *, size_t, va_list);
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
roken_vmconcat (char **, size_t, va_list);
ssize_t ROKEN_LIB_FUNCTION net_write (int, const void *, size_t);
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL net_write (int, const void *, size_t);
ssize_t ROKEN_LIB_FUNCTION net_read (int, void *, size_t);
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL net_read (int, void *, size_t);
int ROKEN_LIB_FUNCTION issuid(void);
#ifdef SOCKET_IS_NOT_AN_FD
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL net_write_s (SOCKET, const void *, size_t);
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL net_read_s (SOCKET, void *, size_t);
#else
#define net_read_s net_read
#define net_write_s net_write
#endif
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL issuid(void);
#ifndef HAVE_STRUCT_WINSIZE
struct winsize {
@@ -512,11 +594,11 @@ struct winsize {
};
#endif
int ROKEN_LIB_FUNCTION get_window_size(int fd, struct winsize *);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, struct winsize *);
#ifndef HAVE_VSYSLOG
#define vsyslog rk_vsyslog
void ROKEN_LIB_FUNCTION vsyslog(int, const char *, va_list);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL vsyslog(int, const char *, va_list);
#endif
#if !HAVE_DECL_OPTARG
@@ -531,25 +613,25 @@ extern int opterr;
#ifndef HAVE_GETIPNODEBYNAME
#define getipnodebyname rk_getipnodebyname
struct hostent * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
getipnodebyname (const char *, int, int, int *);
#endif
#ifndef HAVE_GETIPNODEBYADDR
#define getipnodebyaddr rk_getipnodebyaddr
struct hostent * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
getipnodebyaddr (const void *, size_t, int, int *);
#endif
#ifndef HAVE_FREEHOSTENT
#define freehostent rk_freehostent
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
freehostent (struct hostent *);
#endif
#ifndef HAVE_COPYHOSTENT
#define copyhostent rk_copyhostent
struct hostent * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
copyhostent (const struct hostent *);
#endif
@@ -617,7 +699,7 @@ struct addrinfo {
#ifndef HAVE_GETADDRINFO
#define getaddrinfo rk_getaddrinfo
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getaddrinfo(const char *,
const char *,
const struct addrinfo *,
@@ -626,7 +708,7 @@ getaddrinfo(const char *,
#ifndef HAVE_GETNAMEINFO
#define getnameinfo rk_getnameinfo
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getnameinfo(const struct sockaddr *, socklen_t,
char *, size_t,
char *, size_t,
@@ -635,65 +717,65 @@ getnameinfo(const struct sockaddr *, socklen_t,
#ifndef HAVE_FREEADDRINFO
#define freeaddrinfo rk_freeaddrinfo
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
freeaddrinfo(struct addrinfo *);
#endif
#ifndef HAVE_GAI_STRERROR
#define gai_strerror rk_gai_strerror
const char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
gai_strerror(int);
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
getnameinfo_verified(const struct sockaddr *, socklen_t,
char *, size_t,
char *, size_t,
int);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **);
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);
#ifndef HAVE_STRFTIME
#define strftime rk_strftime
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
strftime (char *, size_t, const char *, const struct tm *);
#endif
#ifndef HAVE_STRPTIME
#define strptime rk_strptime
char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
strptime (const char *, const char *, struct tm *);
#endif
#ifndef HAVE_EMALLOC
#define emalloc rk_emalloc
void * ROKEN_LIB_FUNCTION emalloc (size_t);
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL emalloc (size_t);
#endif
#ifndef HAVE_ECALLOC
#define ecalloc rk_ecalloc
void * ROKEN_LIB_FUNCTION ecalloc(size_t, size_t);
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ecalloc(size_t, size_t);
#endif
#ifndef HAVE_EREALLOC
#define erealloc rk_erealloc
void * ROKEN_LIB_FUNCTION erealloc (void *, size_t);
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL erealloc (void *, size_t);
#endif
#ifndef HAVE_ESTRDUP
#define estrdup rk_estrdup
char * ROKEN_LIB_FUNCTION estrdup (const char *);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL estrdup (const char *);
#endif
/*
* kludges and such
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_gethostby_setup(const char*, const char*);
struct hostent* ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyname(const char*);
struct hostent* ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyaddr(const void*, size_t, int);
#ifdef GETSERVBYNAME_PROTO_COMPATIBLE
@@ -716,24 +798,24 @@ roken_gethostbyaddr(const void*, size_t, int);
#ifndef HAVE_SETPROGNAME
#define setprogname rk_setprogname
void ROKEN_LIB_FUNCTION setprogname(const char *);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL setprogname(const char *);
#endif
#ifndef HAVE_GETPROGNAME
#define getprogname rk_getprogname
const char * ROKEN_LIB_FUNCTION getprogname(void);
ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void);
#endif
#if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME
extern const char *__progname;
#endif
void ROKEN_LIB_FUNCTION mini_inetd_addrinfo (struct addrinfo*);
void ROKEN_LIB_FUNCTION mini_inetd (int);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL mini_inetd_addrinfo (struct addrinfo*);
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL mini_inetd (int);
#ifndef HAVE_LOCALTIME_R
#define localtime_r rk_localtime_r
struct tm * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct tm * ROKEN_LIB_CALL
localtime_r(const time_t *, struct tm *);
#endif
@@ -741,7 +823,7 @@ localtime_r(const time_t *, struct tm *);
#ifndef HAVE_STRSVIS
#define strsvis rk_strsvis
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
strsvis(char *, const char *, int, const char *);
#endif
@@ -749,7 +831,7 @@ strsvis(char *, const char *, int, const char *);
#ifndef HAVE_STRUNVIS
#define strunvis rk_strunvis
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
strunvis(char *, const char *);
#endif
@@ -757,7 +839,7 @@ strunvis(char *, const char *);
#ifndef HAVE_STRVIS
#define strvis rk_strvis
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
strvis(char *, const char *, int);
#endif
@@ -765,7 +847,7 @@ strvis(char *, const char *, int);
#ifndef HAVE_STRVISX
#define strvisx rk_strvisx
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
strvisx(char *, const char *, size_t, int);
#endif
@@ -773,7 +855,7 @@ strvisx(char *, const char *, size_t, int);
#ifndef HAVE_SVIS
#define svis rk_svis
#endif
char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
svis(char *, int, int, int, const char *);
#endif
@@ -781,7 +863,7 @@ svis(char *, int, int, int, const char *);
#ifndef HAVE_UNVIS
#define unvis rk_unvis
#endif
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
unvis(char *, int, int *, int);
#endif
@@ -789,19 +871,19 @@ unvis(char *, int, int *, int);
#ifndef HAVE_VIS
#define vis rk_vis
#endif
char * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
vis(char *, int, int, int);
#endif
#if !defined(HAVE_CLOSEFROM)
#define closefrom rk_closefrom
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
closefrom(int);
#endif
#if !defined(HAVE_TIMEGM)
#define timegm rk_timegm
time_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL
rk_timegm(struct tm *tm);
#endif
+3 -3
View File
@@ -104,7 +104,7 @@ split_spec(const char *spec, char **host, int *port, char **path, int def_port)
}
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_gethostby_setup(const char *proxy_spec, const char *dns_spec)
{
char *proxy_host = NULL;
@@ -207,7 +207,7 @@ roken_gethostby(const char *hostname)
}
}
struct hostent*
ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyname(const char *hostname)
{
struct hostent *he;
@@ -217,7 +217,7 @@ roken_gethostbyname(const char *hostname)
return roken_gethostby(hostname);
}
struct hostent* ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyaddr(const void *addr, size_t len, int type)
{
struct in_addr a;

Some files were not shown because too many files have changed in this diff Show More