static char *strip_printers_prefix(const char *key) { char *subkeypath = NULL; char *path = NULL; TALLOC_CTX *ctx = talloc_tos(); path = talloc_strdup(ctx, key); if (!path) { return NULL; } path = normalize_reg_path(ctx, path); if (!path) { return NULL; } /* normalizing the path does not change length, just key delimiters and case */ if (strncmp(path, KEY_WINNT_PRINTERS, strlen(KEY_WINNT_PRINTERS)) == 0) { subkeypath = reg_remaining_path(ctx, key + strlen(KEY_WINNT_PRINTERS)); } else { subkeypath = reg_remaining_path(ctx, key + strlen(KEY_CONTROL_PRINTERS)); } TALLOC_FREE(path); return subkeypath; }
static char* strip_printers_prefix( const char *key ) { char *subkeypath; pstring path; pstrcpy( path, key ); normalize_reg_path( path ); /* normalizing the path does not change length, just key delimiters and case */ if ( strncmp( path, KEY_WINNT_PRINTERS, strlen(KEY_WINNT_PRINTERS) ) == 0 ) subkeypath = reg_remaining_path( key + strlen(KEY_WINNT_PRINTERS) ); else subkeypath = reg_remaining_path( key + strlen(KEY_CONTROL_PRINTERS) ); return subkeypath; }
static int key_forms_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys ) { char *p = reg_remaining_path( key + strlen(KEY_FORMS) ); /* no keys below Forms */ if ( p ) return -1; return 0; }
static int key_forms_fetch_keys(const char *key, struct regsubkey_ctr *subkeys) { char *p = reg_remaining_path(talloc_tos(), key + strlen(KEY_FORMS)); /* no keys below Forms */ if (p) { return -1; } return 0; }
static int key_driver_fetch_values( const char *key, REGVAL_CTR *values ) { char *keystr; pstring subkey; DEBUG(8,("key_driver_fetch_values: Enter key => [%s]\n", key ? key : "NULL")); /* no values in the Environments key */ if ( !(keystr = reg_remaining_path( key + strlen(KEY_ENVIRONMENTS) )) ) return 0; pstrcpy( subkey, keystr); /* pass off to handle subkeys */ return driver_arch_fetch_values( subkey, values ); }
static int key_driver_fetch_values( const char *key, REGVAL_CTR *values ) { char *keystr = NULL; char *subkey = NULL; TALLOC_CTX *ctx = talloc_tos(); DEBUG(8,("key_driver_fetch_values: Enter key => [%s]\n", key ? key : "NULL")); /* no values in the Environments key */ if (!(keystr = reg_remaining_path(ctx, key + strlen(KEY_ENVIRONMENTS)))) return 0; subkey = talloc_strdup(ctx, keystr); if (!subkey) { return 0; } /* pass off to handle subkeys */ return driver_arch_fetch_values( subkey, values ); }
static int key_driver_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys ) { const char *environments[] = { "Windows 4.0", "Windows NT x86", "Windows NT R4000", "Windows NT Alpha_AXP", "Windows NT PowerPC", "Windows IA64", "Windows x64", NULL }; fstring *drivers = NULL; int i, env_index, num_drivers; char *keystr, *base, *subkeypath; pstring key2; int num_subkeys = -1; int version; DEBUG(10,("key_driver_fetch_keys key=>[%s]\n", key ? key : "NULL" )); keystr = reg_remaining_path( key + strlen(KEY_ENVIRONMENTS) ); /* list all possible architectures */ if ( !keystr ) { for ( num_subkeys=0; environments[num_subkeys]; num_subkeys++ ) regsubkey_ctr_addkey( subkeys, environments[num_subkeys] ); return num_subkeys; } /* we are dealing with a subkey of "Environments */ pstrcpy( key2, keystr ); keystr = key2; if (!reg_split_path( keystr, &base, &subkeypath )) { return -1; } /* sanity check */ for ( env_index=0; environments[env_index]; env_index++ ) { if ( strequal( environments[env_index], base ) ) break; } if ( !environments[env_index] ) return -1; /* ...\Print\Environements\...\ */ if ( !subkeypath ) { regsubkey_ctr_addkey( subkeys, "Drivers" ); regsubkey_ctr_addkey( subkeys, "Print Processors" ); return 2; } /* more of the key path to process */ keystr = subkeypath; if (!reg_split_path( keystr, &base, &subkeypath )) { return -1; } /* ...\Print\Environements\...\Drivers\ */ if ( !subkeypath ) { if ( strequal(base, "Drivers") ) { switch ( env_index ) { case 0: /* Win9x */ regsubkey_ctr_addkey( subkeys, "Version-0" ); break; default: /* Windows NT based systems */ regsubkey_ctr_addkey( subkeys, "Version-2" ); regsubkey_ctr_addkey( subkeys, "Version-3" ); break; } return regsubkey_ctr_numkeys( subkeys ); } else if ( strequal(base, "Print Processors") ) { if ( env_index == 1 || env_index == 5 || env_index == 6 ) regsubkey_ctr_addkey( subkeys, "winprint" ); return regsubkey_ctr_numkeys( subkeys ); } else return -1; /* bad path */ } /* we finally get to enumerate the drivers */ /* only one possible subkey below PrintProc key */ if ( strequal(base, "Print Processors") ) { keystr = subkeypath; if (!reg_split_path( keystr, &base, &subkeypath )) { return -1; } /* no subkeys below this point */ if ( subkeypath ) return -1; /* only allow one keyname here -- 'winprint' */ return strequal( base, "winprint" ) ? 0 : -1; } /* only dealing with drivers from here on out */ keystr = subkeypath; if (!reg_split_path( keystr, &base, &subkeypath )) { return -1; } version = atoi(&base[strlen(base)-1]); switch (env_index) { case 0: if ( version != 0 ) return -1; break; default: if ( version != 2 && version != 3 ) return -1; break; } if ( !subkeypath ) { num_drivers = get_ntdrivers( &drivers, environments[env_index], version ); for ( i=0; i<num_drivers; i++ ) regsubkey_ctr_addkey( subkeys, drivers[i] ); return regsubkey_ctr_numkeys( subkeys ); } /* if anything else left, just say if has no subkeys */ DEBUG(1,("key_driver_fetch_keys unhandled key [%s] (subkey == %s\n", key, subkeypath )); return 0; }