help-gnats
[Top][All Lists]
Advanced

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

[PATCH] Need gnatsd command to retrieve multienum separators


From: Yngve Svendsen
Subject: [PATCH] Need gnatsd command to retrieve multienum separators
Date: Wed, 17 Oct 2001 15:16:32 +0200

At 13:53 17.10.2001 +0200, Yngve Svendsen wrote:
We need a gnatsd command which retrieves the the field separators for a given multienum field. Clients such as Gnatsweb need to know how to submit a legally separated string of values for such fields.

I suggest that we implement a command
FSEP field
which returns the field separators as set by the separators keyword in the field definition in the dbconfig file.

Anyone care to comment?

Yes, I would :)

The following clutch of patches implements an FSEP command as described above.

- Yngve



Index: cmds.c
===================================================================
RCS file: /cvs/gnats/gnats/gnats/cmds.c,v
retrieving revision 1.61
diff -u -p -r1.61 cmds.c
--- cmds.c      2001/10/14 20:32:22     1.61
+++ cmds.c      2001/10/17 13:07:21
@@ -1529,6 +1529,45 @@ GNATS_fdsc (int ac, char **av)
 }

 void
+GNATS_fsep (int ac, char **av)
+{
+  int x;
+
+  if (ac < 1)
+    {
+      chk_nargs (ac, "field name");
+      return;
+    }
+  for (x = 0; x < ac; x++)
+    {
+      char contchar = (x < (ac - 1)) ? '-' : ' ';
+      FieldIndex fnum = find_field_index (currentDatabase, av[x]);
+      if (fnum != InvalidFieldIndex
+                 && fieldDefForIndex (fnum)->datatype == MultiEnum)
+               {
+ const char *sep = fieldDefForIndex (fnum)->multiEnumSeparator;
+
+                 if (sep == NULL)
+                       {
+                         sep = ": ";
+                       }
+
+                 printf ("%d%c '%s'\r\n", CODE_INFORMATION, contchar, sep);
+               }
+         else if (fieldDefForIndex (fnum)->datatype != MultiEnum)
+               {
+                 printf ("%d%cField `%s' not of type MultiEnum\r\n",
+                                 CODE_TYPE_NOT_MULTIENUM, contchar, av[x]);
+               }
+      else
+               {
+                 printf ("%d%cNo such field as `%s'\r\n",
+                                 CODE_INVALID_FIELD_NAME, contchar, av[x]);
+               }
+    }
+}
+
+void
 GNATS_fvld (int ac, char **av)
 {
   FieldIndex fnum;
@@ -1677,6 +1716,10 @@ GNATS_help (int ac ATTRIBUTE_UNUSED, cha
          CODE_INFORMATION);
printf ("%d- FDSC <field> return the description of <field>\r\n",
          CODE_INFORMATION);
+ printf ("%d- FSEP <field> return the field separators for the\r\n",
+                 CODE_INFORMATION);
+  printf ("%d-                           MultiEnum field <field>\r\n",
+                 CODE_INFORMATION);
printf ("%d- FVLD <field> return a string or regexp describing the\r\n",
          CODE_INFORMATION);
   printf ("%d-                           legal values for <field>\r\n",
Index: gnatsd.c
===================================================================
RCS file: /cvs/gnats/gnats/gnats/gnatsd.c,v
retrieving revision 1.42
diff -u -p -r1.42 gnatsd.c
--- gnatsd.c    2001/10/14 20:32:22     1.42
+++ gnatsd.c    2001/10/17 13:07:21
@@ -143,6 +143,8 @@ static Command cmds[] =
   { "FTYP", GNATS_ftyp, ACCESS_VIEW, FALSE },
   /* Return a human-readable description of the field. */
   { "FDSC", GNATS_fdsc, ACCESS_VIEW, FALSE },
+  /* Return the separators for field values. */
+  { "FSEP", GNATS_fsep, ACCESS_VIEW, FALSE },
   /* Return either a regexp that describes the valid values for the
      specified field, or a list of valid values (for an enum field). */
   { "FVLD", GNATS_fvld, ACCESS_VIEW, TRUE },
Index: gnatsd.h
===================================================================
RCS file: /cvs/gnats/gnats/gnats/gnatsd.h,v
retrieving revision 1.25
diff -u -p -r1.25 gnatsd.h
--- gnatsd.h    2001/10/14 20:32:22     1.25
+++ gnatsd.h    2001/10/17 13:07:21
@@ -101,6 +101,7 @@ extern void GNATS_help (int ac, char **a
 extern void GNATS_expr (int ac, char **av);
 extern void GNATS_ftyp (int ac, char **av);
 extern void GNATS_fdsc (int ac, char **av);
+extern void GNATS_fsep (int ac, char **av);
 extern void GNATS_fvld (int ac, char **av);
 extern void GNATS_admv (int ac, char **av);
 extern void GNATS_editaddr (int ac, char **av);
Index: pcodes.h
===================================================================
RCS file: /cvs/gnats/gnats/gnats/pcodes.h,v
retrieving revision 1.9
diff -u -p -r1.9 pcodes.h
--- pcodes.h    2000/03/17 04:31:08     1.9
+++ pcodes.h    2001/10/17 13:07:21
@@ -52,6 +52,7 @@ Software Foundation, 59 Temple Place - S
 #define CODE_NO_KERBEROS               420
 #define CODE_AUTH_TYPE_UNSUP           421
 #define CODE_NO_ACCESS                 422
+#define CODE_TYPE_NOT_MULTIENUM        423
 #define CODE_LOCKED_PR                 430
 #define CODE_GNATS_LOCKED              431
 #define CODE_GNATS_NOT_LOCKED          432


reply via email to

[Prev in Thread] Current Thread [Next in Thread]