summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/roken
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/lib/roken')
-rw-r--r--source4/heimdal/lib/roken/dumpdata.c2
-rw-r--r--source4/heimdal/lib/roken/get_window_size.c73
-rw-r--r--source4/heimdal/lib/roken/getarg.c22
-rw-r--r--source4/heimdal/lib/roken/hex.c5
-rw-r--r--source4/heimdal/lib/roken/parse_units.c4
-rw-r--r--source4/heimdal/lib/roken/resolve.c12
-rw-r--r--source4/heimdal/lib/roken/rkpty.c6
-rw-r--r--source4/heimdal/lib/roken/roken.h.in19
-rw-r--r--source4/heimdal/lib/roken/roken_gethostby.c9
-rw-r--r--source4/heimdal/lib/roken/socket.c2
-rw-r--r--source4/heimdal/lib/roken/strsep_copy.c2
-rw-r--r--source4/heimdal/lib/roken/version-script.map4
12 files changed, 100 insertions, 60 deletions
diff --git a/source4/heimdal/lib/roken/dumpdata.c b/source4/heimdal/lib/roken/dumpdata.c
index f30f0e54cc..844360187f 100644
--- a/source4/heimdal/lib/roken/dumpdata.c
+++ b/source4/heimdal/lib/roken/dumpdata.c
@@ -81,7 +81,7 @@ rk_undumpdata(const char *filename, void **buf, size_t *size)
sret = net_read(fd, *buf, *size);
if (sret < 0)
ret = errno;
- else if (sret != *size) {
+ else if (sret != (ssize_t)*size) {
ret = EINVAL;
free(*buf);
*buf = NULL;
diff --git a/source4/heimdal/lib/roken/get_window_size.c b/source4/heimdal/lib/roken/get_window_size.c
index 13e7ebf157..5a4a1753fe 100644
--- a/source4/heimdal/lib/roken/get_window_size.c
+++ b/source4/heimdal/lib/roken/get_window_size.c
@@ -58,32 +58,46 @@
#include "roken.h"
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
-get_window_size(int fd, struct winsize *wp)
+get_window_size(int fd, int *lines, int *columns)
{
- int ret = -1;
-
- memset(wp, 0, sizeof(*wp));
+ char *s;
#if defined(TIOCGWINSZ)
- ret = ioctl(fd, TIOCGWINSZ, wp);
+ {
+ struct winsize ws;
+ int ret;
+ ret = ioctl(fd, TIOCGWINSZ, &ws);
+ if (ret != -1) {
+ if (lines)
+ *lines = ws.ws_row;
+ if (columns)
+ *columns = ws.ws_col;
+ return 0;
+ }
+ }
#elif defined(TIOCGSIZE)
{
struct ttysize ts;
-
+ int ret;
ret = ioctl(fd, TIOCGSIZE, &ts);
- if(ret == 0) {
- wp->ws_row = ts.ts_lines;
- wp->ws_col = ts.ts_cols;
- }
+ if (ret != -1) {
+ if (lines)
+ *lines = ts.ws_lines;
+ if (columns)
+ *columns = ts.ts_cols;
+ return 0;
+ }
}
#elif defined(HAVE__SCRSIZE)
{
int dst[2];
-
- _scrsize(dst);
- wp->ws_row = dst[1];
- wp->ws_col = dst[0];
- ret = 0;
+
+ _scrsize(dst);
+ if (lines)
+ *lines = dst[1];
+ if (columns)
+ *columns = dst[0];
+ return 0;
}
#elif defined(_WIN32)
{
@@ -93,21 +107,26 @@ get_window_size(int fd, struct winsize *wp)
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;
+ if (lines)
+ *lines = 1 + sb_info.srWindow.Bottom - sb_info.srWindow.Top;
+ if (columns)
+ *columns = 1 + sb_info.srWindow.Right - sb_info.srWindow.Left;
- ret = 0;
+ return 0;
}
}
#endif
- if (ret != 0) {
- char *s;
- if((s = getenv("COLUMNS")))
- wp->ws_col = atoi(s);
- if((s = getenv("LINES")))
- wp->ws_row = atoi(s);
- if(wp->ws_col > 0 && wp->ws_row > 0)
- ret = 0;
+ if (columns) {
+ if ((s = getenv("COLUMNS")))
+ *columns = atoi(s);
+ else
+ return -1;
+ }
+ if (lines) {
+ if ((s = getenv("LINES")))
+ *lines = atoi(s);
+ else
+ return -1;
}
- return ret;
+ return 0;
}
diff --git a/source4/heimdal/lib/roken/getarg.c b/source4/heimdal/lib/roken/getarg.c
index a96e5c85bf..d6a5048689 100644
--- a/source4/heimdal/lib/roken/getarg.c
+++ b/source4/heimdal/lib/roken/getarg.c
@@ -114,8 +114,7 @@ mandoc_template(struct getargs *args,
printf(".Os OPERATING_SYSTEM\n");
printf(".Sh NAME\n");
printf(".Nm %s\n", p);
- printf(".Nd\n");
- printf("in search of a description\n");
+ printf(".Nd in search of a description\n");
printf(".Sh SYNOPSIS\n");
printf(".Nm\n");
for(i = 0; i < num_args; i++){
@@ -133,7 +132,7 @@ mandoc_template(struct getargs *args,
}
if(args[i].long_name) {
print_arg(buf, sizeof(buf), 1, 1, args + i, i18n);
- printf("Fl -%s%s%s",
+ printf("Fl Fl %s%s%s",
args[i].type == arg_negative_flag ? "no-" : "",
args[i].long_name, buf);
}
@@ -142,7 +141,7 @@ mandoc_template(struct getargs *args,
print_arg(buf, sizeof(buf), 1, 0, args + i, i18n);
printf(".Oo Fl %c%s \\*(Ba Xo\n", args[i].short_name, buf);
print_arg(buf, sizeof(buf), 1, 1, args + i, i18n);
- printf(".Fl -%s%s\n.Xc\n.Oc\n", args[i].long_name, buf);
+ printf(".Fl Fl %s%s\n.Xc\n.Oc\n", args[i].long_name, buf);
}
/*
if(args[i].type == arg_strings)
@@ -165,7 +164,7 @@ mandoc_template(struct getargs *args,
printf("\n");
}
if(args[i].long_name){
- printf(".Fl -%s%s",
+ printf(".Fl Fl %s%s",
args[i].type == arg_negative_flag ? "no-" : "",
args[i].long_name);
print_arg(buf, sizeof(buf), 1, 1, args + i, i18n);
@@ -228,7 +227,6 @@ arg_printusage_i18n (struct getargs *args,
size_t i, max_len = 0;
char buf[128];
int col = 0, columns;
- struct winsize ws;
if (progname == NULL)
progname = getprogname();
@@ -240,9 +238,7 @@ arg_printusage_i18n (struct getargs *args,
mandoc_template(args, num_args, progname, extra_string, i18n);
return;
}
- if(get_window_size(2, &ws) == 0)
- columns = ws.ws_col;
- else
+ if(get_window_size(2, NULL, &columns) == -1)
columns = 80;
col = 0;
col += fprintf (stderr, "%s: %s", usage, progname);
@@ -352,7 +348,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;
@@ -477,7 +473,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++) {
@@ -500,9 +496,11 @@ arg_match_short (struct getargs *args, size_t num_args,
}
if(args[k].type == arg_collect) {
struct getarg_collect_info *c = args[k].value;
+ int a = (int)j;
- if((*c->func)(TRUE, argc, rargv, goptind, &j, c->data))
+ if((*c->func)(TRUE, argc, rargv, goptind, &a, c->data))
return ARG_ERR_BAD_ARG;
+ j = a;
break;
}
diff --git a/source4/heimdal/lib/roken/hex.c b/source4/heimdal/lib/roken/hex.c
index 91590dd49d..c66b324f79 100644
--- a/source4/heimdal/lib/roken/hex.c
+++ b/source4/heimdal/lib/roken/hex.c
@@ -37,7 +37,7 @@
#include <ctype.h>
#include "hex.h"
-const static char hexchar[] = "0123456789ABCDEF";
+static const char hexchar[16] = "0123456789ABCDEF";
static int
pos(char c)
@@ -86,14 +86,13 @@ hex_decode(const char *str, void *data, size_t len)
size_t l;
unsigned char *p = data;
size_t i;
-
+
l = strlen(str);
/* check for overflow, same as (l+1)/2 but overflow safe */
if ((l/2) + (l&1) > len)
return -1;
- i = 0;
if (l & 1) {
p[0] = pos(str[0]);
str++;
diff --git a/source4/heimdal/lib/roken/parse_units.c b/source4/heimdal/lib/roken/parse_units.c
index d2857cfa07..8b3cdf40e5 100644
--- a/source4/heimdal/lib/roken/parse_units.c
+++ b/source4/heimdal/lib/roken/parse_units.c
@@ -267,7 +267,7 @@ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
print_units_table (const struct units *units, FILE *f)
{
const struct units *u, *u2;
- int max_sz = 0;
+ size_t max_sz = 0;
for (u = units; u->name; ++u) {
max_sz = max(max_sz, strlen(u->name));
@@ -288,7 +288,7 @@ print_units_table (const struct units *units, FILE *f)
if (u2->name == NULL)
--u2;
unparse_units (u->mult, u2, buf, sizeof(buf));
- fprintf (f, "1 %*s = %s\n", max_sz, u->name, buf);
+ fprintf (f, "1 %*s = %s\n", (int)max_sz, u->name, buf);
} else {
fprintf (f, "1 %s\n", u->name);
}
diff --git a/source4/heimdal/lib/roken/resolve.c b/source4/heimdal/lib/roken/resolve.c
index 03715e5ffd..b27f37a6d6 100644
--- a/source4/heimdal/lib/roken/resolve.c
+++ b/source4/heimdal/lib/roken/resolve.c
@@ -194,7 +194,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
dns_free_rr(rr);
return -1;
}
- if (status + 2 > size) {
+ if ((size_t)status + 2 > size) {
dns_free_rr(rr);
return -1;
}
@@ -217,7 +217,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
dns_free_rr(rr);
return -1;
}
- if (status + 6 > size) {
+ if ((size_t)status + 6 > size) {
dns_free_rr(rr);
return -1;
}
@@ -237,7 +237,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
break;
}
case rk_ns_t_txt:{
- if(size == 0 || size < *p + 1) {
+ if(size == 0 || size < (unsigned)(*p + 1)) {
dns_free_rr(rr);
return -1;
}
@@ -284,7 +284,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
dns_free_rr(rr);
return -1;
}
- if (status + 18 > size) {
+ if ((size_t)status + 18 > size) {
dns_free_rr(rr);
return -1;
}
@@ -409,7 +409,7 @@ parse_reply(const unsigned char *data, size_t len)
{
const unsigned char *p;
int status;
- int i;
+ size_t i;
char host[MAXDNAME];
const unsigned char *end_data = data + len;
struct rk_dns_reply *r;
@@ -528,7 +528,7 @@ dns_lookup_int(const char *domain, int rr_class, int rr_type)
struct sockaddr_storage from;
uint32_t fromsize = sizeof(from);
dns_handle_t handle;
-
+
handle = dns_open(NULL);
if (handle == NULL)
return NULL;
diff --git a/source4/heimdal/lib/roken/rkpty.c b/source4/heimdal/lib/roken/rkpty.c
index 0faf668615..f2c62f23f3 100644
--- a/source4/heimdal/lib/roken/rkpty.c
+++ b/source4/heimdal/lib/roken/rkpty.c
@@ -107,9 +107,9 @@ open_pty(void)
{
char *clone[] = {
"/dev/ptc",
- "/dev/ptmx",
+ "/dev/ptmx",
"/dev/ptm",
- "/dev/ptym/clone",
+ "/dev/ptym/clone",
NULL
};
char **q;
@@ -372,7 +372,7 @@ main(int argc, char **argv)
sa.sa_handler = caught_signal;
sa.sa_flags = 0;
sigemptyset (&sa.sa_mask);
-
+
sigaction(SIGALRM, &sa, NULL);
}
diff --git a/source4/heimdal/lib/roken/roken.h.in b/source4/heimdal/lib/roken/roken.h.in
index 1ca3c10dc9..a6299aee8e 100644
--- a/source4/heimdal/lib/roken/roken.h.in
+++ b/source4/heimdal/lib/roken/roken.h.in
@@ -105,6 +105,10 @@ typedef int rk_socket_t;
#endif
+#ifndef IN_LOOPBACKNET
+#define IN_LOOPBACKNET 127
+#endif
+
#ifdef _MSC_VER
/* Declarations for Microsoft Visual C runtime on Windows */
@@ -759,7 +763,7 @@ struct winsize {
};
#endif
-ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, struct winsize *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, int *, int *);
#ifndef HAVE_VSYSLOG
#define vsyslog rk_vsyslog
@@ -932,6 +936,7 @@ strptime (const char *, const char *, struct tm *);
#endif
#ifndef HAVE_GETTIMEOFDAY
+#define gettimeofday rk_gettimeofday
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
gettimeofday (struct timeval *, void *);
#endif
@@ -1098,6 +1103,18 @@ rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
#define rk_random() rand()
#endif
+#ifndef HAVE_TDELETE
+#define tdelete(a,b,c) rk_tdelete(a,b,c)
+#endif
+#ifndef HAVE_TFIND
+#define tfind(a,b,c) rk_tfind(a,b,c)
+#endif
+#ifndef HAVE_TSEARCH
+#define tsearch(a,b,c) rk_tsearch(a,b,c)
+#endif
+#ifndef HAVE_TWALK
+#define twalk(a,b) rk_twalk(a,b)
+#endif
#if defined(__linux__) && defined(SOCK_CLOEXEC) && !defined(SOCKET_WRAPPER_REPLACE) && !defined(__SOCKET_WRAPPER_H__)
#undef socket
diff --git a/source4/heimdal/lib/roken/roken_gethostby.c b/source4/heimdal/lib/roken/roken_gethostby.c
index 1d6c8ffe8a..1bb560d3ba 100644
--- a/source4/heimdal/lib/roken/roken_gethostby.c
+++ b/source4/heimdal/lib/roken/roken_gethostby.c
@@ -142,6 +142,7 @@ roken_gethostby(const char *hostname)
int offset = 0;
int n;
char *p, *foo;
+ size_t len;
if(dns_addr.sin_family == 0)
return NULL; /* no configured host */
@@ -160,7 +161,9 @@ roken_gethostby(const char *hostname)
free(request);
return NULL;
}
- if(write(s, request, strlen(request)) != strlen(request)) {
+
+ len = strlen(request);
+ if(write(s, request, len) != (ssize_t)len) {
close(s);
free(request);
return NULL;
@@ -188,12 +191,12 @@ roken_gethostby(const char *hostname)
static char addrs[4 * MAX_ADDRS];
static char *addr_list[MAX_ADDRS + 1];
int num_addrs = 0;
-
+
he.h_name = p;
he.h_aliases = NULL;
he.h_addrtype = AF_INET;
he.h_length = 4;
-
+
while((p = strtok_r(NULL, " \t\r\n", &foo)) && num_addrs < MAX_ADDRS) {
struct in_addr ip;
inet_aton(p, &ip);
diff --git a/source4/heimdal/lib/roken/socket.c b/source4/heimdal/lib/roken/socket.c
index 8797f95772..017d6252ea 100644
--- a/source4/heimdal/lib/roken/socket.c
+++ b/source4/heimdal/lib/roken/socket.c
@@ -233,7 +233,7 @@ socket_set_portrange (rk_socket_t sock, int restr, int af)
}
#endif
}
-
+
/*
* Enable debug on `sock'.
*/
diff --git a/source4/heimdal/lib/roken/strsep_copy.c b/source4/heimdal/lib/roken/strsep_copy.c
index 9624b5a46f..1228f1a450 100644
--- a/source4/heimdal/lib/roken/strsep_copy.c
+++ b/source4/heimdal/lib/roken/strsep_copy.c
@@ -49,7 +49,7 @@ strsep_copy(const char **stringp, const char *delim, char *buf, size_t len)
if(save == NULL)
return -1;
*stringp = *stringp + strcspn(*stringp, delim);
- l = min(len, *stringp - save);
+ l = min(len, (size_t)(*stringp - save));
if(len > 0) {
memcpy(buf, save, l);
buf[l] = '\0';
diff --git a/source4/heimdal/lib/roken/version-script.map b/source4/heimdal/lib/roken/version-script.map
index 1baa4b182a..9229a373cd 100644
--- a/source4/heimdal/lib/roken/version-script.map
+++ b/source4/heimdal/lib/roken/version-script.map
@@ -139,6 +139,10 @@ HEIMDAL_ROKEN_1.0 {
rk_timevaladd;
rk_timevalfix;
rk_timevalsub;
+ rk_tdelete;
+ rk_tfind;
+ rk_tsearch;
+ rk_twalk;
rk_undumpdata;
rk_unvis;
rk_vasnprintf;