2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
25 Change History (most recent first):
28 Revision 1.9 2004/05/18 23:51:27 cheshire
29 Tidy up all checkin comments to use consistent "<rdar://problem/xxxxxxx>" format for bug numbers
31 Revision 1.8 2003/11/05 22:44:57 ksekar
32 <rdar://problem/3335230>: No bounds checking when reading data from client
33 Reviewed by: Stuart Cheshire
35 Revision 1.7 2003/08/12 19:56:25 cheshire
40 #include "dnssd_ipc.h"
42 void put_flags(const DNSServiceFlags flags
, char **ptr
)
44 memcpy(*ptr
, &flags
, sizeof(DNSServiceFlags
));
45 *ptr
+= sizeof(flags
);
48 DNSServiceFlags
get_flags(char **ptr
)
50 DNSServiceFlags flags
;
52 flags
= *(DNSServiceFlags
*)*ptr
;
53 *ptr
+= sizeof(DNSServiceFlags
);
57 void put_long(const uint32_t l
, char **ptr
)
60 *(uint32_t *)(*ptr
) = l
;
61 *ptr
+= sizeof(uint32_t);
64 uint32_t get_long(char **ptr
)
68 l
= *(uint32_t *)(*ptr
);
69 *ptr
+= sizeof(uint32_t);
73 void put_error_code(const DNSServiceErrorType error
, char **ptr
)
75 memcpy(*ptr
, &error
, sizeof(error
));
76 *ptr
+= sizeof(DNSServiceErrorType
);
79 DNSServiceErrorType
get_error_code(char **ptr
)
81 DNSServiceErrorType error
;
83 error
= *(DNSServiceErrorType
*)(*ptr
);
84 *ptr
+= sizeof(DNSServiceErrorType
);
88 void put_short(const uint16_t s
, char **ptr
)
90 *(uint16_t *)(*ptr
) = s
;
91 *ptr
+= sizeof(uint16_t);
94 uint16_t get_short(char **ptr
)
98 s
= *(uint16_t *)(*ptr
);
99 *ptr
+= sizeof(uint16_t);
104 int put_string(const char *str
, char **ptr
)
108 *ptr
+= strlen(str
) + 1;
112 int get_string(char **ptr
, char *buffer
, int buflen
)
116 overrun
= (int)strlen(*ptr
) < buflen
? 0 : -1;
117 strncpy(buffer
, *ptr
, buflen
- 1);
118 buffer
[buflen
- 1] = '\0';
119 *ptr
+= strlen(buffer
) + 1;
123 void put_rdata(const int rdlen
, const char *rdata
, char **ptr
)
125 memcpy(*ptr
, rdata
, rdlen
);
129 char *get_rdata(char **ptr
, int rdlen
)