+Wed Mar 1 12:03:30 1995 Keith Vetter (keithv@fusion.com)
+
+ * *.c, *.h Added windows INTERFACE keyword
+ * Makefile.in: made to work on the PC.
+ * rc_dfl.c: Some int/long changes for the PC
+ * rc_io.c: hack to get Microsoft C in std-c mode to allow
+ low-level i/o routines. Probably not a permanent solution
+ but keep until we decide on a better method.
+ * rc_io.h: added 2 missing prototypes
+ * rc_dfl.h: added 2 missing prototypes
+
Tue Feb 28 01:03:34 1995 John Gilmore (gnu at toad.com)
* *.c: Avoid <krb5/...> includes.
CFLAGS = $(CCOPTS) $(DEFS)
LDFLAGS = -g
-all:: $(OBJS)
+##DOSBUILDTOP = ..\..\..
+##DOSLIBNAME=..\libkrb5.lib
+##DOS!include $(BUILDTOP)\config\windows.in
OBJS= \
- rc_base.o \
- rc_dfl.o \
- rc_io.o \
- rcdef.o \
- rc_conv.o
+ rc_base.$(OBJEXT) \
+ rc_dfl.$(OBJEXT) \
+ rc_io.$(OBJEXT) \
+ rcdef.$(OBJEXT) \
+ rc_conv.$(OBJEXT)
SRCS= \
$(srcdir)/rc_base.c \
$(srcdir)/rc_io.c \
$(srcdir)/rcdef.c \
$(srcdir)/rc_conv.c
+
+all:: $(OBJS)
semaphore ex_typelist = 1;
#endif
-krb5_error_code krb5_rc_register_type(context, ops)
+krb5_error_code INTERFACE krb5_rc_register_type(context, ops)
krb5_context context;
krb5_rc_ops *ops;
{
return 0;
}
-krb5_error_code krb5_rc_resolve_type(context, id, type)
+krb5_error_code INTERFACE krb5_rc_resolve_type(context, id, type)
krb5_context context;
krb5_rcache *id;
char *type;
return 0;
}
-char *krb5_rc_get_type(context, id)
+char * INTERFACE krb5_rc_get_type(context, id)
krb5_context context;
krb5_rcache id;
{
return id->ops->type;
}
-char *krb5_rc_default_type(context)
+char * INTERFACE krb5_rc_default_type(context)
krb5_context context;
{
char *s;
return "dfl";
}
-char *krb5_rc_default_name(context)
+char * INTERFACE krb5_rc_default_name(context)
krb5_context context;
{
char *s;
return (char *) 0;
}
-krb5_error_code
+krb5_error_code INTERFACE
krb5_rc_default(context, id)
krb5_context context;
krb5_rcache *id;
}
-krb5_error_code krb5_rc_resolve_full(context, id, string_name)
+krb5_error_code INTERFACE krb5_rc_resolve_full(context, id, string_name)
krb5_context context;
krb5_rcache *id;
char *string_name;
given auth, take important information and make rep; return -1 if failed
*/
-krb5_error_code
+krb5_error_code INTERFACE
krb5_auth_to_rep(context, auth, rep)
krb5_context context;
krb5_tkt_authent *auth;
#include "rc_base.h"
#include "rc_dfl.h"
#include "rc_io.h"
+#include <k5-int.h>
/*
If NOIOSTUFF is defined at compile time, dfl rcaches will be per-process.
krb5_donot_replay *rep;
int hsize;
{
- return (((rep->cusec + rep->ctime + *rep->server + *rep->client)
- % hsize) + hsize) % hsize;
+ return (int) ((((rep->cusec + rep->ctime + *rep->server + *rep->client)
+ % hsize) + hsize) % hsize);
/* We take this opportunity to once again complain about C's idiotic %. */
}
return CMP_HOHUM;
}
-char *krb5_rc_dfl_get_name(context, id)
+char * INTERFACE krb5_rc_dfl_get_name(context, id)
krb5_context context;
krb5_rcache id;
{
return ((struct dfl_data *) (id->data))->name;
}
-krb5_error_code krb5_rc_dfl_get_span(context, id, lifespan)
+krb5_error_code INTERFACE krb5_rc_dfl_get_span(context, id, lifespan)
krb5_context context;
krb5_rcache id;
krb5_deltat *lifespan;
return 0;
}
-krb5_error_code krb5_rc_dfl_init(context, id, lifespan)
+krb5_error_code INTERFACE krb5_rc_dfl_init(context, id, lifespan)
krb5_context context;
krb5_rcache id;
krb5_deltat lifespan;
return 0;
}
-krb5_error_code krb5_rc_dfl_close_no_free(context, id)
+krb5_error_code INTERFACE krb5_rc_dfl_close_no_free(context, id)
krb5_context context;
krb5_rcache id;
{
return 0;
}
-krb5_error_code krb5_rc_dfl_close(context, id)
+krb5_error_code INTERFACE krb5_rc_dfl_close(context, id)
krb5_context context;
krb5_rcache id;
{
return 0;
}
-krb5_error_code krb5_rc_dfl_destroy(context, id)
+krb5_error_code INTERFACE krb5_rc_dfl_destroy(context, id)
krb5_context context;
krb5_rcache id;
{
return krb5_rc_dfl_close(context, id);
}
-krb5_error_code krb5_rc_dfl_resolve(context, id, name)
+krb5_error_code INTERFACE krb5_rc_dfl_resolve(context, id, name)
krb5_context context;
krb5_rcache id;
char *name;
return retval;
}
-void krb5_rc_free_entry (context, rep)
+void INTERFACE krb5_rc_free_entry (context, rep)
krb5_context context;
krb5_donot_replay **rep;
{
}
}
-krb5_error_code krb5_rc_io_fetch(context, t, rep, maxlen)
+static krb5_error_code krb5_rc_io_fetch(context, t, rep, maxlen)
krb5_context context;
struct dfl_data *t;
krb5_donot_replay *rep;
-krb5_error_code krb5_rc_dfl_recover(context, id)
+krb5_error_code INTERFACE krb5_rc_dfl_recover(context, id)
krb5_context context;
krb5_rcache id;
{
struct dfl_data *t = (struct dfl_data *)id->data;
krb5_donot_replay *rep;
krb5_error_code retval;
- int max_size;
+ long max_size;
if (retval = krb5_rc_io_open(context, &t->d,t->name))
return retval;
rep->client = NULL;
rep->server = NULL;
- retval = krb5_rc_io_fetch (context, t, rep, max_size);
+ retval = krb5_rc_io_fetch (context, t, rep, (int) max_size);
if (retval == KRB5_RC_IO_EOF)
break;
#endif
}
-krb5_error_code krb5_rc_io_store (context, t, rep)
+static krb5_error_code
+krb5_rc_io_store (context, t, rep)
krb5_context context;
struct dfl_data *t;
krb5_donot_replay *rep;
return ret;
}
-krb5_error_code krb5_rc_dfl_store(context, id, rep)
+krb5_error_code INTERFACE krb5_rc_dfl_store(context, id, rep)
krb5_context context;
krb5_rcache id;
krb5_donot_replay *rep;
return 0;
}
-krb5_error_code krb5_rc_dfl_expunge(context, id)
+krb5_error_code INTERFACE krb5_rc_dfl_expunge(context, id)
krb5_context context;
krb5_rcache id;
{
extern krb5_rc_ops krb5_rc_dfl_ops; /* initialized to the following */
-krb5_error_code krb5_rc_dfl_init
+krb5_error_code INTERFACE krb5_rc_dfl_init
PROTOTYPE((krb5_context,
krb5_rcache,
krb5_deltat));
-krb5_error_code krb5_rc_dfl_recover
+krb5_error_code INTERFACE krb5_rc_dfl_recover
PROTOTYPE((krb5_context,
krb5_rcache));
-krb5_error_code krb5_rc_dfl_destroy
+krb5_error_code INTERFACE krb5_rc_dfl_destroy
PROTOTYPE((krb5_context,
krb5_rcache));
-krb5_error_code krb5_rc_dfl_close
+krb5_error_code INTERFACE krb5_rc_dfl_close
PROTOTYPE((krb5_context,
krb5_rcache));
-krb5_error_code krb5_rc_dfl_store
+krb5_error_code INTERFACE krb5_rc_dfl_store
PROTOTYPE((krb5_context,
krb5_rcache,
krb5_donot_replay *));
-krb5_error_code krb5_rc_dfl_expunge
+krb5_error_code INTERFACE krb5_rc_dfl_expunge
PROTOTYPE((krb5_context,
krb5_rcache));
-krb5_error_code krb5_rc_dfl_get_span
+krb5_error_code INTERFACE krb5_rc_dfl_get_span
PROTOTYPE((krb5_context,
krb5_rcache,
krb5_deltat *));
-char *krb5_rc_dfl_get_name
+char * INTERFACE krb5_rc_dfl_get_name
PROTOTYPE((krb5_context,
krb5_rcache));
-krb5_error_code krb5_rc_dfl_resolve
+krb5_error_code INTERFACE krb5_rc_dfl_resolve
PROTOTYPE((krb5_context,
krb5_rcache,
char *));
-
+krb5_error_code INTERFACE krb5_rc_dfl_close_no_free
+ PROTOTYPE((krb5_context,
+ krb5_rcache));
+void INTERFACE krb5_rc_free_entry
+ PROTOTYPE((krb5_context,
+ krb5_donot_replay **));
#endif
+
#define KRB5_RC_VNO 0x0501 /* krb5, rcache v 1 */
+#define NEED_WINSOCK_H
#include <stdio.h> /* for P_tmpdir */
-
+#include <krb5.h>
#include "rc_base.h"
#include "rc_dfl.h"
#include "rc_io.h"
+/* Ugly. Microsoft, in stdc mode, doesn't support the low-level i/o
+ * routines directly. Rather, they only export the _<function> version.
+ * The following defines works around this problem. Perhaps this should
+ * go into config.h but leave it here for now until we see how prevalent
+ * this problem is.
+ */
+#ifdef MSDOS_FILESYSTEM
+#include <fcntl.h>
+#include <io.h>
+#include <process.h>
+#define O_RDONLY _O_RDONLY
+#define O_WRONLY _O_WRONLY
+#define O_RDWR _O_RDWR
+#define O_APPEND _O_APPEND
+#define O_CREAT _O_CREAT
+#define O_TRUNC _O_TRUNC
+#define O_EXCL _O_EXCL
+#define O_TEXT _O_TEXT
+#define O_BINARY _O_BINARY
+#define O_NOINHERIT _O_NOINHERIT
+#define stat _stat
+#define getpid _getpid
+#define unlink _unlink
+#define lseek _lseek
+#define write _write
+#define open _open
+#define close _close
+#define read _read
+#define fstat _fstat
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#ifdef KRB5_USE_INET
+#ifndef _WINSOCKAPI_
#include <netinet/in.h>
+#endif
#else
#error find some way to use net-byte-order file version numbers.
#endif
+#ifndef HAVE_ERRNO
extern int errno; /* this should be in errno.h, but isn't on some systems */
+#endif
#define FREE(x) ((void) free((char *) (x)))
#define UNIQUE getpid() /* hopefully unique number */
}
}
-krb5_error_code krb5_rc_io_creat (context, d, fn)
+krb5_error_code INTERFACE krb5_rc_io_creat (context, d, fn)
krb5_context context;
krb5_rc_iostuff *d;
char **fn;
(void) strcpy(d->fn,dir);
(void) strcat(d->fn,"/");
(void) strcat(d->fn,*fn);
- d->fd = open(d->fn,O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,0600);
+ d->fd = open(d->fn,O_WRONLY | O_CREAT | O_TRUNC | O_EXCL | O_BINARY,0600);
}
else
{
(void) sprintf(d->fn,"%s/krb5_RC%d",dir,UNIQUE);
c = d->fn + strlen(d->fn);
(void) strcpy(c,"aaa");
- while ((d->fd = open(d->fn,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600)) == -1)
+ while ((d->fd = open(d->fn,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY,0600)) == -1)
{
if ((c[2]++) == 'z')
{
return 0;
}
-krb5_error_code krb5_rc_io_open (context, d, fn)
+krb5_error_code INTERFACE krb5_rc_io_open (context, d, fn)
krb5_context context;
krb5_rc_iostuff *d;
char *fn;
{
krb5_int16 rc_vno;
krb5_error_code retval;
+#ifndef NO_USERID
struct stat statb;
+#endif
GETDIR;
if (!(d->fn = malloc(strlen(fn) + dirlen + 1)))
(void) strcpy(d->fn,dir);
(void) strcat(d->fn,"/");
(void) strcat(d->fn,fn);
+
+#ifdef NO_USERID
+ d->fd = open(d->fn,O_RDWR | O_BINARY,0600);
+#else
if ((d->fd = stat(d->fn, &statb)) != -1) {
uid_t me;
FREE(d->fn);
return KRB5_RC_IO_PERM;
}
- d->fd = open(d->fn,O_RDWR,0600);
+ d->fd = open(d->fn,O_RDWR | O_BINARY,0600);
}
+#endif
if (d->fd == -1) {
switch(errno)
{
return 0;
}
-krb5_error_code krb5_rc_io_move (context, new, old)
+krb5_error_code INTERFACE krb5_rc_io_move (context, new, old)
krb5_context context;
krb5_rc_iostuff *new;
krb5_rc_iostuff *old;
return 0;
}
-krb5_error_code krb5_rc_io_write (context, d, buf, num)
+krb5_error_code INTERFACE krb5_rc_io_write (context, d, buf, num)
krb5_context context;
krb5_rc_iostuff *d;
krb5_pointer buf;
return 0;
}
-krb5_error_code krb5_rc_io_sync (context, d)
+krb5_error_code INTERFACE krb5_rc_io_sync (context, d)
krb5_context context;
krb5_rc_iostuff *d;
{
+#ifndef MSDOS_FILESYSTEM
if (fsync(d->fd) == -1) {
switch(errno)
{
default: return KRB5_RC_IO_UNKNOWN;
}
}
+#endif
return 0;
}
-krb5_error_code krb5_rc_io_read (context, d, buf, num)
+krb5_error_code INTERFACE krb5_rc_io_read (context, d, buf, num)
krb5_context context;
krb5_rc_iostuff *d;
krb5_pointer buf;
return 0;
}
-krb5_error_code krb5_rc_io_close (context, d)
+krb5_error_code INTERFACE krb5_rc_io_close (context, d)
krb5_context context;
krb5_rc_iostuff *d;
{
return 0;
}
-krb5_error_code krb5_rc_io_destroy (context, d)
+krb5_error_code INTERFACE krb5_rc_io_destroy (context, d)
krb5_context context;
krb5_rc_iostuff *d;
{
return 0;
}
-krb5_error_code krb5_rc_io_mark (context, d)
+krb5_error_code INTERFACE krb5_rc_io_mark (context, d)
krb5_context context;
krb5_rc_iostuff *d;
{
return 0;
}
-krb5_error_code krb5_rc_io_unmark (context, d)
+krb5_error_code INTERFACE krb5_rc_io_unmark (context, d)
krb5_context context;
krb5_rc_iostuff *d;
{
return 0;
}
-int krb5_rc_io_size (context, d)
+long INTERFACE
+krb5_rc_io_size (context, d)
+ krb5_context context;
krb5_rc_iostuff *d;
{
struct stat statb;
typedef struct krb5_rc_iostuff
{
int fd;
+#ifdef MSDOS_FILESYSTEM
+ long mark;
+#else
int mark; /* on newer systems, should be pos_t */
+#endif
char *fn;
}
krb5_rc_iostuff;
/* first argument is always iostuff for result file */
-krb5_error_code krb5_rc_io_creat
+krb5_error_code INTERFACE krb5_rc_io_creat
PROTOTYPE((krb5_context,
krb5_rc_iostuff *,
char **));
-krb5_error_code krb5_rc_io_open
+krb5_error_code INTERFACE krb5_rc_io_open
PROTOTYPE((krb5_context,
krb5_rc_iostuff *,
char *));
-krb5_error_code krb5_rc_io_move
+krb5_error_code INTERFACE krb5_rc_io_move
PROTOTYPE((krb5_context,
krb5_rc_iostuff *,
krb5_rc_iostuff *));
-krb5_error_code krb5_rc_io_write
+krb5_error_code INTERFACE krb5_rc_io_write
PROTOTYPE((krb5_context,
krb5_rc_iostuff *,
krb5_pointer,
int));
-krb5_error_code krb5_rc_io_read
+krb5_error_code INTERFACE krb5_rc_io_read
PROTOTYPE((krb5_context,
krb5_rc_iostuff *,
krb5_pointer,
int));
-krb5_error_code krb5_rc_io_close
+krb5_error_code INTERFACE krb5_rc_io_close
PROTOTYPE((krb5_context,
krb5_rc_iostuff *));
-krb5_error_code krb5_rc_io_destroy
+krb5_error_code INTERFACE krb5_rc_io_destroy
PROTOTYPE((krb5_context,
krb5_rc_iostuff *));
-krb5_error_code krb5_rc_io_mark
+krb5_error_code INTERFACE krb5_rc_io_mark
PROTOTYPE((krb5_context,
krb5_rc_iostuff *));
-krb5_error_code krb5_rc_io_unmark
+krb5_error_code INTERFACE krb5_rc_io_unmark
+ PROTOTYPE((krb5_context,
+ krb5_rc_iostuff *));
+krb5_error_code INTERFACE krb5_rc_io_sync
+ PROTOTYPE((krb5_context,
+ krb5_rc_iostuff *));
+long INTERFACE krb5_rc_io_size
PROTOTYPE((krb5_context,
krb5_rc_iostuff *));
-
#endif