~ubuntu-branches/ubuntu/raring/boost-build/raring

« back to all changes in this revision

Viewing changes to jam_src/w32_getreg.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-08-06 00:38:31 UTC
  • mfrom: (4.1.1 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080806003831-zr65893244swds0b
Tags: 2.0-m12-2
* debian/rules: Do not install /etc/user-config.jam.
* debian/site-config.jam: New.  Install into /etc instead of empty
  example.  Closes: #493323.

* debian/control: Update homepage.  Update description.  Closes:
  #493510.  Update Standards-Version to 3.8.0; no changes.

* debian/compat: New.  Set compat level to 7.
* debian/rules: Remove DH_COMPAT setting.
* debian/control: Change debhelper build-dep to version >= 7.

* debian/control: Remove docbook-to-man, bison from build-deps.

* debian/rules: Clean up upstream source by removing debian/conffiles.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright Paul Lin 2003. Distributed under the Boost */
2
 
/* Software License, Version 1.0. (See accompanying */
3
 
/* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
 
1
/*
 
2
Copyright Paul Lin 2003. Copyright 2006 Bojan Resnik.
 
3
Distributed under the Boost Software License, Version 1.0. (See accompanying
 
4
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
5
*/
4
6
 
5
7
# include "jam.h"
6
8
 
15
17
# define WIN32_LEAN_AND_MEAN
16
18
# include <windows.h>
17
19
 
18
 
# define  MAX_REGISTRY_DATA_LENGTH  4096
 
20
# define  MAX_REGISTRY_DATA_LENGTH 4096
 
21
# define  MAX_REGISTRY_KEYNAME_LENGTH 256
 
22
# define  MAX_REGISTRY_VALUENAME_LENGTH 16384
19
23
 
20
24
typedef struct
21
25
{
33
37
    { 0, 0 }
34
38
};
35
39
 
 
40
static HKEY get_key(char const** path)
 
41
{
 
42
    const KeyMap *p;
 
43
 
 
44
    for (p = dlRootKeys; p->name; ++p)
 
45
    {
 
46
        int n = strlen(p->name);
 
47
        if (!strncmp(*path,p->name,n))
 
48
        {
 
49
            if ((*path)[n] == '\\' || (*path)[n] == 0)
 
50
            {
 
51
                *path += n + 1;
 
52
                break;
 
53
            }
 
54
        }
 
55
    }
 
56
 
 
57
    return p->value;
 
58
}
 
59
 
36
60
LIST*
37
61
builtin_system_registry(
38
62
    PARSE    *parse,
40
64
{
41
65
    char const* path = lol_get(frame->args, 0)->string;
42
66
    LIST* result = L0;
43
 
    HKEY key;
 
67
    HKEY key = get_key(&path);
44
68
    
45
 
    {
46
 
        const KeyMap *p;
47
 
        
48
 
        for (p = dlRootKeys; p->name; ++p)
49
 
        {
50
 
            int n = strlen(p->name);
51
 
            if (!strncmp(path,p->name,n))
52
 
            {
53
 
                if (path[n] == '\\' || path[n] == 0)
54
 
                {
55
 
                    path += n + 1;
56
 
                    break;
57
 
                }
58
 
            }
59
 
        }
60
 
        
61
 
        key = p->value;
62
 
    }
63
 
 
64
69
    if (
65
70
        key != 0
66
71
        && ERROR_SUCCESS == RegOpenKeyEx(key, path, 0, KEY_QUERY_VALUE, &key) 
125
130
    return  result;
126
131
}
127
132
 
 
133
static LIST* get_subkey_names(HKEY key, char const* path)
 
134
{
 
135
    LIST* result = 0;
 
136
    
 
137
    if ( ERROR_SUCCESS == 
 
138
         RegOpenKeyEx(key, path, 0, KEY_ENUMERATE_SUB_KEYS, &key) 
 
139
    )
 
140
    {
 
141
        char name[MAX_REGISTRY_KEYNAME_LENGTH];
 
142
        DWORD name_size = sizeof(name);
 
143
        DWORD index;
 
144
        FILETIME last_write_time;
 
145
 
 
146
        for ( index = 0; 
 
147
              ERROR_SUCCESS == RegEnumKeyEx(
 
148
                  key, index, name, &name_size, 0, 0, 0, &last_write_time);
 
149
              ++index, 
 
150
              name_size = sizeof(name)
 
151
        )
 
152
        {
 
153
            name[name_size] = 0;
 
154
            result = list_append(result, list_new(0, newstr(name)));
 
155
        }
 
156
        
 
157
        RegCloseKey(key);
 
158
    }
 
159
    
 
160
    return result;
 
161
}
 
162
 
 
163
static LIST* get_value_names(HKEY key, char const* path)
 
164
{
 
165
    LIST* result = 0;
 
166
    
 
167
    if ( ERROR_SUCCESS == RegOpenKeyEx(key, path, 0, KEY_QUERY_VALUE, &key) )
 
168
    {
 
169
        char name[MAX_REGISTRY_VALUENAME_LENGTH];
 
170
        DWORD name_size = sizeof(name);
 
171
        DWORD index;
 
172
 
 
173
        for ( index = 0; 
 
174
              ERROR_SUCCESS == RegEnumValue(
 
175
                  key, index, name, &name_size, 0, 0, 0, 0);
 
176
              ++index, 
 
177
              name_size = sizeof(name)
 
178
        )
 
179
        {
 
180
            name[name_size] = 0;
 
181
            result = list_append(result, list_new(0, newstr(name)));
 
182
        }
 
183
        
 
184
        RegCloseKey(key);
 
185
    }
 
186
    
 
187
    return result;
 
188
}
 
189
 
 
190
LIST*
 
191
builtin_system_registry_names(
 
192
    PARSE    *parse,
 
193
    FRAME    *frame )
 
194
{
 
195
    char const* path        = lol_get(frame->args, 0)->string;
 
196
    char const* result_type = lol_get(frame->args, 1)->string;
 
197
    
 
198
    HKEY key = get_key(&path);
 
199
 
 
200
    if ( !strcmp(result_type, "subkeys") )
 
201
        return get_subkey_names(key, path);
 
202
    if ( !strcmp(result_type, "values") )
 
203
        return get_value_names(key, path);
 
204
    return 0;
 
205
}
 
206
 
128
207
# endif