Apple Network Setup Manual do Utilizador Página 37

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 184
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 36
CHAPTER 2
Using Network Setup
Reading and Writing Preferences 37
IMPORTANT
You can derive the C structure for a specific preference type
by removing the “k” from the front of the name and the
“Pref” from the end. For example, the C structure for
kOTCfgTCPDHCPLeaseInfoPref is OTCfgTCPDHCPLeaseInfo. The
preference type constants and preference structures for all
of the Apple-defined preferences are provided in Chapter 4,
“Network Setup Protocol Structures and Data Types.”
Reading Variable-size Preferences 2
The MyReadFixedSizePref routine shown in Listing 2-7 also works with variable
size preferences that have a known maximum size that internally includes the
size of the preference. The user-visible name preference
(
kOTCfgUserVisibleNamePref), which contains a packed Pascal string, is an
example. The maximum length of a Pascal string is 256 bytes, and the first byte
denotes the length of the actual string data. Listing 2-9 shows how to use
MyReadFixedSizePref to read this type of variable size preference.
Listing 2-9 Reading the user-visible name preference
static OSStatus MyGetEntityUserVisibleName(CfgDatabaseRef dbRef,
const CfgEntityRef *entity,
Str255 name)
{
OSStatus err;
assert(dbRef != nil);
assert(entity != nil);
assert(name != nil);
err = MyReadFixedSizePref(dbRef, entity, kOTCfgUserVisibleNamePref,
name, sizeof(Str255));
return err;
}
If the variable size preference you want to read does not have a known
maximum size and does not store its size internally, you need to know how big
a buffer to allocate before you call
OTCfgGetPrefs. You can get this information
Vista de página 36
1 2 ... 32 33 34 35 36 37 38 39 40 41 42 ... 183 184

Comentários a estes Manuais

Sem comentários