Libinfo-173.tar.gz
[apple/libinfo.git] / lookup.subproj / lu_utils.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Useful macros and other stuff for generic lookups
27 * Copyright (C) 1989 by NeXT, Inc.
28 */
29
30 #ifndef _LU_UTILS_H_
31 #define _LU_UTILS_H_
32
33 #import <netinfo/lookup_types.h>
34 #include <netinfo/ni.h>
35 #include <stdarg.h>
36
37 #define LU_COPY_STRING(x) strdup(((x) == NULL) ? "" : x)
38
39 #define LU_LONG_STRING_LENGTH 8192
40
41 #define _lu_data_key_alias 10010
42 #define _lu_data_key_bootp 10020
43 #define _lu_data_key_bootparams 10030
44 #define _lu_data_key_fstab 10040
45 #define _lu_data_key_group 10050
46 #define _lu_data_key_host 10060
47 #define _lu_data_key_netgroup 10070
48 #define _lu_data_key_network 10080
49 #define _lu_data_key_printer 10090
50 #define _lu_data_key_protocol 10100
51 #define _lu_data_key_rpc 10110
52 #define _lu_data_key_service 10120
53 #define _lu_data_key_user 10130
54
55 struct lu_thread_info
56 {
57 void *lu_entry;
58 XDR *lu_xdr;
59 char *lu_vm;
60 unsigned int lu_vm_length;
61 unsigned int lu_vm_cursor;
62 };
63
64 extern mach_port_t _lu_port;
65 extern unit *_lookup_buf;
66 extern int _lu_running(void);
67
68 void *_lu_data_create_key(unsigned int key, void (*destructor)(void *));
69 void _lu_data_set_key(unsigned int key, void *data);
70 void *_lu_data_get_key(unsigned int key);
71 void _lu_data_free_vm_xdr(struct lu_thread_info *tdata);
72
73 int _lu_xdr_attribute(XDR *xdr, char **key, char ***val, unsigned int *count);
74
75 ni_proplist *_lookupd_xdr_dictionary(XDR *inxdr);
76 int lookupd_query(ni_proplist *l, ni_proplist ***out);
77 ni_proplist *lookupd_make_query(char *cat, char *fmt, ...);
78 void ni_property_merge(ni_property *a, ni_property *b);
79 void ni_proplist_merge(ni_proplist *a, ni_proplist *b);
80
81 kern_return_t _lookup_link(mach_port_t server, lookup_name name, int *procno);
82 kern_return_t _lookup_one(mach_port_t server, int proc, inline_data indata, mach_msg_type_number_t indataCnt, inline_data outdata, mach_msg_type_number_t *outdataCnt);
83 kern_return_t _lookup_all(mach_port_t server, int proc, inline_data indata, mach_msg_type_number_t indataCnt, ooline_data *outdata, mach_msg_type_number_t *outdataCnt);
84 kern_return_t _lookup_ooall(mach_port_t server, int proc, ooline_data indata, mach_msg_type_number_t indataCnt, ooline_data *outdata, mach_msg_type_number_t *outdataCnt);
85
86 #endif /* ! _LU_UTILS_H_ */