]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r5891: Make enum- and getform use the same form_display-function.
authorGünther Deschner <gd@samba.org>
Fri, 18 Mar 2005 23:48:46 +0000 (23:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:07 +0000 (10:56 -0500)
Guenther

source/rpcclient/cmd_spoolss.c

index 49f22b3654647bf8b2ce0f7395959a3910002459..60b1aaa6b87dd02e5dd94238948570428a45d7e4 100644 (file)
@@ -1813,6 +1813,38 @@ static WERROR cmd_spoolss_setform(struct cli_state *cli, TALLOC_CTX *mem_ctx,
        return werror;
 }
 
+static const char *get_form_flag(int form_flag)
+{
+       switch (form_flag) {
+       case FORM_USER:
+               return "FORM_USER";
+       case FORM_BUILTIN:
+               return "FORM_BUILTIN";
+       case FORM_PRINTER:
+               return "FORM_PRINTER";
+       default:
+               return "unknown";
+       }
+}
+
+static void display_form(FORM_1 *form)
+{
+       fstring form_name = "";
+
+       if (form->name.buffer)
+               rpcstr_pull(form_name, form->name.buffer,
+                           sizeof(form_name), -1, STR_TERMINATE);
+
+       printf("%s\n" \
+               "\tflag: %s (%d)\n" \
+               "\twidth: %d, length: %d\n" \
+               "\tleft: %d, right: %d, top: %d, bottom: %d\n\n", 
+               form_name, get_form_flag(form->flag), form->flag,
+               form->width, form->length, 
+               form->left, form->right, 
+               form->top, form->bottom);
+}
+
 /* Get a form */
 
 static WERROR cmd_spoolss_getform(struct cli_state *cli, TALLOC_CTX *mem_ctx,
@@ -1847,7 +1879,7 @@ static WERROR cmd_spoolss_getform(struct cli_state *cli, TALLOC_CTX *mem_ctx,
 
        got_handle = True;
 
-       /* Set the form */
+       /* Get the form */
 
        werror = cli_spoolss_getform(cli, mem_ctx, 0, &needed,
                                     &handle, argv[2], 1, &form);
@@ -1859,12 +1891,7 @@ static WERROR cmd_spoolss_getform(struct cli_state *cli, TALLOC_CTX *mem_ctx,
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
-       printf("width: %d\n", form.width);
-       printf("length: %d\n", form.length);
-       printf("left: %d\n", form.left);
-       printf("top: %d\n", form.top);
-       printf("right: %d\n", form.right);
-       printf("bottom: %d\n", form.bottom);
+       display_form(&form);
 
  done:
        if (got_handle)
@@ -1925,20 +1952,6 @@ static WERROR cmd_spoolss_deleteform(struct cli_state *cli,
 
 /* Enumerate forms */
 
-static const char *get_form_flag(int form_flag)
-{
-       switch (form_flag) {
-       case FORM_USER:
-               return "FORM_USER";
-       case FORM_BUILTIN:
-               return "FORM_BUILTIN";
-       case FORM_PRINTER:
-               return "FORM_PRINTER";
-       default:
-               return "unknown";
-       }
-}
-
 static WERROR cmd_spoolss_enum_forms(struct cli_state *cli, 
                                       TALLOC_CTX *mem_ctx, int argc, 
                                       const char **argv)
@@ -1988,20 +2001,9 @@ static WERROR cmd_spoolss_enum_forms(struct cli_state *cli,
        /* Display output */
 
        for (i = 0; i < num_forms; i++) {
-               fstring form_name;
-
-               if (forms[i].name.buffer)
-                       rpcstr_pull(form_name, forms[i].name.buffer,
-                                   sizeof(form_name), -1, STR_TERMINATE);
-
-               printf("%s\n" \
-                       "\tflag: %s (%d)\n" \
-                       "\twidth: %d, length: %d\n" \
-                       "\tleft: %d, right: %d, top: %d, bottom: %d\n\n", 
-                       form_name, get_form_flag(forms[i].flag), forms[i].flag,
-                       forms[i].width, forms[i].length, 
-                       forms[i].left, forms[i].right, 
-                       forms[i].top, forms[i].bottom);
+
+               display_form(&forms[i]);
+
        }
 
  done: