[PC-BSD Commits] r17828 - pcbsd-projects/AD_4_PCBSD/krb

svn at pcbsd.org svn at pcbsd.org
Fri Jul 20 02:39:55 PDT 2012


Author: johnh
Date: 2012-07-20 09:39:55 +0000 (Fri, 20 Jul 2012)
New Revision: 17828

Modified:
   pcbsd-projects/AD_4_PCBSD/krb/krb5-parser.tab.i
   pcbsd-projects/AD_4_PCBSD/krb/krb5-parser.y
   pcbsd-projects/AD_4_PCBSD/krb/krbconf.c
   pcbsd-projects/AD_4_PCBSD/krb/krbconf.h
Log:
Got the syntax/grammer all figured out, checking in progress and moving
forward.



Modified: pcbsd-projects/AD_4_PCBSD/krb/krb5-parser.tab.i
===================================================================
--- pcbsd-projects/AD_4_PCBSD/krb/krb5-parser.tab.i	2012-07-20 09:20:51 UTC (rev 17827)
+++ pcbsd-projects/AD_4_PCBSD/krb/krb5-parser.tab.i	2012-07-20 09:39:55 UTC (rev 17828)
@@ -24,9 +24,35 @@
 extern	void set_binding_value(struct krb_binding *, const char *);
 
 extern	int lineno;
-extern	int	block;
+extern	int tindex;
+extern	int	*tstack;
 
-#line 27 "krb5-parser.y"
+#define	STOKENMAX	32768
+#define	SECTION		1234
+#define	NAME		1235
+#define	VALUE		1236
+
+struct _krbinfo {
+	int type;
+
+#define	TYPE_SECTION		1
+#define	TYPE_BINDING		2
+
+	struct krb_binding *kb;
+
+#define	kb_bindings		kb->bindings
+#define	kb_nbindings	kb->nbindings
+
+	struct krb_section *ks;
+
+#define	ks_bindings		ks->bindings
+#define	ks_nbindings	ks->nbindings
+};
+
+extern	struct	_krbinfo bl;
+extern	struct	_krbinfo ll;
+
+#line 53 "krb5-parser.y"
 #ifdef YYSTYPE
 #undef  YYSTYPE_IS_DECLARED
 #define YYSTYPE_IS_DECLARED 1

Modified: pcbsd-projects/AD_4_PCBSD/krb/krb5-parser.y
===================================================================
--- pcbsd-projects/AD_4_PCBSD/krb/krb5-parser.y	2012-07-20 09:20:51 UTC (rev 17827)
+++ pcbsd-projects/AD_4_PCBSD/krb/krb5-parser.y	2012-07-20 09:39:55 UTC (rev 17828)
@@ -20,8 +20,34 @@
 extern	void set_binding_value(struct krb_binding *, const char *);
 
 extern	int lineno;
-extern	int	block;
+extern	int tindex;
+extern	int	*tstack;
 
+#define	STOKENMAX	32768
+#define	SECTION		1234
+#define	NAME		1235
+#define	VALUE		1236
+
+struct _krbinfo {
+	int type;
+
+#define	TYPE_SECTION		1
+#define	TYPE_BINDING		2
+
+	struct krb_binding *kb;
+
+#define	kb_bindings		kb->bindings
+#define	kb_nbindings	kb->nbindings
+
+	struct krb_section *ks;
+
+#define	ks_bindings		ks->bindings
+#define	ks_nbindings	ks->nbindings
+};
+
+extern	struct	_krbinfo bl;
+extern	struct	_krbinfo ll;
+
 %}
 
 %union {
@@ -73,29 +99,40 @@
 	{
 		struct krb_section *ks = new_krb_section($1);
 		TAILQ_INSERT_TAIL(&fentries, ks, entries);
+
+		xfree(&tstack);
+		tstack = xalloc(STOKENMAX);
+		tindex = 0;
+		tstack[tindex++] = SECTION;
+
+		bl.type = TYPE_SECTION;
+		bl.ks = ks;
 		cs = ks;
 	}
 
 bindings:
 	binding bindings |
-	binding
+	binding |
 
 binding:
 	|
+	comments |
 	name eq value |
-	name eq bopen bindings bclose
+	name eq bopen bindings bclose 
 
 eq:
-	EQ
+	EQ {
+		tstack[tindex++] = EQ;
+	}
 
 bopen:
 	B_OPEN {
-		block = 1;
+		tstack[tindex++] = B_OPEN;
 	}
 
 bclose:
 	B_CLOSE {
-		block = 0;
+		tstack[tindex++] = B_CLOSE;
 	}
 
 name:
@@ -106,53 +143,58 @@
 		kb->name = xstrdup($1);
 
 		/*
-		 *	-> name = telnet, value = 
-		 *	-> cur = telnet
-		 *
-		 *	-> name = rcp, value = 
-		 *	-> cur = rcp
+		 *	Start of a section, set the binding list to a sectionk
+		 *	binding list.
 		 */
+		if (tstack[tindex - 1] == SECTION) {
+			bl.type = TYPE_SECTION;
+			bl.ks = cs;
 
 		/*
-		 *	-> name = login, value = 
-		 *	-> cur = login
-		 *
-		 *	-> name = forwardable, value = true
-		 *	-> cur = forwadable
-		 *
-		 *	-> name = krb5_run_aklog , value = true
-		 *	-> cur = krb5_run_aklog
-		 *
-		 *	-> name = krb5_get_tickets , value = true
-		 *	-> cur = krb5_get_tickets
-		 *
-		 *	-> name = krb5_get_tickets , value = false
-		 *	-> cur = krb5_get_tickets
-		 *
-		 *	-> name = krb4_convert , value = false
-		 *	-> cur = krb4_convert
-		 *
-		 *	-> name = kinit , value = 
-		 *	-> cur = kinit 
-		 *
+		 *	Don't change anything, insert into the current binding list.
 		 */
+		} else if (tstack[tindex - 1] == VALUE) {
 
-		if (cb != NULL && cb->value == NULL) {
-			printf("XX: inserting (%s) into (%s) XXX\n", kb->name, cb->name);
-			cb->nbindings++;
-			TAILQ_INSERT_TAIL(&cb->bindings, kb, entries);
 
+		/*
+		 *	Opening brace into a new binding. Save the current binding
+		 *	list for now and set the binding list to the current binding
+		 *	list.
+		 */
+		} else if (tstack[tindex - 1] == B_OPEN) {
+			ll = bl;
+			bl.type = TYPE_BINDING;
+			bl.kb = cb;
+
+		/*
+		 *	Closing brace of a binding. Set the binding list to the list
+		 *	to the binding list set when the brace opened.
+		 */
+		} else if (tstack[tindex - 1] == B_CLOSE) {
+			bl = ll;
+
 		} else {
-			cs->nbindings++;
-			TAILQ_INSERT_TAIL(&cs->bindings, kb, entries);
-			cb = kb;
+			/* shouldn't get here */
 		}
+
+		if (bl.type == TYPE_SECTION) {
+			TAILQ_INSERT_TAIL(&bl.ks_bindings, kb, entries);
+			bl.ks_nbindings++;
+
+		} else {
+			TAILQ_INSERT_TAIL(&bl.kb_bindings, kb, entries);
+			bl.kb_nbindings++;
+		}
+
+		cb = kb;
+		tstack[tindex++] = NAME;
 	}
 
 value:
 	STRING
 	{
 		cb->value = xstrdup($1);
+		tstack[tindex++] = VALUE;
 	}
 
 comment:
@@ -160,11 +202,15 @@
 
 %%
 
-int block = 0;
+int tindex;
+int *tstack = NULL;
 
 struct	krb_section *cs = NULL;
 struct	krb_binding *cb = NULL;
 
+struct	_krbinfo bl;
+struct	_krbinfo ll;
+
 struct krb_binding *
 new_krb_binding(void)
 {

Modified: pcbsd-projects/AD_4_PCBSD/krb/krbconf.c
===================================================================
--- pcbsd-projects/AD_4_PCBSD/krb/krbconf.c	2012-07-20 09:20:51 UTC (rev 17827)
+++ pcbsd-projects/AD_4_PCBSD/krb/krbconf.c	2012-07-20 09:39:55 UTC (rev 17828)
@@ -204,23 +204,49 @@
 #endif
 
 static int
-write_krb5_bindings(struct krb_binding *kb)
+write_krb5_bindings(struct krb_binding *kb, int indent)
 {
 	if (kb == NULL)
 		return (-1);
 
 	if (kb->nbindings > 0) {
 		struct krb_binding *kbtmp;
+		int i;
 
-		fprintf(yyout, "%s (%d) = {\n", kb->name, kb->nbindings);
+		for (i = 0;i < indent;i++)
+			fprintf(yyout, "\t");
+		fprintf(yyout, "%s = { \n", kb->name, kb->nbindings);
 
-		TAILQ_FOREACH(kbtmp, &kb->bindings, entries)
-			write_krb5_bindings(kbtmp);
+		TAILQ_FOREACH(kbtmp, &kb->bindings, entries) {
 
+			if (kbtmp->nbindings > 0) {
+				write_krb5_bindings(kbtmp, indent + 1);
+
+			} else {
+				int i;
+
+				for (i = 0;i < indent + 1;i++)
+					fprintf(yyout, "\t");
+				fprintf(yyout, "%s = %s\n", kbtmp->name, kbtmp->value);
+			}
+		}	
+
+		for (i = 0;i < indent;i++)
+			fprintf(yyout, "\t");
 		fprintf(yyout, "}\n");
 
 	} else {
-		fprintf(yyout, "\t%s = %s\n", kb->name, kb->value);
+		int i;
+
+		for (i = 0;i < indent;i++)
+			fprintf(yyout, "\t");
+
+		if (kb->value != NULL) {
+			fprintf(yyout, "%s = %s\n", kb->name, kb->value);
+
+		} else {
+			fprintf(yyout, "%s = { }\n", kb->name);
+		}
 	}
 
 	return (0);
@@ -239,7 +265,7 @@
 			struct krb_binding *kb;
 
 			TAILQ_FOREACH(kb, &ks->bindings, entries)
-				write_krb5_bindings(kb);
+				write_krb5_bindings(kb, 1);
 		}
 	}
 }

Modified: pcbsd-projects/AD_4_PCBSD/krb/krbconf.h
===================================================================
--- pcbsd-projects/AD_4_PCBSD/krb/krbconf.h	2012-07-20 09:20:51 UTC (rev 17827)
+++ pcbsd-projects/AD_4_PCBSD/krb/krbconf.h	2012-07-20 09:39:55 UTC (rev 17828)
@@ -30,19 +30,21 @@
 
 #define	KRB_BINDING_LIST	0x00000001
 
+TAILQ_HEAD(krb_binding_list, krb_binding);
+
 struct krb_binding {
 	char *name;
 	char *value;
 	unsigned int flags;
 	unsigned int nbindings;
-	TAILQ_HEAD(krb_binding_bindings, krb_binding) bindings;
+	struct krb_binding_list bindings;
 	TAILQ_ENTRY(krb_binding) entries;
 };
 
 struct krb_section {
 	char *name;  
 	unsigned int nbindings;
-	TAILQ_HEAD(krb_section_bindings, krb_binding) bindings;
+	struct krb_binding_list bindings;
 	TAILQ_ENTRY(krb_section) entries;
 };
 



More information about the Commits mailing list