summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1996-06-12 05:29:43 +0000
committerTheodore Tso <tytso@mit.edu>1996-06-12 05:29:43 +0000
commit9ea5441a9f42a441060d05cd1373bcd99804397b (patch)
tree3ef0ad865e64b4c6b1469bb7bbb7872a5181b3dd
parent578f087df29a96f7652506dee6b46a8e2aa30be3 (diff)
downloadkrb5-9ea5441a9f42a441060d05cd1373bcd99804397b.tar.gz
krb5-9ea5441a9f42a441060d05cd1373bcd99804397b.tar.xz
krb5-9ea5441a9f42a441060d05cd1373bcd99804397b.zip
test_profile.c: Add usage message if not enough arguments
prof_parse.c (dump_profile_to_file, dump_profile): Dump the profile using the correct line terminator for Windows, Macintosh, etc. prof_parse.c: prof_file.c: Change _WINDOWS to _MSDOS, and add check for _WIN32. prof_int.h: Add size #defines for _WIN32. Handle prototypes correctly for _WIN32. prof_int.h: Added comment to profile state structure git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@8318 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/util/profile/ChangeLog18
-rw-r--r--src/util/profile/prof_file.c2
-rw-r--r--src/util/profile/prof_int.h9
-rw-r--r--src/util/profile/prof_parse.c30
-rw-r--r--src/util/profile/profile.hin2
-rw-r--r--src/util/profile/test_parse.c7
-rw-r--r--src/util/profile/test_profile.c5
7 files changed, 58 insertions, 15 deletions
diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog
index 209dace7e..24a8fcbba 100644
--- a/src/util/profile/ChangeLog
+++ b/src/util/profile/ChangeLog
@@ -1,3 +1,21 @@
+Mon Jun 10 17:35:02 1996 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * test_profile.c: Add usage message if not enough arguments.
+
+ * prof_parse.c (dump_profile_to_file, dump_profile): Dump the
+ profile using the correct line terminator for Windows,
+ Macintosh, etc.
+
+ * prof_parse.c:
+ * prof_file.c: Change _WINDOWS to _MSDOS, and add check for _WIN32.
+
+ * prof_int.h: Add size #defines for _WIN32. Handle prototypes
+ correctly for _WIN32.
+
+Fri Feb 16 15:18:17 1996 <tytso@rsts-11.mit.edu>
+
+ * prof_int.h: Added comment to profile state structure
+
Wed Feb 14 16:43:48 1996 <tytso@rsts-11.mit.edu>
* prof_parse.c (parse_std_line): Make parsing more flexible, so we
diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c
index 468de74a8..f7bdaf855 100644
--- a/src/util/profile/prof_file.c
+++ b/src/util/profile/prof_file.c
@@ -17,7 +17,7 @@
#include <errno.h>
-#ifdef _WINDOWS
+#if defined(_MSDOS) || defined(_WIN32)
#define stat _stat
#endif
diff --git a/src/util/profile/prof_int.h b/src/util/profile/prof_int.h
index 46a7d5a55..4fd122eee 100644
--- a/src/util/profile/prof_int.h
+++ b/src/util/profile/prof_int.h
@@ -5,7 +5,7 @@
#include <time.h>
#include "prof_err.h"
-#if defined(__STDC__) || defined(_MSDOS)
+#if defined(__STDC__) || defined(_MSDOS) || defined(_WIN32)
#define PROTOTYPE(x) x
#else
#define PROTOTYPE(x) ()
@@ -18,6 +18,12 @@
#define SIZEOF_LONG 4
#endif
+#if defined(_WIN32)
+#define SIZEOF_INT 4
+#define SIZEOF_SHORT 2
+#define SIZEOF_LONG 4
+#endif
+
#if defined(_MACINTOSH)
#define NO_SYS_TYPES_H
#define NO_SYS_STAT_H
@@ -31,6 +37,7 @@ typedef long errcode_t;
*/
struct _prf_file_t {
errcode_t magic;
+ char *comment;
char *filename;
struct profile_node *root;
time_t timestamp;
diff --git a/src/util/profile/prof_parse.c b/src/util/profile/prof_parse.c
index eed309df0..4d1382bc8 100644
--- a/src/util/profile/prof_parse.c
+++ b/src/util/profile/prof_parse.c
@@ -198,7 +198,19 @@ errcode_t profile_parse_file(f, root)
return 0;
}
-#ifndef _WINDOWS
+#if defined(_MSDOS) || defined(_WIN32)
+#define EOL "\r\n"
+#endif
+
+#ifdef _MACINTOSH
+#define EOL "\r"
+#endif
+
+#ifndef EOL
+#define EOL "\n"
+#endif
+
+#if !defined(_MSDOS) && !defined(_WIN32)
void dump_profile(root, level)
struct profile_node *root;
@@ -218,7 +230,7 @@ void dump_profile(root, level)
break;
for (i=0; i < level; i++)
printf(" ");
- printf("%s = '%s'\n", name, value);
+ printf("%s = '%s'%s", name, value, EOL);
} while (iter != 0);
iter = 0;
@@ -229,11 +241,11 @@ void dump_profile(root, level)
break;
for (i=0; i < level; i++)
printf(" ");
- printf("[%s]\n", name);
+ printf("[%s]%s", name, EOL);
dump_profile(p, level+1);
} while (iter != 0);
}
-#endif /* ! _WINDOWS */
+#endif /* !_MSDOS && !_WIN32 */
void dump_profile_to_file(root, level, dstfile)
@@ -255,7 +267,7 @@ void dump_profile_to_file(root, level, dstfile)
break;
for (i=0; i < level; i++)
fprintf(dstfile, "\t");
- fprintf(dstfile, "%s = %s\r", name, value);
+ fprintf(dstfile, "%s = %s%s", name, value, EOL);
} while (iter != 0);
iter = 0;
@@ -267,17 +279,17 @@ void dump_profile_to_file(root, level, dstfile)
if (level == 0) { /* [xxx] */
for (i=0; i < level; i++)
fprintf(dstfile, "\t");
- fprintf(dstfile, "[%s]\r", name);
+ fprintf(dstfile, "[%s]%s", name, EOL);
dump_profile_to_file(p, level+1, dstfile);
- fprintf(dstfile, "\r");
+ fprintf(dstfile, EOL);
} else { /* xxx = { ... } */
for (i=0; i < level; i++)
fprintf(dstfile, "\t");
- fprintf(dstfile, "%s = {\r", name);
+ fprintf(dstfile, "%s = {%s", name, EOL);
dump_profile_to_file(p, level+1, dstfile);
for (i=0; i < level; i++)
fprintf(dstfile, "\t");
- fprintf(dstfile, "}\r");
+ fprintf(dstfile, "}%s", EOL);
}
} while (iter != 0);
}
diff --git a/src/util/profile/profile.hin b/src/util/profile/profile.hin
index 80f7d37ca..e0fee5ba5 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(_MSDOS)
+#if defined(__STDC__) || defined(_MSDOS) || defined(_WIN32)
#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 346615401..463cde4da 100644
--- a/src/util/profile/test_parse.c
+++ b/src/util/profile/test_parse.c
@@ -49,12 +49,13 @@ int main(argc, argv)
fclose(f);
printf("\n\nDebugging dump.\n");
+#if 0
dump_profile(root, 0);
-
-#if 1
- profile_free_node(root);
#else
dump_profile_to_file(root, 0, stdout);
#endif
+
+ profile_free_node(root);
+
return 0;
}
diff --git a/src/util/profile/test_profile.c b/src/util/profile/test_profile.c
index 52acfbe70..b75c81f70 100644
--- a/src/util/profile/test_profile.c
+++ b/src/util/profile/test_profile.c
@@ -31,6 +31,11 @@ int main(argc, argv)
filenames[0] = argv[1];
filenames[1] = 0;
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s filename argset\n", argv[0]);
+ exit(1);
+ }
+
initialize_prof_error_table();
retval = profile_init(filenames, &profile);