Remove some statics
authorVolker Lendecke <vl@sernet.de>
Sun, 25 Nov 2007 09:10:52 +0000 (10:10 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 27 Nov 2007 13:18:47 +0000 (14:18 +0100)
(This used to be commit 1fab16ffb888cd4ec18e52d9da33976a67a5d104)

source3/lib/display_sec.c
source3/lib/util_uuid.c
source3/libads/disp_sec.c
source3/libads/ldap.c
source3/libsmb/dsgetdcname.c
source3/printing/nt_printing.c
source3/rpc_server/srv_spoolss_nt.c
source3/rpcclient/cmd_lsarpc.c
source3/utils/net_ads.c

index 8e92c84f3cd53a750fd72bfdc6f9a86b588b7d55..caa13a6a5ee5c5900dbbeaa65607e6b8ff1ba43a 100644 (file)
@@ -97,12 +97,12 @@ static void disp_sec_ace_object(struct security_ace_object *object)
 {
        if (object->flags & SEC_ACE_OBJECT_PRESENT) {
                printf("Object type: SEC_ACE_OBJECT_PRESENT\n");
-               printf("Object GUID: %s\n", smb_uuid_string_static(
+               printf("Object GUID: %s\n", smb_uuid_string(talloc_tos(),
                        object->type.type));
        }
        if (object->flags & SEC_ACE_OBJECT_INHERITED_PRESENT) {
                printf("Object type: SEC_ACE_OBJECT_INHERITED_PRESENT\n");
-               printf("Object GUID: %s\n", smb_uuid_string_static(
+               printf("Object GUID: %s\n", smb_uuid_string(talloc_tos(), 
                        object->inherited_type.inherited_type));
        }
 }
index 606bfd2147c25f6ad56e4efb9da7dfd5768a016c..36c04e9b8492868443df6490564a9699655c9416 100644 (file)
@@ -44,14 +44,6 @@ void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu)
        memcpy(uu->node, in.info+10, 6);
 }
 
-struct GUID smb_uuid_unpack_static(const UUID_FLAT in)
-{
-       static struct GUID uu;
-
-       smb_uuid_unpack(in, &uu);
-       return uu;
-}
-
 void smb_uuid_generate_random(struct GUID *uu)
 {
        UUID_FLAT tmp;
@@ -63,30 +55,20 @@ void smb_uuid_generate_random(struct GUID *uu)
        uu->time_hi_and_version = (uu->time_hi_and_version & 0x0FFF) | 0x4000;
 }
 
-char *smb_uuid_to_string(const struct GUID uu)
-{
-       char *out;
-
-       asprintf(&out, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-                uu.time_low, uu.time_mid, uu.time_hi_and_version,
-                uu.clock_seq[0], uu.clock_seq[1],
-                uu.node[0], uu.node[1], uu.node[2], 
-                uu.node[3], uu.node[4], uu.node[5]);
-
-       return out;
-}
-
-const char *smb_uuid_string_static(const struct GUID uu)
+const char *smb_uuid_string(TALLOC_CTX *mem_ctx, const struct GUID uu)
 {
-       static char out[37];
-
-       slprintf(out, sizeof(out), 
-                "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-                uu.time_low, uu.time_mid, uu.time_hi_and_version,
-                uu.clock_seq[0], uu.clock_seq[1],
-                uu.node[0], uu.node[1], uu.node[2], 
-                uu.node[3], uu.node[4], uu.node[5]);
-       return out;
+       char *result;
+
+       result = talloc_asprintf(
+               mem_ctx,
+               "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+               uu.time_low, uu.time_mid, uu.time_hi_and_version,
+               uu.clock_seq[0], uu.clock_seq[1],
+               uu.node[0], uu.node[1], uu.node[2], 
+               uu.node[3], uu.node[4], uu.node[5]);
+
+       SMB_ASSERT(result != NULL);
+       return result;
 }
 
 bool smb_string_to_uuid(const char *in, struct GUID* uu)
index e85809635f13d9b39ccdf1ebea618c9eb435f4e4..e211ef69e44e3d32c5ce96ca373b5107e0c503ce 100644 (file)
@@ -114,14 +114,14 @@ static void ads_disp_sec_ace_object(ADS_STRUCT *ads,
 {
        if (object->flags & SEC_ACE_OBJECT_PRESENT) {
                printf("Object type: SEC_ACE_OBJECT_PRESENT\n");
-               printf("Object GUID: %s (%s)\n", smb_uuid_string_static(
+               printf("Object GUID: %s (%s)\n", smb_uuid_string(mem_ctx, 
                        object->type.type), 
                        ads_interprete_guid_from_object(ads, mem_ctx, 
                                &object->type.type));
        }
        if (object->flags & SEC_ACE_OBJECT_INHERITED_PRESENT) {
                printf("Object type: SEC_ACE_OBJECT_INHERITED_PRESENT\n");
-               printf("Object GUID: %s (%s)\n", smb_uuid_string_static(
+               printf("Object GUID: %s (%s)\n", smb_uuid_string(mem_ctx,
                        object->inherited_type.inherited_type),
                        ads_interprete_guid_from_object(ads, mem_ctx, 
                                &object->inherited_type.inherited_type));
index 01f6b00c0253def07dfbee31f5daadb91c9b8c3a..533aa3026f565480da9941f6ee4596b4a9fa3e28 100644 (file)
@@ -1828,11 +1828,14 @@ static void dump_binary(ADS_STRUCT *ads, const char *field, struct berval **valu
 static void dump_guid(ADS_STRUCT *ads, const char *field, struct berval **values)
 {
        int i;
-       UUID_FLAT guid;
        for (i=0; values[i]; i++) {
+
+               UUID_FLAT guid;
+               struct GUID tmp;
+
                memcpy(guid.info, values[i]->bv_val, sizeof(guid.info));
-               printf("%s: %s\n", field, 
-                      smb_uuid_string_static(smb_uuid_unpack_static(guid)));
+               smb_uuid_unpack(guid, &tmp);
+               printf("%s: %s\n", field, smb_uuid_string(talloc_tos(), tmp));
        }
 }
 
@@ -3429,7 +3432,7 @@ const char *ads_get_extended_right_name_by_guid(ADS_STRUCT *ads,
        }
 
        expr = talloc_asprintf(mem_ctx, "(rightsGuid=%s)", 
-                              smb_uuid_string_static(*rights_guid));
+                              smb_uuid_string(mem_ctx, *rights_guid));
        if (!expr) {
                goto done;
        }
index f6c32730844cad4fcb35f116505946f4651c16c4..b0870e249e8e2db1f9c8580ba453e4bcc93f64bb 100644 (file)
@@ -800,7 +800,7 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx,
                dc_address_type = ADS_NETBIOS_ADDRESS;
        }
        NT_STATUS_HAVE_NO_MEMORY(dc_address);
-       dc_guid = smb_uuid_unpack_static(r.guid);
+       smb_uuid_unpack(r.guid, &dc_guid);
 
        if (r.forest) {
                dc_flags |= ADS_DNS_FOREST;
index bbe312ca277a4308d0f187998b1ab6e1ddf7eaba..c55f9f1f915d4fbf1ff9380a26fe96016876b047 100644 (file)
@@ -3208,7 +3208,8 @@ static void store_printer_guid(NT_PRINTER_INFO_LEVEL_2 *info2,
           Vista to whine */
 
        ZERO_STRUCT( unistr_guid );     
-       init_unistr2( &unistr_guid, smb_uuid_string_static(guid),
+       
+       init_unistr2( &unistr_guid, smb_uuid_string(talloc_tos(), guid),
                      UNI_STR_TERMINATE );
 
        regval_ctr_addvalue(ctr, "objectGUID", REG_SZ, 
@@ -3821,7 +3822,8 @@ static int unpack_values(NT_PRINTER_DATA *printer_data, const uint8 *buf, int bu
 
                        memcpy( &guid, data_p, sizeof(struct GUID) );
 
-                       init_unistr2( &unistr_guid, smb_uuid_string_static(guid), 
+                       init_unistr2( &unistr_guid,
+                                     smb_uuid_string(talloc_tos(), guid), 
                                      UNI_STR_TERMINATE );
 
                        regval_ctr_addvalue( printer_data->keys[key_index].values, 
index fe7a12940ee331c01f55a91de5a1adb39efc93c7..d49731272fb251b861ba36cb4b4179038b24ff6e 100644 (file)
@@ -4376,7 +4376,8 @@ static bool construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *p
        struct GUID guid; 
        
        if (is_printer_published(print_hnd, snum, &guid)) {
-               asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid));
+               asprintf(&guid_str, "{%s}",
+                        smb_uuid_string(talloc_tos(), guid));
                strupper_m(guid_str);
                init_unistr(&printer->guid, guid_str);
                printer->action = SPOOL_DS_PUBLISH;
index 31a8e2bdfd130ba1d4682eb3c0fd30c963baef08..fd7b8762ab5e417474b793781923708e7ef2a602 100644 (file)
@@ -126,7 +126,8 @@ static void display_query_info_12(DOM_QUERY_12 d)
        d_printf("Domain DNS Name: %s\n", dns_dom_name);
        d_printf("Domain Forest Name: %s\n", forest_name);
        d_printf("Domain Sid: %s\n", sid_string_static(&d.dom_sid.sid));
-       d_printf("Domain GUID: %s\n", smb_uuid_string_static(d.dom_guid));
+       d_printf("Domain GUID: %s\n", smb_uuid_string(talloc_tos(),
+                                                     d.dom_guid));
 
 }
 
index 81b13ba76ecece7ba747127eb096e57d66deeb55..ac8f79435492817603727a4b72b350314c725b52 100644 (file)
@@ -80,6 +80,7 @@ static int net_ads_cldap_netlogon(ADS_STRUCT *ads)
 {
        char addr[INET6_ADDRSTRLEN];
        struct cldap_netlogon_reply reply;
+       struct GUID tmp_guid;
 
        print_sockaddr(addr, sizeof(addr), &ads->ldap.ss);
        if ( !ads_cldap_netlogon(addr, ads->server.realm, &reply ) ) {
@@ -102,8 +103,10 @@ static int net_ads_cldap_netlogon(ADS_STRUCT *ads)
                d_printf("0x%x\n", reply.type);
                break;
        }
-       d_printf("GUID: %s\n",
-                smb_uuid_string_static(smb_uuid_unpack_static(reply.guid)));
+
+       smb_uuid_unpack(reply.guid, &tmp_guid);
+       d_printf("GUID: %s\n", smb_uuid_string(talloc_tos(), tmp_guid));
+
        d_printf("Flags:\n"
                 "\tIs a PDC:                                   %s\n"
                 "\tIs a GC of the forest:                      %s\n"