Update of /cvsroot/monetdb/sql/src/backends/monet5/merovingian
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv17152

Modified Files:
        Makefile.ag monetdb.c 
Removed Files:
        monetdb_get.c 
Log Message:
move monetdb_get into monetdb.c again

U Makefile.ag
Index: Makefile.ag
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/Makefile.ag,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Makefile.ag 16 Sep 2009 09:12:03 -0000      1.13
+++ Makefile.ag 18 Sep 2009 12:22:53 -0000      1.14
@@ -23,7 +23,7 @@
        $(MONETDB5_INCS) \
        $(MONETDB_INCS)
 
-MEROVINGIAN_TMP_SUBS = \
+MEROVINGIAN_SUBS = \
        merovingian_client.c \
        merovingian_connections.c \
        merovingian_controlrunner.c \
@@ -32,17 +32,13 @@
        merovingian_handlers.c \
        merovingian_proxy.c
 
-MONETDB_TMP_SUBS = \
-       monetdb_get.c
-
 EXTRA_DIST = $(man_MANS) \
        utils.h \
        properties.h \
        glob.h \
        database.h \
        control.h \
-       $(MEROVINGIAN_TMP_SUBS) \
-       $(MONETDB_TMP_SUBS)
+       $(MEROVINGIAN_SUBS)
 
 lib_meroutil = {
        NOINST

--- monetdb_get.c DELETED ---

U monetdb.c
Index: monetdb.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- monetdb.c   18 Sep 2009 11:16:12 -0000      1.54
+++ monetdb.c   18 Sep 2009 12:22:53 -0000      1.55
@@ -978,7 +978,158 @@
        exit(state);
 }
 
-#include "monetdb_get.c"
+static void
+command_get(int argc, char *argv[], confkeyval *defprops)
+{
+       char doall = 1;
+       char *p;
+       char *property = NULL;
+       err e;
+       int i;
+       sabdb *orig, *stats;
+       int twidth = TERMWIDTH;
+       char *source, *value;
+       confkeyval *kv, *props = getDefaultProps();
+
+       if (argc == 1) {
+               /* print help message for this command */
+               command_help(2, &argv[-1]);
+               exit(1);
+       } else if (argc == 0) {
+               exit(2);
+       }
+
+       /* time to collect some option flags */
+       for (i = 1; i < argc; i++) {
+               if (argv[i][0] == '-') {
+                       for (p = argv[i] + 1; *p != '\0'; p++) {
+                               switch (*p) {
+                                       case '-':
+                                               if (p[1] == '\0') {
+                                                       if (argc - 1 > i) 
+                                                               doall = 0;
+                                                       i = argc;
+                                                       break;
+                                               }
+                                       default:
+                                               fprintf(stderr, "get: unknown 
option: -%c\n", *p);
+                                               command_help(2, &argv[-1]);
+                                               exit(1);
+                                       break;
+                               }
+                       }
+                       /* make this option no longer available, for easy use
+                        * lateron */
+                       argv[i] = NULL;
+               } else if (property == NULL) {
+                       /* first non-option is property, rest is database */
+                       property = argv[i];
+                       argv[i] = NULL;
+                       if (strcmp(property, "all") == 0) {
+                               /* die hard leak (can't use constant, strtok 
modifies
+                                * (and hence crashes)) */
+                               property = 
GDKstrdup("name,forward,shared,nthreads,master");
+                       }
+               } else {
+                       doall = 0;
+               }
+       }
+
+       if (property == NULL) {
+               fprintf(stderr, "get: need a property argument\n");
+               command_help(2, &argv[-1]);
+               exit(1);
+       }
+
+       if (doall == 1) {
+               /* don't even look at the arguments, because we are instructed
+                * to list all known databases */
+               if ((e = SABAOTHgetStatus(&orig, NULL)) != MAL_SUCCEED) {
+                       fprintf(stderr, "get: internal error: %s\n", e);
+                       GDKfree(e);
+                       exit(2);
+               }
+       } else {
+               sabdb *w = NULL;
+               orig = NULL;
+               for (i = 1; i < argc; i++) {
+                       if (argv[i] != NULL) {
+                               if ((e = SABAOTHgetStatus(&stats, argv[i])) != 
MAL_SUCCEED) {
+                                       fprintf(stderr, "get: internal error: 
%s\n", e);
+                                       GDKfree(e);
+                                       exit(2);
+                               }
+
+                               if (stats == NULL) {
+                                       fprintf(stderr, "get: no such database: 
%s\n", argv[i]);
+                                       argv[i] = NULL;
+                               } else {
+                                       if (orig == NULL) {
+                                               orig = stats;
+                                               w = stats;
+                                       } else {
+                                               w = w->next = stats;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /* name = 15 */
+       /* prop = 8 */
+       /* source = 7 */
+       twidth -= 15 - 2 - 8 - 2 - 7 - 2;
+       if (twidth < 6)
+               twidth = 6;
+       printf("     name          prop     source           value\n");
+       while ((p = strtok(property, ",")) != NULL) {
+               property = NULL;
+               stats = orig;
+               while (stats != NULL) {
+                       /* special virtual case */
+                       if (strcmp(p, "name") == 0) {
+                               source = "-";
+                               value = stats->dbname;
+                       } else {
+                               if (mero_running == 1) {
+                                       char *buf;
+                                       e = control_send(&buf, mero_control, 
-1, stats->dbname, "get", 1);
+                                       if (e != NULL) {
+                                               fprintf(stderr, "get: internal 
error: %s\n", e);
+                                               free(e);
+                                               exit(2);
+                                       }
+                                       readPropsBuf(props, buf);
+                                       free(buf);
+                               } else {
+                                       readProps(props, stats->path);
+                               }
+                               kv = findConfKey(props, p);
+                               if (kv == NULL) {
+                                       fprintf(stderr, "get: no such property: 
%s\n", p);
+                                       stats = NULL;
+                                       continue;
+                               }
+                               if (kv->val == NULL) {
+                                       kv = findConfKey(defprops, p);
+                                       source = "default";
+                                       value = kv != NULL && kv->val != NULL ? 
kv->val : "<unknown>";
+                               } else {
+                                       source = "local";
+                                       value = kv->val;
+                               }
+                       }
+                       printf("%-15s  %-8s  %-7s  %s\n",
+                                       stats->dbname, p, source, value);
+                       freeConfFile(props);
+                       stats = stats->next;
+               }
+       }
+
+       if (orig != NULL)
+               SABAOTHfreeStatus(&orig);
+       GDKfree(props);
+}
 
 static void
 command_create(int argc, char *argv[])


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to