changeset 28:33e4c4cdf493

libunet: reading of ATTR lines implemented
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sat, 08 Aug 2015 21:17:57 +0000
parents d14bf25b5e26
children dcdf606dfaaa
files ueda/libunet/unetrd.c ueda/libunet/unetrd.h
diffstat 2 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ueda/libunet/unetrd.c	Thu Aug 06 20:40:19 2015 +0000
+++ b/ueda/libunet/unetrd.c	Sat Aug 08 21:17:57 2015 +0000
@@ -144,6 +144,29 @@
 	}
 }
 
+static void
+handle_attr(state, out, rest)
+	struct unetrd_state *state;
+	struct unetrd_out *out;
+	char *rest;
+{
+	char *cp;
+
+	for (cp = rest; isspace(*cp); cp++)
+		;
+	if (*cp == '\0' || *cp == '#') {
+error:		fprintf(stderr, "%s line %d: invalid syntax on ATTR line\n",
+			state->filename, state->lineno);
+		exit(1);
+	}
+	out->objname = cp;
+	cp = index(cp, '=');
+	if (!cp)
+		goto error;
+	*cp++ = '\0';
+	out->attr_value = cp;
+}
+
 static struct objmap {
 	char	*keyword;
 	int	typecode;
@@ -157,6 +180,7 @@
 	{"ALTNAME",	UNETOBJ_ALTNAME,	handle_name_only},
 	{"PIN",		UNETOBJ_PIN,		handle_pin_line},
 	{"PINMAP",	UNETOBJ_PINMAP,		handle_pin_line},
+	{"ATTR",	UNETOBJ_ATTR,		handle_attr},
 	{0, 0, 0}
 };
 
--- a/ueda/libunet/unetrd.h	Thu Aug 06 20:40:19 2015 +0000
+++ b/ueda/libunet/unetrd.h	Sat Aug 08 21:17:57 2015 +0000
@@ -14,6 +14,7 @@
 	char	*objname;
 	char	*connect_to_net;
 	char	*nc_comment;
+	char	*attr_value;
 };
 
 #define	UNETOBJ_CLOSINGBRACE	0
@@ -24,3 +25,4 @@
 #define	UNETOBJ_ALTNAME		5
 #define	UNETOBJ_PIN		6
 #define	UNETOBJ_PINMAP		7
+#define	UNETOBJ_ATTR		8