From: Keith Vetter Date: Thu, 27 Apr 1995 18:08:37 +0000 (+0000) Subject: Got the profile code to work on the PC X-Git-Tag: krb5-1.0-beta5~203 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=161f5baf40d07945a701d1fe8e12dc06c32953d2;p=krb5.git Got the profile code to work on the PC git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5549 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index 180216f94..58bea73c5 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,13 @@ +Thu Apr 27 10:43:24 1995 Keith Vetter (keithv@fusion.com) + + * Makefile.in: made to work on the PC. + * profile.hin, prof_int.h: use _MSDOS instead of _WINDOWS + so we can compile DOS test programs. + * *.c: Don't need to include file unistd.h. + * test_*.c: Made to work under DOS--used stubs for the com_err stuff. + * prof_parse.c: Turned a 2k automatic array into a malloc'ed block + because windows dll's shouldn't use up a lot of stack space. + Wed Apr 26 09:54:18 1995 Ezra Peisach * profile.hin: Only define PROTOTYPE if it is undefined. diff --git a/src/util/profile/Makefile.in b/src/util/profile/Makefile.in index b13253823..898ef0ce2 100644 --- a/src/util/profile/Makefile.in +++ b/src/util/profile/Makefile.in @@ -1,12 +1,16 @@ CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) +##DOSBUILDTOP = ..\.. +##DOSLIBNAME=profile.lib +##DOS!include $(BUILDTOP)\config\windows.in + LOCALINCLUDE=-I. -I$(srcdir)/../et -OBJS = prof_tree.o \ - prof_file.o \ - prof_parse.o \ - prof_err.o \ - prof_init.o +OBJS = prof_tree.$(OBJEXT) \ + prof_file.$(OBJEXT) \ + prof_parse.$(OBJEXT) \ + prof_err.$(OBJEXT) \ + prof_init.$(OBJEXT) SRCS = $(srcdir)/prof_tree.c \ $(srcdir)/prof_file.c \ @@ -14,19 +18,38 @@ SRCS = $(srcdir)/prof_tree.c \ prof_err.c \ $(srcdir)/prof_init.c -LIBS = ../et/libcom_err.a +LIBS = ../et/libcom_err.$(LIBEXT) + +all:: all-$(WHAT) + +all-max:: all-unix +all-unix:: includes libprofile.a test_parse test_profile -all:: includes libprofile.a test_parse test_profile +all-windows: $(OBJS) + +awk-windows: + $(AWK) -f $(BUILDTOP)/util/et/et_h.awk outfile=prof_err.h prof_err.et + $(AWK) -f $(BUILDTOP)/util/et/et_c.awk outfile=prof_err.c prof_err.et + if exist prof_err.h copy profile.hin+prof_err.h profile.h + if exist profile.h copy profile.h $(BUILDTOP)\include\profile.h libprofile.a: $(OBJS) - $(ARADD) $@ $(OBJS) + $(ARCHIVE) $@ $(OBJS) $(RANLIB) $@ -test_parse: test_parse.o $(OBJS) $(LIBS) - $(CC) -o test_parse test_parse.o $(OBJS) $(LIBS) +test_parse: test_parse.$(OBJEXT) $(OBJS) $(LIBS) + $(CC) -o test_parse test_parse.$(OBJEXT) $(OBJS) $(LIBS) + +test_profile: test_profile.$(OBJEXT) $(OBJS) $(LIBS) + $(CC) -o test_profile test_profile.$(OBJEXT) $(OBJS) $(LIBS) -test_profile: test_profile.o $(OBJS) $(LIBS) - $(CC) -o test_profile test_profile.o $(OBJS) $(LIBS) +test_parse.exe: + $(CC) $(CFLAGS2) -o test_parse.exe test_parse.c \ + prof_parse.c prof_tree.c /link /stack:16384 + +test_profile.exe: + $(CC) $(CFLAGS2) -o test_profile.exe test_profile.c prof_init.c \ + prof_file.c prof_parse.c prof_tree.c /link /stack:16384 profile.h: prof_err.h profile.hin cat $(srcdir)/profile.hin prof_err.h > $@ @@ -35,9 +58,22 @@ prof_err.h: $(srcdir)/prof_err.et prof_err.c: $(srcdir)/prof_err.et -clean:: +clean:: clean-$(WHAT) + +clean-mac:: clean-unix +clean-unix:: rm -f $(PROGS) *.o *~ test_parse core libprofile.a prof_err.h \ prof_err.c +clean-windows:: + $(RM) profile.lib profile.bak test_parse.exe test_profile.exe + +check:: check-$(WHAT) + +check-mac:: +check-unix:: +check-windows:: test_profile.exe test_parse.exe + $(RM) *.obj + test_parse test.ini # +++ Dependency line eater +++ # diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c index eeae90419..b4b305e18 100644 --- a/src/util/profile/prof_file.c +++ b/src/util/profile/prof_file.c @@ -3,7 +3,6 @@ */ #include -#include #include #include #include @@ -12,6 +11,10 @@ #include "prof_int.h" +#ifdef _WINDOWS +#define stat _stat +#endif + errcode_t profile_open_file(filename, ret_prof) const char *filename; prf_file_t *ret_prof; diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c index 9a4a0b533..57af950fb 100644 --- a/src/util/profile/prof_init.c +++ b/src/util/profile/prof_init.c @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -132,11 +131,6 @@ errcode_t profile_get_values(profile, names, ret_values) init_list(&values); - if (profile == 0) { - *ret_values = 0; - return 0; - } - file = profile->first_file; retval = profile_update_file(file); if (retval) diff --git a/src/util/profile/prof_int.h b/src/util/profile/prof_int.h index 2585277da..940e2ac9a 100644 --- a/src/util/profile/prof_int.h +++ b/src/util/profile/prof_int.h @@ -5,7 +5,7 @@ #include #include "prof_err.h" -#if defined(__STDC__) || defined(_WINDOWS) +#if defined(__STDC__) || defined(_MSDOS) #define PROTOTYPE(x) x #else #define PROTOTYPE(x) () diff --git a/src/util/profile/prof_parse.c b/src/util/profile/prof_parse.c index 6f85a6f2c..794e98266 100644 --- a/src/util/profile/prof_parse.c +++ b/src/util/profile/prof_parse.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -166,24 +165,37 @@ errcode_t profile_parse_file(f, root) FILE *f; struct profile_node **root; { - char buf[2048]; - int retval; +#define BUF_SIZE 2048 + char *bptr; + errcode_t retval; struct parse_state state; + bptr = malloc (BUF_SIZE); + if (!bptr) + return ENOMEM; + retval = parse_init_state(&state); - if (retval) + if (retval) { + free (bptr); return retval; + } while (!feof(f)) { - if (fgets(buf, sizeof(buf), f) == NULL) + if (fgets(bptr, BUF_SIZE, f) == NULL) break; - retval = parse_line(buf, &state); - if (retval) + retval = parse_line(bptr, &state); + if (retval) { + free (bptr); return retval; + } } *root = state.root_section; + + free (bptr); return 0; } +#ifndef _WINDOWS + void dump_profile(root, level) struct profile_node *root; int level; @@ -217,4 +229,4 @@ void dump_profile(root, level) dump_profile(p, level+1); } while (iter != 0); } - +#endif /* ! _WINDOWS */ diff --git a/src/util/profile/prof_section.c b/src/util/profile/prof_section.c index bbcf65ae1..b3407ecc0 100644 --- a/src/util/profile/prof_section.c +++ b/src/util/profile/prof_section.c @@ -7,7 +7,6 @@ #include #include -#include #include #include "prof_int.h" diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index 1dc701373..c39831955 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/src/util/profile/profile.hin b/src/util/profile/profile.hin index 2fec69337..3c0d9df95 100644 --- a/src/util/profile/profile.hin +++ b/src/util/profile/profile.hin @@ -5,7 +5,7 @@ typedef struct _profile_t *profile_t; #if !defined(PROTOTYPE) -#if defined(__STDC__) || defined(_WINDOWS) +#if defined(__STDC__) || defined(_MSDOS) #define PROTOTYPE(x) x #else #define PROTOTYPE(x) () diff --git a/src/util/profile/test_parse.c b/src/util/profile/test_parse.c index fd81d1d16..8ea54510b 100644 --- a/src/util/profile/test_parse.c +++ b/src/util/profile/test_parse.c @@ -1,20 +1,33 @@ #include #include -#include #include #include #include #include "profile.h" + +#ifndef _MSDOS #include "com_err.h" +#else + +#include "prof_int.h" +#define initialize_prof_error_table() +char *error_message (long err) { + static char buf[50]; + + sprintf (buf, " 0x%lX (%ld)", err, err); + return buf; +} +#endif int main(argc, argv) int argc; char **argv; { - struct profile_relation *root; + struct profile_node *root; unsigned long retval; FILE *f; + void dump_profile(struct profile_node *root, int level); initialize_prof_error_table(); if (argc != 2) { diff --git a/src/util/profile/test_profile.c b/src/util/profile/test_profile.c index c6dfaa62a..52acfbe70 100644 --- a/src/util/profile/test_profile.c +++ b/src/util/profile/test_profile.c @@ -3,11 +3,20 @@ */ #include -#include #include #include "profile.h" +#ifndef _MSDOS #include "com_err.h" +#else + +/* Stubs for the error handling routines */ +#include "prof_int.h" +void initialize_prof_error_table() {} +void com_err (char *fmt, long err, char *msg) { + printf (fmt, err, msg); +} +#endif int main(argc, argv) int argc; @@ -41,7 +50,9 @@ int main(argc, argv) } free(values); profile_release(profile); - exit(0); + + return 0; + }