summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorKeith Vetter <keithv@fusion.com>1995-09-11 19:06:45 +0000
committerKeith Vetter <keithv@fusion.com>1995-09-11 19:06:45 +0000
commitcdd6c33b9ae48076999e33ffa70e2365ecc5eb8c (patch)
tree84682f14e77a844dfab2174318ebccb9067c829f /src/util
parenta66029e852781fa0333dc92bd88bd8184f6feeb1 (diff)
Mac Beta 1 submission
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6749 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
-rw-r--r--src/util/et/com_err.c62
-rw-r--r--src/util/et/error_message.c6
-rw-r--r--src/util/et/vfprintf.c2
-rw-r--r--src/util/profile/prof_init.c54
-rw-r--r--src/util/profile/prof_parse.c55
-rw-r--r--src/util/profile/prof_section.c1
-rw-r--r--src/util/profile/prof_tree.c65
7 files changed, 245 insertions, 0 deletions
diff --git a/src/util/et/com_err.c b/src/util/et/com_err.c
index 5b4940947..e8ed65d2e 100644
--- a/src/util/et/com_err.c
+++ b/src/util/et/com_err.c
@@ -15,6 +15,10 @@
#define VARARGS
#endif
+#ifdef _MACINTOSH
+#include "icons.h"
+#endif
+
#include "error_table.h"
#include "internal.h"
@@ -69,12 +73,70 @@ static void
#ifdef _WINDOWS
MessageBox (NULL, errbuf, "Kerboros", MB_ICONEXCLAMATION);
#else
+#ifdef _MACINTOSH
+{
+WindowPtr errWindow;
+ControlHandle errOkButton;
+Rect errOkButtonRect = { 120, 220, 140, 280 };
+Rect errRect = { 0, 0, 150, 300 };
+GDHandle mainDevice = GetMainDevice();
+Rect mainRect = (**mainDevice).gdRect;
+Rect tmpRect;
+Rect errTextRect = { 10, 70, 110, 290 };
+Rect errIconRect = { 10, 10, 10 + 32, 10 + 32 };
+EventRecord theEvent;
+Point localPt;
+Boolean done;
+
+ /* Find Centered rect for window */
+ tmpRect.top = (mainRect.bottom + mainRect.top)/2 - (errRect.bottom + errRect.top)/2;
+ tmpRect.bottom = tmpRect.top + (errRect.bottom - errRect.top);
+ tmpRect.left = (mainRect.right + mainRect.left)/2 - (errRect.right + errRect.left)/2;
+ tmpRect.right = tmpRect.left + (errRect.right - errRect.left);
+
+ /* Create the error window - as a dialog window */
+ errWindow = NewWindow(NULL, &tmpRect, "\p", TRUE, dBoxProc, (WindowPtr) -1, FALSE, 0L);
+
+ SetPort(errWindow);
+ TextFont(systemFont);
+ TextSize(12);
+
+ errOkButton = NewControl(errWindow,&errOkButtonRect,"\pOk",TRUE,0,0,1,pushButProc,0L);
+ DrawControls(errWindow);
+
+ /* Draw the error text */
+ TextBox(errbuf, strlen(errbuf), &errTextRect, teForceLeft);
+
+ /* Draw the Stop icon */
+ PlotIcon(&errIconRect, GetResource('ICON', 0));
+
+ /* mini event loop here */
+ done = FALSE;
+ while(!done)
+ {
+ GetNextEvent(mDownMask | mUpMask, &theEvent);
+ if (theEvent.what == mouseDown)
+ {
+ localPt = theEvent.where;
+ GlobalToLocal(&localPt);
+ if (TestControl(errOkButton, localPt) && TrackControl(errOkButton, localPt, NULL))
+ {
+ done = TRUE;
+ }
+ }
+ }
+
+ /* Dispose of the Window, disposes of controls */
+ DisposeWindow(errWindow);
+}
+#else
fputs (errbuf, stderr);
/* should do this only on a tty in raw mode */
putc('\r', stderr);
putc('\n', stderr);
fflush(stderr);
#endif
+#endif
}
#if defined(__STDC__) || defined(_WINDOWS)
diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c
index ddc043353..26db759bb 100644
--- a/src/util/et/error_message.c
+++ b/src/util/et/error_message.c
@@ -17,6 +17,8 @@
#include "mit-sipb-copyright.h"
#include "internal.h"
+#define sys_nerr 100
+
static const char copyright[] =
"Copyright 1986, 1987, 1988 by the Student Information Processing Board\nand the department of Information Systems\nof the Massachusetts Institute of Technology";
@@ -47,6 +49,7 @@ long code;
offset = (int) l_offset;
table_num = code - l_offset;
if (!table_num) {
+#ifdef HAS_SYSERRLIST
#ifdef HAS_STRERROR
return strerror (offset);
#else
@@ -55,6 +58,9 @@ long code;
else
goto oops;
#endif
+#else
+ goto oops;
+#endif
}
for (et = _et_list; et; et = et->next) {
if (et->table->base == table_num) {
diff --git a/src/util/et/vfprintf.c b/src/util/et/vfprintf.c
index d397e9ede..328d882a0 100644
--- a/src/util/et/vfprintf.c
+++ b/src/util/et/vfprintf.c
@@ -18,6 +18,7 @@
/* based on @(#)vfprintf.c 5.2 (Berkeley) 6/27/88 */
#include <stdio.h>
+#if !defined(_MACINTOSH)
#if defined(HAVE_STDARG_H) || defined(_WINDOWS) || defined (_MACINTOSH)
#include <stdarg.h>
#else
@@ -48,3 +49,4 @@ vfprintf(iop, fmt, ap)
return (ferror(iop) ? EOF : len);
}
+#endif
diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c
index d8e1c6bd1..c0d10f689 100644
--- a/src/util/profile/prof_init.c
+++ b/src/util/profile/prof_init.c
@@ -177,6 +177,60 @@ cleanup:
/*
* XXX this version only works to get values from the first file.
+ * To do more than that means we have to implement some "interesting"
+ * code to do the section searching.
+ */
+errcode_t profile_get_first_values(profile, names, ret_values)
+ profile_t profile;
+ const char **names;
+ char ***ret_values;
+{
+ prf_file_t file;
+ errcode_t retval;
+ struct profile_node *section;
+ void *state;
+ char *value;
+ struct string_list values;
+ const char **cpp;
+ char *dummyvalue;
+ char *secname;
+ const char *mynames[3];
+
+
+ if (profile == 0)
+ return PROF_NO_PROFILE;
+
+ if (names == 0 || names[0] == 0)
+ return PROF_BAD_NAMESET;
+
+ init_list(&values);
+
+ file = profile->first_file;
+ retval = profile_update_file(file);
+ if (retval)
+ goto cleanup;
+
+ section = file->root;
+
+ state = 0;
+ retval = profile_find_node_subsection(section, *names, &state, &secname, &section);
+
+ do {
+ retval = profile_find_node_name(section, &state, &value);
+ if (retval)
+ goto cleanup;
+ add_to_list(&values, value);
+ } while (state);
+
+ *ret_values = values.list;
+ return 0;
+cleanup:
+ free_list(&values);
+ return retval;
+}
+
+/*
+ * XXX this version only works to get values from the first file.
*/
static errcode_t profile_get_value(profile, names, ret_value)
profile_t profile;
diff --git a/src/util/profile/prof_parse.c b/src/util/profile/prof_parse.c
index fde563fac..6927321d0 100644
--- a/src/util/profile/prof_parse.c
+++ b/src/util/profile/prof_parse.c
@@ -230,3 +230,58 @@ void dump_profile(root, level)
} while (iter != 0);
}
#endif /* ! _WINDOWS */
+
+
+void dump_profile_to_file(root, level, dstfile)
+ struct profile_node *root;
+ int level;
+ FILE *dstfile;
+{
+ int i;
+ struct profile_node *p;
+ void *iter;
+ long retval;
+ char *name, *value;
+
+ iter = 0;
+ do {
+ retval = profile_find_node_relation(root, 0, &iter,
+ &name, &value);
+ if (retval)
+ break;
+ for (i=0; i < level; i++)
+ fprintf(dstfile, "\t");
+ fprintf(dstfile, "%s = %s\r", name, value);
+ } while (iter != 0);
+
+ iter = 0;
+ do {
+ retval = profile_find_node_subsection(root, 0, &iter,
+ &name, &p);
+ if (retval)
+ break;
+ if (level == 0) /* [xxx] */
+ {
+ for (i=0; i < level; i++)
+ fprintf(dstfile, "\t");
+ fprintf(dstfile, "[%s]\r", name);
+ dump_profile_to_file(p, level+1, dstfile);
+ fprintf(dstfile, "\r");
+ }
+ else if (level == 1) /* xxx = { ... } */
+ {
+ for (i=0; i < level; i++)
+ fprintf(dstfile, "\t");
+ fprintf(dstfile, "%s = {\r", name);
+ dump_profile_to_file(p, level+1, dstfile);
+ for (i=0; i < level; i++)
+ fprintf(dstfile, "\t");
+ fprintf(dstfile, "}\r");
+ }
+ else /* +xxx+ */
+ {
+ // don't know what comes next, this should get someones attention
+ fprintf(dstfile, "+%s+");
+ }
+ } while (iter != 0);
+}
diff --git a/src/util/profile/prof_section.c b/src/util/profile/prof_section.c
index b3407ecc0..e563e4f23 100644
--- a/src/util/profile/prof_section.c
+++ b/src/util/profile/prof_section.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
#include "prof_int.h"
diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c
index 5cb86c92c..4934d29c5 100644
--- a/src/util/profile/prof_tree.c
+++ b/src/util/profile/prof_tree.c
@@ -323,6 +323,42 @@ errcode_t profile_delete_node_relation(section, name)
}
/*
+ * This function deletes a relation from a section. Subsections are
+ * not deleted; if those need to be deleted, they must be done so manually.
+ * And sections need not have a value to be delete, this is to enable
+ * deleting sections which are valueless headers for subsections.
+ */
+errcode_t profile_delete_interior_node_relation(section, name)
+ struct profile_node *section;
+ const char *name;
+{
+ struct profile_node *p, *next;
+
+ for (p = section->first_child; p; p = p->next) {
+ if ((strcmp(p->name, name) == 0))
+ break;
+ }
+ if (p == 0)
+ return PROF_NO_RELATION;
+ /*
+ * Now we start deleting the relations... if we find a
+ * subsection with the same name, delete it and keep going.
+ */
+ while (p && (strcmp(p->name, name) == 0)) {
+ if (p->prev)
+ p->prev->next = p->next;
+ else
+ section->first_child = p->next;
+ next = p->next;
+ if (p->next)
+ p->next->prev = p;
+ profile_free_node(p);
+ p = next;
+ }
+ return 0;
+}
+
+/*
* This function returns the parent of a particular node.
*/
errcode_t profile_get_node_parent(section, parent)
@@ -333,3 +369,32 @@ errcode_t profile_get_node_parent(section, parent)
}
+/*
+ * Taking the state from another find function, give the name of the
+ * section and move to the next section. In this case, state can't be null
+ */
+errcode_t profile_find_node_name(section, state, ret_name)
+ struct profile_node *section;
+ void **state;
+ char **ret_name;
+{
+ struct profile_node *p;
+
+ CHECK_MAGIC(section);
+ p = *state;
+ if (p) {
+ CHECK_MAGIC(p);
+ } else
+ p = section->first_child;
+
+ if (p == 0) {
+ *state = 0;
+ return PROF_NO_SECTION;
+ }
+/* give the name back */
+ *ret_name = p->name;
+ p = p->next;
+
+ *state = p;
+ return 0;
+}