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