Mercurial > mplayer.hg
comparison loader/registry.c @ 7386:174e2a58b4cd
avifile sync - 95% cosmetics 5% bug
author | arpi |
---|---|
date | Fri, 13 Sep 2002 19:43:17 +0000 |
parents | a1d27234018f |
children | 692c4467da42 |
comparison
equal
deleted
inserted
replaced
7385:e2fcdd7608b1 | 7386:174e2a58b4cd |
---|---|
5 #include <fcntl.h> | 5 #include <fcntl.h> |
6 #include <unistd.h> | 6 #include <unistd.h> |
7 #include <pwd.h> | 7 #include <pwd.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <wine/winbase.h> | 10 #include "wine/winbase.h" |
11 #include <wine/winreg.h> | 11 #include "wine/winreg.h" |
12 #include <wine/winnt.h> | 12 #include "wine/winnt.h" |
13 #include <wine/winerror.h> | 13 #include "wine/winerror.h" |
14 | 14 |
15 #include "ext.h" | 15 #include "ext.h" |
16 #include "registry.h" | 16 #include "registry.h" |
17 | 17 |
18 //#undef TRACE | 18 //#undef TRACE |
208 } | 208 } |
209 return 0; | 209 return 0; |
210 } | 210 } |
211 static int generate_handle() | 211 static int generate_handle() |
212 { | 212 { |
213 static int zz=249; | 213 static unsigned int zz=249; |
214 zz++; | 214 zz++; |
215 while((zz==HKEY_LOCAL_MACHINE) || (zz==HKEY_CURRENT_USER)) | 215 while((zz==HKEY_LOCAL_MACHINE) || (zz==HKEY_CURRENT_USER)) |
216 zz++; | 216 zz++; |
217 return zz; | 217 return zz; |
218 } | 218 } |
279 //replacing old one | 279 //replacing old one |
280 { | 280 { |
281 free(v->value); | 281 free(v->value); |
282 free(v->name); | 282 free(v->name); |
283 } | 283 } |
284 TRACE("RegInsert '%s' %p v:%d len:%d\n", name, value, *(int*)value, len); | |
284 v->type=type; | 285 v->type=type; |
285 v->len=len; | 286 v->len=len; |
286 v->value=(char*)malloc(len); | 287 v->value=(char*)malloc(len); |
287 memcpy(v->value, value, len); | 288 memcpy(v->value, value, len); |
288 v->name=(char*)malloc(strlen(fullname)+1); | 289 v->name=(char*)malloc(strlen(fullname)+1); |
379 | 380 |
380 return 0; | 381 return 0; |
381 } | 382 } |
382 long RegCloseKey(long key) | 383 long RegCloseKey(long key) |
383 { | 384 { |
384 reg_handle_t *handle; | 385 reg_handle_t *handle; |
385 if(key==HKEY_LOCAL_MACHINE) | 386 if(key==(long)HKEY_LOCAL_MACHINE) |
386 return 0; | 387 return 0; |
387 if(key==HKEY_CURRENT_USER) | 388 if(key==(long)HKEY_CURRENT_USER) |
388 return 0; | 389 return 0; |
389 handle=find_handle(key); | 390 handle=find_handle(key); |
390 if(handle==0) | 391 if(handle==0) |
391 return 0; | 392 return 0; |
392 if(handle->prev) | 393 if(handle->prev) |
401 return 1; | 402 return 1; |
402 } | 403 } |
403 | 404 |
404 long RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count) | 405 long RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count) |
405 { | 406 { |
406 struct reg_value* t; | 407 struct reg_value* t; |
407 char* c; | 408 char* c; |
408 TRACE("Querying value %s\n", value); | 409 TRACE("Querying value %s\n", value); |
409 if(!regs) | 410 if(!regs) |
410 init_registry(); | 411 init_registry(); |
411 | 412 |
412 c=build_keyname(key, value); | 413 c=build_keyname(key, value); |
413 if(c==NULL) | 414 if (!c) |
414 return 1; | 415 return 1; |
415 t=find_value_by_name(c); | 416 t=find_value_by_name(c); |
416 free(c); | 417 free(c); |
417 if(t==0) | 418 if (t==0) |
418 return 2; | 419 return 2; |
419 if(type) | 420 if (type) |
420 *type=t->type; | 421 *type=t->type; |
421 if(data) | 422 if (data) |
422 { | 423 { |
423 memcpy(data, t->value, (t->len<*count)?t->len:*count); | 424 memcpy(data, t->value, (t->len<*count)?t->len:*count); |
424 TRACE("returning %d bytes: %d\n", t->len, *(int*)data); | 425 TRACE("returning %d bytes: %d\n", t->len, *(int*)data); |
425 } | 426 } |
426 if(*count<t->len) | 427 if(*count<t->len) |
427 { | 428 { |
428 *count=t->len; | 429 *count=t->len; |
429 return ERROR_MORE_DATA; | 430 return ERROR_MORE_DATA; |
430 } | 431 } |
431 else | 432 else |
432 { | 433 { |
433 *count=t->len; | 434 *count=t->len; |
434 } | 435 } |
435 return 0; | 436 return 0; |
436 } | 437 } |
437 long RegCreateKeyExA(long key, const char* name, long reserved, | 438 long RegCreateKeyExA(long key, const char* name, long reserved, |
438 void* classs, long options, long security, | 439 void* classs, long options, long security, |
439 void* sec_attr, int* newkey, int* status) | 440 void* sec_attr, int* newkey, int* status) |
440 { | 441 { |
441 reg_handle_t* t; | 442 reg_handle_t* t; |
442 char* fullname; | 443 char* fullname; |
443 struct reg_value* v; | 444 struct reg_value* v; |
444 // TRACE("Creating/Opening key %s\n", name); | 445 // TRACE("Creating/Opening key %s\n", name); |
445 TRACE("Creating/Opening key %s\n", name); | 446 if(!regs) |
446 if(!regs) | 447 init_registry(); |
447 init_registry(); | 448 |
448 | 449 fullname=build_keyname(key, name); |
449 fullname=build_keyname(key, name); | 450 if (!fullname) |
450 if(fullname==NULL) | 451 return 1; |
451 return 1; | 452 TRACE("Creating/Opening key %s\n", fullname); |
452 v=find_value_by_name(fullname); | 453 v=find_value_by_name(fullname); |
453 if(v==0) | 454 if(v==0) |
454 { | 455 { |
455 int qw=45708; | 456 int qw=45708; |
456 v=insert_reg_value(key, name, DIR, &qw, 4); | 457 v=insert_reg_value(key, name, DIR, &qw, 4); |
457 if (status) *status=REG_CREATED_NEW_KEY; | 458 if (status) *status=REG_CREATED_NEW_KEY; |
458 // return 0; | 459 // return 0; |
459 } | 460 } |
460 | 461 |
461 t=insert_handle(generate_handle(), fullname); | 462 t=insert_handle(generate_handle(), fullname); |
462 *newkey=t->handle; | 463 *newkey=t->handle; |
463 free(fullname); | 464 free(fullname); |
464 return 0; | 465 return 0; |
465 } | 466 } |
466 | 467 |
467 /* | 468 /* |
468 LONG RegEnumValue( | 469 LONG RegEnumValue( |
469 HKEY hKey, // handle to key to query | 470 HKEY hKey, // handle to key to query |
503 | 504 |
504 long RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size) | 505 long RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size) |
505 { | 506 { |
506 struct reg_value* t; | 507 struct reg_value* t; |
507 char* c; | 508 char* c; |
508 TRACE("Request to set value %s\n", name); | 509 TRACE("Request to set value %s %d\n", name, *(const int*)data); |
509 if(!regs) | 510 if(!regs) |
510 init_registry(); | 511 init_registry(); |
511 | 512 |
512 c=build_keyname(key, name); | 513 c=build_keyname(key, name); |
513 if(c==NULL) | 514 if(c==NULL) |