2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 Change History (most recent first):
26 Revision 1.7 2003/08/12 19:56:25 cheshire
31 #include "dnssd_ipc.h"
33 void put_flags(const DNSServiceFlags flags
, char **ptr
)
35 memcpy(*ptr
, &flags
, sizeof(DNSServiceFlags
));
36 *ptr
+= sizeof(flags
);
39 DNSServiceFlags
get_flags(char **ptr
)
41 DNSServiceFlags flags
;
43 flags
= *(DNSServiceFlags
*)*ptr
;
44 *ptr
+= sizeof(DNSServiceFlags
);
48 void put_long(const uint32_t l
, char **ptr
)
51 *(uint32_t *)(*ptr
) = l
;
52 *ptr
+= sizeof(uint32_t);
55 uint32_t get_long(char **ptr
)
59 l
= *(uint32_t *)(*ptr
);
60 *ptr
+= sizeof(uint32_t);
64 void put_error_code(const DNSServiceErrorType error
, char **ptr
)
66 memcpy(*ptr
, &error
, sizeof(error
));
67 *ptr
+= sizeof(DNSServiceErrorType
);
70 DNSServiceErrorType
get_error_code(char **ptr
)
72 DNSServiceErrorType error
;
74 error
= *(DNSServiceErrorType
*)(*ptr
);
75 *ptr
+= sizeof(DNSServiceErrorType
);
79 void put_short(const uint16_t s
, char **ptr
)
81 *(uint16_t *)(*ptr
) = s
;
82 *ptr
+= sizeof(uint16_t);
85 uint16_t get_short(char **ptr
)
89 s
= *(uint16_t *)(*ptr
);
90 *ptr
+= sizeof(uint16_t);
95 int put_string(const char *str
, char **ptr
)
99 *ptr
+= strlen(str
) + 1;
103 // !!!KRS we don't properly handle the case where the string is longer than the buffer!!!
104 int get_string(char **ptr
, char *buffer
, int buflen
)
108 overrun
= (int)strlen(*ptr
) < buflen
? 0 : -1;
109 strncpy(buffer
, *ptr
, buflen
- 1);
110 buffer
[buflen
- 1] = '\0';
111 *ptr
+= strlen(buffer
) + 1;
115 void put_rdata(const int rdlen
, const char *rdata
, char **ptr
)
117 memcpy(*ptr
, rdata
, rdlen
);
121 char *get_rdata(char **ptr
, int rdlen
)