s3-spoolss: rework some form functions and add form_by_string functions.
authorGünther Deschner <gd@samba.org>
Sat, 15 Nov 2008 21:17:23 +0000 (22:17 +0100)
committerGünther Deschner <gd@samba.org>
Sat, 7 Feb 2009 00:52:28 +0000 (01:52 +0100)
Guenther

source3/include/proto.h
source3/printing/nt_printing.c

index aae8dbfd54f286f5d9a555c5690370e83b1a14cb..ed875b1caaab9fffed3132d4b1fbd64eba85e275 100644 (file)
@@ -4788,10 +4788,12 @@ uint32 update_c_setprinter(bool initialize);
 uint32 get_c_setprinter(void);
 int get_builtin_ntforms(nt_forms_struct **list);
 bool get_a_builtin_ntform(UNISTR2 *uni_formname,nt_forms_struct *form);
+bool get_a_builtin_ntform_by_string(const char *form_name, nt_forms_struct *form);
 int get_ntforms(nt_forms_struct **list);
 int write_ntforms(nt_forms_struct **list, int number);
 bool add_a_form(nt_forms_struct **list, const FORM *form, int *count);
 bool delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, WERROR *ret);
+bool delete_a_form_by_string(nt_forms_struct **list, const char *del_name, int *count, WERROR *ret);
 void update_a_form(nt_forms_struct **list, const FORM *form, int count);
 int get_ntdrivers(fstring **list, const char *architecture, uint32 version);
 const char *get_short_archi(const char *long_archi);
index bfbc35f3d3b0c9307a066f9583338fc966de5b11..da31945ed0f11b2c0dfedb913f8856d1b101c002 100644 (file)
@@ -773,11 +773,9 @@ int get_builtin_ntforms(nt_forms_struct **list)
  get a builtin form struct
 ****************************************************************************/
 
-bool get_a_builtin_ntform(UNISTR2 *uni_formname,nt_forms_struct *form)
+bool get_a_builtin_ntform_by_string(const char *form_name, nt_forms_struct *form)
 {
        int i,count;
-       fstring form_name;
-       unistr2_to_ascii(form_name, uni_formname, sizeof(form_name));
        DEBUGADD(6,("Looking for builtin form %s \n", form_name));
        count = sizeof(default_forms) / sizeof(default_forms[0]);
        for (i=0;i<count;i++) {
@@ -791,6 +789,13 @@ bool get_a_builtin_ntform(UNISTR2 *uni_formname,nt_forms_struct *form)
        return (i !=count);
 }
 
+bool get_a_builtin_ntform(UNISTR2 *uni_formname,nt_forms_struct *form)
+{
+       fstring form_name;
+       unistr2_to_ascii(form_name, uni_formname, sizeof(form_name));
+       return get_a_builtin_ntform_by_string(form_name, form);
+}
+
 /****************************************************************************
  get a form struct list.
 ****************************************************************************/
@@ -937,25 +942,22 @@ bool add_a_form(nt_forms_struct **list, const FORM *form, int *count)
  Delete a named form struct.
 ****************************************************************************/
 
-bool delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, WERROR *ret)
+bool delete_a_form_by_string(nt_forms_struct **list, const char *del_name, int *count, WERROR *ret)
 {
        char *key = NULL;
        int n=0;
-       fstring form_name;
 
        *ret = WERR_OK;
 
-       unistr2_to_ascii(form_name, del_name, sizeof(form_name));
-
        for (n=0; n<*count; n++) {
-               if (!strncmp((*list)[n].name, form_name, strlen(form_name))) {
-                       DEBUG(103, ("delete_a_form, [%s] in list\n", form_name));
+               if (!strncmp((*list)[n].name, del_name, strlen(del_name))) {
+                       DEBUG(103, ("delete_a_form, [%s] in list\n", del_name));
                        break;
                }
        }
 
        if (n == *count) {
-               DEBUG(10,("delete_a_form, [%s] not found\n", form_name));
+               DEBUG(10,("delete_a_form, [%s] not found\n", del_name));
                *ret = WERR_INVALID_PARAM;
                return False;
        }
@@ -973,6 +975,15 @@ bool delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, WERROR
        return true;
 }
 
+bool delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, WERROR *ret)
+{
+       fstring form_name;
+
+       unistr2_to_ascii(form_name, del_name, sizeof(form_name));
+
+       return delete_a_form_by_string(list, form_name, count, ret);
+}
+
 /****************************************************************************
  Update a form struct.
 ****************************************************************************/