[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: debconf client support in cdebconf



This is an unrelated patch to debconfclient.c.  I don't know if people
will like it, or if it just makes code harder to read.  The idea is that we
don't want to take up a lot of space with "INPUT", "GET" in a bunch of places
all around the tree. 


Here's the old way:
      client->command (client, "input", "high", "netcfg/get_hostname",
                       NULL);
      client->command (client, "go", NULL);
      client->command (client, "get", "netcfg/get_hostname", NULL);
      hostname = client->value;

Here's the new way:
      client->command (client, dbc_input, dbc_high, netcfg_get_hostname,
                       NULL);
      client->command (client, dbc_go, NULL);
      client->command (client, dbc_get, netcfg_get_hostname, NULL);
      hostname = client->value;

netcfg dropped from 2289 bytes to 2160 bytes after I replaced the strings in
this way.  The biggest savings is probably in removing the multiple uses of things like
"netcfg/get_hostname", but it doesn't help to have 200 copies of "get" either.  

We're saving a few bytes here and there, maybe it's worth it.

-David



Index: debconfclient.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/debconfclient.c,v
retrieving revision 1.1
diff -u -r1.1 debconfclient.c
--- debconfclient.c	2000/12/09 07:19:11	1.1
+++ debconfclient.c	2000/12/11 05:10:01
@@ -47,6 +47,82 @@
 #include <ctype.h>
 #include <sys/types.h>
 
+/* commands */
+const char dbc_version_str[]="VERSION";
+const char *dbc_version=dbc_version_str;
+
+const char dbc_capb_str[]="CAPB";
+const char *dbc_capb=dbc_capb_str;
+
+const char dbc_title_str[]="TITLE";
+const char *dbc_title=dbc_title_str;
+
+const char dbc_stop_str[]="STOP";
+const char *dbc_stop=dbc_stop_str;
+
+const char dbc_input_str[]="INPUT";
+const char *dbc_input=dbc_input_str;
+
+const char dbc_beginblock_str[]="BEGINBLOCK";
+const char *dbc_beginblock=dbc_beginblock_str;
+
+const char dbc_endblock_str[]="ENDBLOCK";
+const char *dbc_endblock=dbc_endblock_str;
+
+const char dbc_go_str[]="GO";
+const char *dbc_go=dbc_go_str;
+
+const char dbc_clear_str[]="CLEAR";
+const char *dbc_clear=dbc_clear_str;
+
+const char dbc_get_str[]="GET";
+const char *dbc_get=dbc_get_str;
+
+const char dbc_set_str[]="SET";
+const char *dbc_set=dbc_set_str;
+
+const char dbc_subst_str[]="SUBST";
+const char *dbc_subst=dbc_subst_str;
+
+const char dbc_fget_str[]="FGET";
+const char *dbc_fget=dbc_fget_str;
+
+const char dbc_fset_str[]="FSET";
+const char *dbc_fset=dbc_fset_str;
+
+const char dbc_metaget_str[]="METAGET";
+const char *dbc_metaget=dbc_metaget_str;
+
+const char dbc_register_str[]="REGISTER";
+const char *dbc_register=dbc_register_str;
+
+const char dbc_purge_str[]="PURGE";
+const char *dbc_purge=dbc_purge_str;
+
+/* priorities */
+const char dbc_low_str[]="LOW";
+const char *dbc_low=dbc_low_str;
+
+const char dbc_medium_str[]="MEDIUM";
+const char *dbc_medium=dbc_medium_str;
+
+const char dbc_high_str[]="HIGH";
+const char *dbc_high=dbc_high_str;
+
+const char dbc_critical_str[]="CRITICAL";
+const char *dbc_critical=dbc_critical_str;
+
+/* flags */
+
+const char dbc_true_str[]="true";
+const char *dbc_true=dbc_true_str;
+
+const char dbc_false_str[]="false";
+const char *dbc_false=dbc_false_str;
+
+const char dbc_seen_str[]="seen";
+const char *dbc_seen="seen";
+
 static int debconfclient_command(struct debconfclient *client, 
 	const char *command, ...)
 {
Index: debconfclient.h
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/debconfclient.h,v
retrieving revision 1.1
diff -u -r1.1 debconfclient.h
--- debconfclient.h	2000/12/09 07:19:11	1.1
+++ debconfclient.h	2000/12/11 05:10:08
@@ -1,6 +1,39 @@
 #ifndef _DEBCONFCLIENT_H_
 #define _DEBCONFCLIENT_H_
 
+/* commands */
+extern const char *dbc_version;
+extern const char *dbc_capb;
+extern const char *dbc_title;
+extern const char *dbc_stop;
+extern const char *dbc_input;
+extern const char *dbc_beginblock;
+extern const char *dbc_endblock;
+extern const char *dbc_go;
+extern const char *dbc_clear;
+extern const char *dbc_get;
+extern const char *dbc_set;
+extern const char *dbc_subst;
+extern const char *dbc_fget;
+extern const char *dbc_fset;
+extern const char *dbc_metaget;
+extern const char *dbc_register;
+extern const char *dbc_purge;
+
+/* priorities */
+extern const char *dbc_low;
+extern const char *dbc_medium;
+extern const char *dbc_high;
+extern const char *dbc_critical;
+
+/* flags */ 
+
+extern const char *dbc_true;
+extern const char *dbc_false;
+extern const char *dbc_seen;
+
+
+
 struct debconfclient {
 	char *value;
 




Reply to: