Module Name:    src
Committed By:   plunky
Date:           Fri Jun 24 20:53:56 UTC 2011

Modified Files:
        src/usr.bin/sdpquery: print.c

Log Message:
some attributes contain comma separated lists which are too long to
show on a single line, split them up


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/sdpquery/print.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.12 src/usr.bin/sdpquery/print.c:1.13
--- src/usr.bin/sdpquery/print.c:1.12	Fri Jun 24 20:11:23 2011
+++ src/usr.bin/sdpquery/print.c	Fri Jun 24 20:53:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.12 2011/06/24 20:11:23 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.13 2011/06/24 20:53:56 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: print.c,v 1.12 2011/06/24 20:11:23 plunky Exp $");
+__RCSID("$NetBSD: print.c,v 1.13 2011/06/24 20:53:56 plunky Exp $");
 
 #include <ctype.h>
 #include <iconv.h>
@@ -82,6 +82,7 @@
 static void print_uuid(sdp_data_t *);
 static void print_uuid_list(sdp_data_t *);
 static void print_string(sdp_data_t *);
+static void print_string_list(sdp_data_t *);
 static void print_url(sdp_data_t *);
 static void print_profile_version(sdp_data_t *);
 static void print_language_string(sdp_data_t *);
@@ -244,19 +245,19 @@
 };
 
 attr_t bp_attrs[] = {	/* Basic Printing */
-	{ 0x0350, "DocumentFormatsSupported",		print_string },
+	{ 0x0350, "DocumentFormatsSupported",		print_string_list },
 	{ 0x0352, "CharacterRepertoiresSupported",	print_character_repertoires },
-	{ 0x0354, "XHTML-PrintImageFormatsSupported",	print_string },
+	{ 0x0354, "XHTML-PrintImageFormatsSupported",	print_string_list },
 	{ 0x0356, "ColorSupported",			print_bool },
 	{ 0x0358, "1284ID",				print_string },
 	{ 0x035a, "PrinterName",			print_string },
 	{ 0x035c, "PrinterLocation",			print_string },
 	{ 0x035e, "DuplexSupported",			print_bool },
-	{ 0x0360, "MediaTypesSupported",		print_string },
+	{ 0x0360, "MediaTypesSupported",		print_string_list },
 	{ 0x0362, "MaxMediaWidth",			print_uint16d },
 	{ 0x0364, "MaxMediaLength",			print_uint16d },
 	{ 0x0366, "EnhancedLayoutSupport",		print_bool },
-	{ 0x0368, "RUIFormatsSupported",		print_string },
+	{ 0x0368, "RUIFormatsSupported",		print_string_list },
 	{ 0x0370, "ReferencePrintingRUISupported",	print_bool },
 	{ 0x0372, "DirectPrintingRUISupported",		print_bool },
 	{ 0x0374, "ReferencePrintingTopURL",		print_url },
@@ -281,7 +282,7 @@
 };
 
 attr_t rui_attrs[] = {	/* Reflected User Interface */
-	{ 0x0368, "RUIFormatsSupported",		print_string },
+	{ 0x0368, "RUIFormatsSupported",		print_string_list },
 	{ 0x0378, "PrinterAdminRUITopURL",		print_url },
 };
 
@@ -774,6 +775,31 @@
 }
 
 static void
+print_string_list(sdp_data_t *data)
+{
+	char *str, *ep;
+	size_t len, l;
+
+	if (!sdp_get_str(data, &str, &len))
+		return;
+
+	printf("\n");
+	while (len > 0) {
+		ep = memchr(str, (int)',', len);
+		if (ep == NULL) {
+			l = len;
+			len = 0;
+		} else {
+			l = (size_t)(ep - str);
+			len -= l + 1;
+			ep++;
+		}
+		printf("    %s\n", string_vis(VIS_CSTYLE, str, l));
+		str = ep;
+	}
+}
+
+static void
 print_url(sdp_data_t *data)
 {
 	char *url;

Reply via email to