root/source3/lib/util_reg.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. reg_type_lookup
  2. reg_pull_multi_sz

   1 /*
   2  * Unix SMB/CIFS implementation.
   3  * Registry helper routines
   4  * Copyright (C) Volker Lendecke 2006
   5  * 
   6  * This program is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License as published by the Free
   8  * Software Foundation; either version 3 of the License, or (at your option)
   9  * any later version.
  10  * 
  11  * This program is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  14  * more details.
  15  * 
  16  * You should have received a copy of the GNU General Public License along with
  17  * this program; if not, see <http://www.gnu.org/licenses/>.
  18  */
  19 
  20 #include "includes.h"
  21 
  22 #undef DBGC_CLASS
  23 #define DBGC_CLASS DBGC_REGISTRY
  24 
  25 extern REGISTRY_OPS smbconf_reg_ops;
  26 
  27 const char *reg_type_lookup(enum winreg_Type type)
     /* [<][>][^][v][top][bottom][index][help] */
  28 {
  29         const char *result;
  30 
  31         switch(type) {
  32         case REG_NONE:
  33                 result = "REG_NONE";
  34                 break;
  35         case REG_SZ:
  36                 result = "REG_SZ";
  37                 break;
  38         case REG_EXPAND_SZ:
  39                 result = "REG_EXPAND_SZ";
  40                 break;
  41         case REG_BINARY:
  42                 result = "REG_BINARY";
  43                 break;
  44         case REG_DWORD:
  45                 result = "REG_DWORD";
  46                 break;
  47         case REG_DWORD_BIG_ENDIAN:
  48                 result = "REG_DWORD_BIG_ENDIAN";
  49                 break;
  50         case REG_LINK:
  51                 result = "REG_LINK";
  52                 break;
  53         case REG_MULTI_SZ:
  54                 result = "REG_MULTI_SZ";
  55                 break;
  56         case REG_RESOURCE_LIST:
  57                 result = "REG_RESOURCE_LIST";
  58                 break;
  59         case REG_FULL_RESOURCE_DESCRIPTOR:
  60                 result = "REG_FULL_RESOURCE_DESCRIPTOR";
  61                 break;
  62         case REG_RESOURCE_REQUIREMENTS_LIST:
  63                 result = "REG_RESOURCE_REQUIREMENTS_LIST";
  64                 break;
  65         case REG_QWORD:
  66                 result = "REG_QWORD";
  67                 break;
  68         default:
  69                 result = "REG TYPE IS UNKNOWN";
  70                 break;
  71         }
  72         return result;
  73 }
  74 
  75 WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
     /* [<][>][^][v][top][bottom][index][help] */
  76                          uint32 *num_values, char ***values)
  77 {
  78         const smb_ucs2_t *p = (const smb_ucs2_t *)buf;
  79         *num_values = 0;
  80 
  81         /*
  82          * Make sure that a talloc context for the strings retrieved exists
  83          */
  84 
  85         if (!(*values = TALLOC_ARRAY(mem_ctx, char *, 1))) {
  86                 return WERR_NOMEM;
  87         }
  88 
  89         len /= 2;               /* buf is a set of UCS2 strings */
  90 
  91         while (len > 0) {
  92                 char *val;
  93                 size_t dstlen, thislen;
  94 
  95                 thislen = strnlen_w(p, len) + 1;
  96                 if (!convert_string_allocate(*values, CH_UTF16LE, CH_UNIX,
  97                         p, thislen*2, (void *)&val, &dstlen, true)) {
  98                         TALLOC_FREE(*values);
  99                         return WERR_NOMEM;
 100                 }
 101 
 102                 ADD_TO_ARRAY(*values, char *, val, values, num_values);
 103                 if (*values == NULL) {
 104                         return WERR_NOMEM;
 105                 }
 106 
 107                 p += thislen;
 108                 len -= thislen;
 109         }
 110 
 111         return WERR_OK;
 112 }

/* [<][>][^][v][top][bottom][index][help] */