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@
26 #include "dnssd_ipc.h"
29 void put_flags(const DNSServiceFlags flags
, char **ptr
)
31 memcpy(*ptr
, &flags
, sizeof(DNSServiceFlags
));
32 *ptr
+= sizeof(flags
);
35 DNSServiceFlags
get_flags(char **ptr
)
37 DNSServiceFlags flags
;
39 flags
= *(DNSServiceFlags
*)*ptr
;
40 *ptr
+= sizeof(DNSServiceFlags
);
44 void put_long(const uint32_t l
, char **ptr
)
47 *(uint32_t *)(*ptr
) = l
;
48 *ptr
+= sizeof(uint32_t);
51 uint32_t get_long(char **ptr
)
55 l
= *(uint32_t *)(*ptr
);
56 *ptr
+= sizeof(uint32_t);
60 void put_error_code(const DNSServiceErrorType error
, char **ptr
)
62 memcpy(*ptr
, &error
, sizeof(error
));
63 *ptr
+= sizeof(DNSServiceErrorType
);
66 DNSServiceErrorType
get_error_code(char **ptr
)
68 DNSServiceErrorType error
;
70 error
= *(DNSServiceErrorType
*)(*ptr
);
71 *ptr
+= sizeof(DNSServiceErrorType
);
75 void put_short(const uint16_t s
, char **ptr
)
77 *(uint16_t *)(*ptr
) = s
;
78 *ptr
+= sizeof(uint16_t);
81 uint16_t get_short(char **ptr
)
85 s
= *(uint16_t *)(*ptr
);
86 *ptr
+= sizeof(uint16_t);
91 int put_string(const char *str
, char **ptr
)
95 *ptr
+= strlen(str
) + 1;
99 // !!!KRS we don't properly handle the case where the string is longer than the buffer!!!
100 int get_string(char **ptr
, char *buffer
, int buflen
)
104 overrun
= (int)strlen(*ptr
) < buflen
? 0 : -1;
105 strncpy(buffer
, *ptr
, buflen
- 1);
106 buffer
[buflen
- 1] = '\0';
107 *ptr
+= strlen(buffer
) + 1;
111 void put_rdata(const int rdlen
, const char *rdata
, char **ptr
)
113 memcpy(*ptr
, rdata
, rdlen
);
117 char *get_rdata(char **ptr
, int rdlen
)