2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.2 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #include "dnssd_ipc.h"
26 void put_flags(const DNSServiceFlags flags
, char **ptr
)
28 memcpy(*ptr
, &flags
, sizeof(DNSServiceFlags
));
29 *ptr
+= sizeof(flags
);
32 DNSServiceFlags
get_flags(char **ptr
)
34 DNSServiceFlags flags
;
36 flags
= *(DNSServiceFlags
*)*ptr
;
37 *ptr
+= sizeof(DNSServiceFlags
);
41 void put_long(const uint32_t l
, char **ptr
)
44 *(uint32_t *)(*ptr
) = l
;
45 *ptr
+= sizeof(uint32_t);
48 uint32_t get_long(char **ptr
)
52 l
= *(uint32_t *)(*ptr
);
53 *ptr
+= sizeof(uint32_t);
57 void put_error_code(const DNSServiceErrorType error
, char **ptr
)
59 memcpy(*ptr
, &error
, sizeof(error
));
60 *ptr
+= sizeof(DNSServiceErrorType
);
63 DNSServiceErrorType
get_error_code(char **ptr
)
65 DNSServiceErrorType error
;
67 error
= *(DNSServiceErrorType
*)(*ptr
);
68 *ptr
+= sizeof(DNSServiceErrorType
);
72 void put_short(const uint16_t s
, char **ptr
)
74 *(uint16_t *)(*ptr
) = s
;
75 *ptr
+= sizeof(uint16_t);
78 uint16_t get_short(char **ptr
)
82 s
= *(uint16_t *)(*ptr
);
83 *ptr
+= sizeof(uint16_t);
88 int put_string(const char *str
, char **ptr
)
92 *ptr
+= strlen(str
) + 1;
96 // !!!KRS we don't properly handle the case where the string is longer than the buffer!!!
97 int get_string(char **ptr
, char *buffer
, int buflen
)
101 overrun
= (int)strlen(*ptr
) < buflen ?
0 : -1;
102 strncpy(buffer
, *ptr
, buflen
- 1);
103 buffer
[buflen
- 1] = '\0';
104 *ptr
+= strlen(buffer
) + 1;
108 void put_rdata(const int rdlen
, const char *rdata
, char **ptr
)
110 memcpy(*ptr
, rdata
, rdlen
);
114 char *get_rdata(char **ptr
, int rdlen
)