summaryrefslogtreecommitdiffstats
path: root/src/appl/gss-sample/gss-misc.c
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2005-10-21 01:32:57 +0000
committerKen Raeburn <raeburn@mit.edu>2005-10-21 01:32:57 +0000
commit6158f7243127ce89552f18549d7b9ef9ebeeeab3 (patch)
tree9822f904b7509980aa3fa14241d722d502c64d7d /src/appl/gss-sample/gss-misc.c
parent5be1b244f3ced76421957a8cc955ab78d791f600 (diff)
downloadkrb5-6158f7243127ce89552f18549d7b9ef9ebeeeab3.tar.gz
krb5-6158f7243127ce89552f18549d7b9ef9ebeeeab3.tar.xz
krb5-6158f7243127ce89552f18549d7b9ef9ebeeeab3.zip
reindent to style in doc/coding-style, via gnu indent
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17447 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/appl/gss-sample/gss-misc.c')
-rw-r--r--src/appl/gss-sample/gss-misc.c388
1 files changed, 195 insertions, 193 deletions
diff --git a/src/appl/gss-sample/gss-misc.c b/src/appl/gss-sample/gss-misc.c
index c912792e09..fe578d1ab8 100644
--- a/src/appl/gss-sample/gss-misc.c
+++ b/src/appl/gss-sample/gss-misc.c
@@ -78,38 +78,39 @@ static char *rcsid = "$Header$";
extern char *malloc();
#endif
-FILE *display_file;
+FILE *display_file;
gss_buffer_desc empty_token_buf = { 0, (void *) "" };
gss_buffer_t empty_token = &empty_token_buf;
-static void display_status_1
- (char *m, OM_uint32 code, int type);
+static void display_status_1(char *m, OM_uint32 code, int type);
-static int write_all(int fildes, char *buf, unsigned int nbyte)
+static int
+write_all(int fildes, char *buf, unsigned int nbyte)
{
- int ret;
- char *ptr;
-
- for (ptr = buf; nbyte; ptr += ret, nbyte -= ret) {
- ret = send(fildes, ptr, nbyte, 0);
- if (ret < 0) {
- if (errno == EINTR)
- continue;
- return(ret);
- } else if (ret == 0) {
- return(ptr-buf);
- }
- }
-
- return(ptr-buf);
+ int ret;
+ char *ptr;
+
+ for (ptr = buf; nbyte; ptr += ret, nbyte -= ret) {
+ ret = send(fildes, ptr, nbyte, 0);
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ return (ret);
+ } else if (ret == 0) {
+ return (ptr - buf);
+ }
+ }
+
+ return (ptr - buf);
}
-static int read_all(int fildes, char *buf, unsigned int nbyte)
+static int
+read_all(int fildes, char *buf, unsigned int nbyte)
{
- int ret;
- char *ptr;
- fd_set rfds;
+ int ret;
+ char *ptr;
+ fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
@@ -120,18 +121,18 @@ static int read_all(int fildes, char *buf, unsigned int nbyte)
for (ptr = buf; nbyte; ptr += ret, nbyte -= ret) {
if (select(FD_SETSIZE, &rfds, NULL, NULL, &tv) <= 0
|| !FD_ISSET(fildes, &rfds))
- return(ptr-buf);
+ return (ptr - buf);
ret = recv(fildes, ptr, nbyte, 0);
if (ret < 0) {
if (errno == EINTR)
continue;
- return(ret);
+ return (ret);
} else if (ret == 0) {
- return(ptr-buf);
+ return (ptr - buf);
}
}
- return(ptr-buf);
+ return (ptr - buf);
}
/*
@@ -155,54 +156,54 @@ static int read_all(int fildes, char *buf, unsigned int nbyte)
* written to the file descriptor s. It returns 0 on success, and -1
* if an error occurs or if it could not write all the data.
*/
-int send_token(s, flags, tok)
- int s;
- int flags;
- gss_buffer_t tok;
+int
+send_token(s, flags, tok)
+ int s;
+ int flags;
+ gss_buffer_t tok;
{
- int ret;
- unsigned char char_flags = (unsigned char) flags;
- unsigned char lenbuf[4];
-
- if (char_flags) {
- ret = write_all(s, (char *)&char_flags, 1);
- if (ret != 1) {
- perror("sending token flags");
- return -1;
- }
- }
- if (tok->length > 0xffffffffUL)
- abort();
- lenbuf[0] = (tok->length >> 24) & 0xff;
- lenbuf[1] = (tok->length >> 16) & 0xff;
- lenbuf[2] = (tok->length >> 8) & 0xff;
- lenbuf[3] = tok->length & 0xff;
-
- ret = write_all(s, lenbuf, 4);
- if (ret < 0) {
- perror("sending token length");
- return -1;
- } else if (ret != 4) {
- if (display_file)
- fprintf(display_file,
- "sending token length: %d of %d bytes written\n",
- ret, 4);
- return -1;
- }
-
- ret = write_all(s, tok->value, tok->length);
- if (ret < 0) {
- perror("sending token data");
- return -1;
- } else if (ret != tok->length) {
- if (display_file)
- fprintf(display_file,
- "sending token data: %d of %d bytes written\n",
- ret, (int) tok->length);
- return -1;
- }
-
- return 0;
+ int ret;
+ unsigned char char_flags = (unsigned char) flags;
+ unsigned char lenbuf[4];
+
+ if (char_flags) {
+ ret = write_all(s, (char *) &char_flags, 1);
+ if (ret != 1) {
+ perror("sending token flags");
+ return -1;
+ }
+ }
+ if (tok->length > 0xffffffffUL)
+ abort();
+ lenbuf[0] = (tok->length >> 24) & 0xff;
+ lenbuf[1] = (tok->length >> 16) & 0xff;
+ lenbuf[2] = (tok->length >> 8) & 0xff;
+ lenbuf[3] = tok->length & 0xff;
+
+ ret = write_all(s, lenbuf, 4);
+ if (ret < 0) {
+ perror("sending token length");
+ return -1;
+ } else if (ret != 4) {
+ if (display_file)
+ fprintf(display_file,
+ "sending token length: %d of %d bytes written\n", ret, 4);
+ return -1;
+ }
+
+ ret = write_all(s, tok->value, tok->length);
+ if (ret < 0) {
+ perror("sending token data");
+ return -1;
+ } else if (ret != tok->length) {
+ if (display_file)
+ fprintf(display_file,
+ "sending token data: %d of %d bytes written\n",
+ ret, (int) tok->length);
+ return -1;
+ }
+
+ return 0;
}
/*
@@ -228,104 +229,101 @@ int send_token(s, flags, tok)
* should be freed with gss_release_buffer. It returns 0 on success,
* and -1 if an error occurs or if it could not read all the data.
*/
-int recv_token(s, flags, tok)
- int s;
- int *flags;
- gss_buffer_t tok;
+int
+recv_token(s, flags, tok)
+ int s;
+ int *flags;
+ gss_buffer_t tok;
{
- int ret;
- unsigned char char_flags;
- unsigned char lenbuf[4];
-
- ret = read_all(s, (char *) &char_flags, 1);
- if (ret < 0) {
- perror("reading token flags");
- return -1;
- } else if (! ret) {
- if (display_file)
- fputs("reading token flags: 0 bytes read\n", display_file);
- return -1;
- } else {
- *flags = (int) char_flags;
- }
-
- if (char_flags == 0 ) {
- lenbuf[0] = 0;
- ret = read_all(s, &lenbuf[1], 3);
- if (ret < 0) {
- perror("reading token length");
- return -1;
- } else if (ret != 3) {
- if (display_file)
- fprintf(display_file,
- "reading token length: %d of %d bytes read\n",
- ret, 3);
- return -1;
- }
- }
- else {
- ret = read_all(s, lenbuf, 4);
- if (ret < 0) {
- perror("reading token length");
- return -1;
- } else if (ret != 4) {
- if (display_file)
- fprintf(display_file,
- "reading token length: %d of %d bytes read\n",
- ret, 4);
- return -1;
- }
- }
-
- tok->length = ((lenbuf[0] << 24)
- | (lenbuf[1] << 16)
- | (lenbuf[2] << 8)
- | lenbuf[3]);
- tok->value = (char *) malloc(tok->length ? tok->length : 1);
- if (tok->length && tok->value == NULL) {
- if (display_file)
- fprintf(display_file,
- "Out of memory allocating token data\n");
- return -1;
- }
-
- ret = read_all(s, (char *) tok->value, tok->length);
- if (ret < 0) {
- perror("reading token data");
- free(tok->value);
- return -1;
- } else if (ret != tok->length) {
- fprintf(stderr, "sending token data: %d of %d bytes written\n",
- ret, (int) tok->length);
- free(tok->value);
- return -1;
- }
-
- return 0;
+ int ret;
+ unsigned char char_flags;
+ unsigned char lenbuf[4];
+
+ ret = read_all(s, (char *) &char_flags, 1);
+ if (ret < 0) {
+ perror("reading token flags");
+ return -1;
+ } else if (!ret) {
+ if (display_file)
+ fputs("reading token flags: 0 bytes read\n", display_file);
+ return -1;
+ } else {
+ *flags = (int) char_flags;
+ }
+
+ if (char_flags == 0) {
+ lenbuf[0] = 0;
+ ret = read_all(s, &lenbuf[1], 3);
+ if (ret < 0) {
+ perror("reading token length");
+ return -1;
+ } else if (ret != 3) {
+ if (display_file)
+ fprintf(display_file,
+ "reading token length: %d of %d bytes read\n", ret, 3);
+ return -1;
+ }
+ } else {
+ ret = read_all(s, lenbuf, 4);
+ if (ret < 0) {
+ perror("reading token length");
+ return -1;
+ } else if (ret != 4) {
+ if (display_file)
+ fprintf(display_file,
+ "reading token length: %d of %d bytes read\n", ret, 4);
+ return -1;
+ }
+ }
+
+ tok->length = ((lenbuf[0] << 24)
+ | (lenbuf[1] << 16)
+ | (lenbuf[2] << 8)
+ | lenbuf[3]);
+ tok->value = (char *) malloc(tok->length ? tok->length : 1);
+ if (tok->length && tok->value == NULL) {
+ if (display_file)
+ fprintf(display_file, "Out of memory allocating token data\n");
+ return -1;
+ }
+
+ ret = read_all(s, (char *) tok->value, tok->length);
+ if (ret < 0) {
+ perror("reading token data");
+ free(tok->value);
+ return -1;
+ } else if (ret != tok->length) {
+ fprintf(stderr, "sending token data: %d of %d bytes written\n",
+ ret, (int) tok->length);
+ free(tok->value);
+ return -1;
+ }
+
+ return 0;
}
-static void display_status_1(m, code, type)
- char *m;
- OM_uint32 code;
- int type;
+static void
+display_status_1(m, code, type)
+ char *m;
+ OM_uint32 code;
+ int type;
{
- OM_uint32 maj_stat, min_stat;
- gss_buffer_desc msg;
- OM_uint32 msg_ctx;
-
- msg_ctx = 0;
- while (1) {
- maj_stat = gss_display_status(&min_stat, code,
- type, GSS_C_NULL_OID,
- &msg_ctx, &msg);
- if (display_file)
- fprintf(display_file, "GSS-API error %s: %s\n", m,
- (char *)msg.value);
- (void) gss_release_buffer(&min_stat, &msg);
-
- if (!msg_ctx)
- break;
- }
+ OM_uint32 maj_stat, min_stat;
+ gss_buffer_desc msg;
+ OM_uint32 msg_ctx;
+
+ msg_ctx = 0;
+ while (1) {
+ maj_stat = gss_display_status(&min_stat, code,
+ type, GSS_C_NULL_OID, &msg_ctx, &msg);
+ if (display_file)
+ fprintf(display_file, "GSS-API error %s: %s\n", m,
+ (char *) msg.value);
+ (void) gss_release_buffer(&min_stat, &msg);
+
+ if (!msg_ctx)
+ break;
+ }
}
/*
@@ -345,13 +343,14 @@ static void display_status_1(m, code, type)
* displayed on stderr, each preceeded by "GSS-API error <msg>: " and
* followed by a newline.
*/
-void display_status(msg, maj_stat, min_stat)
- char *msg;
- OM_uint32 maj_stat;
- OM_uint32 min_stat;
+void
+display_status(msg, maj_stat, min_stat)
+ char *msg;
+ OM_uint32 maj_stat;
+ OM_uint32 min_stat;
{
- display_status_1(msg, maj_stat, GSS_C_GSS_CODE);
- display_status_1(msg, min_stat, GSS_C_MECH_CODE);
+ display_status_1(msg, maj_stat, GSS_C_GSS_CODE);
+ display_status_1(msg, min_stat, GSS_C_MECH_CODE);
}
/*
@@ -370,32 +369,34 @@ void display_status(msg, maj_stat, min_stat)
* stdout, preceded by "context flag: " and followed by a newline
*/
-void display_ctx_flags(flags)
- OM_uint32 flags;
+void
+display_ctx_flags(flags)
+ OM_uint32 flags;
{
- if (flags & GSS_C_DELEG_FLAG)
- fprintf(display_file, "context flag: GSS_C_DELEG_FLAG\n");
- if (flags & GSS_C_MUTUAL_FLAG)
- fprintf(display_file, "context flag: GSS_C_MUTUAL_FLAG\n");
- if (flags & GSS_C_REPLAY_FLAG)
- fprintf(display_file, "context flag: GSS_C_REPLAY_FLAG\n");
- if (flags & GSS_C_SEQUENCE_FLAG)
- fprintf(display_file, "context flag: GSS_C_SEQUENCE_FLAG\n");
- if (flags & GSS_C_CONF_FLAG )
- fprintf(display_file, "context flag: GSS_C_CONF_FLAG \n");
- if (flags & GSS_C_INTEG_FLAG )
- fprintf(display_file, "context flag: GSS_C_INTEG_FLAG \n");
+ if (flags & GSS_C_DELEG_FLAG)
+ fprintf(display_file, "context flag: GSS_C_DELEG_FLAG\n");
+ if (flags & GSS_C_MUTUAL_FLAG)
+ fprintf(display_file, "context flag: GSS_C_MUTUAL_FLAG\n");
+ if (flags & GSS_C_REPLAY_FLAG)
+ fprintf(display_file, "context flag: GSS_C_REPLAY_FLAG\n");
+ if (flags & GSS_C_SEQUENCE_FLAG)
+ fprintf(display_file, "context flag: GSS_C_SEQUENCE_FLAG\n");
+ if (flags & GSS_C_CONF_FLAG)
+ fprintf(display_file, "context flag: GSS_C_CONF_FLAG \n");
+ if (flags & GSS_C_INTEG_FLAG)
+ fprintf(display_file, "context flag: GSS_C_INTEG_FLAG \n");
}
-void print_token(tok)
- gss_buffer_t tok;
+void
+print_token(tok)
+ gss_buffer_t tok;
{
- int i;
+ int i;
unsigned char *p = tok->value;
if (!display_file)
return;
- for (i=0; i < tok->length; i++, p++) {
+ for (i = 0; i < tok->length; i++, p++) {
fprintf(display_file, "%02x ", *p);
if ((i % 16) == 15) {
fprintf(display_file, "\n");
@@ -409,7 +410,8 @@ void print_token(tok)
#include <sys\timeb.h>
#include <time.h>
-int gettimeofday (struct timeval *tv, void *ignore_tz)
+int
+gettimeofday(struct timeval *tv, void *ignore_tz)
{
struct _timeb tb;
_tzset();