File indexing completed on 2024-05-19 04:06:37
0001 /* 0002 * Copyright (C) 2005-2008 Justin Karneges 0003 * 0004 * Permission is hereby granted, free of charge, to any person obtaining a 0005 * copy of this software and associated documentation files (the 0006 * "Software"), to deal in the Software without restriction, including 0007 * without limitation the rights to use, copy, modify, merge, publish, 0008 * distribute, sublicense, and/or sell copies of the Software, and to 0009 * permit persons to whom the Software is furnished to do so, subject to 0010 * the following conditions: 0011 * 0012 * The above copyright notice and this permission notice shall be included 0013 * in all copies or substantial portions of the Software. 0014 * 0015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 0016 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 0017 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 0018 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 0019 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 0020 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 0021 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 0022 */ 0023 0024 #ifndef JDNS_P_H 0025 #define JDNS_P_H 0026 0027 #include <stdio.h> 0028 #include <stdlib.h> 0029 #include <string.h> 0030 #include <stdarg.h> 0031 #include <ctype.h> 0032 0033 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 0034 # define JDNS_OS_WIN 0035 #else 0036 # define JDNS_OS_UNIX 0037 #endif 0038 0039 #if defined(__FreeBSD__) || defined(__DragonFly__) 0040 # define JDNS_OS_FREEBSD 0041 #elif defined(__NetBSD__) 0042 # define JDNS_OS_NETBSD 0043 #elif defined(__OpenBSD__) 0044 # define JDNS_OS_OPENBSD 0045 #elif defined(sun) || defined(__sun) 0046 # define JDNS_OS_SOLARIS 0047 #elif defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__)) 0048 # define JDNS_OS_MAC 0049 #endif 0050 0051 #ifdef JDNS_OS_WIN 0052 # include <windows.h> 0053 #endif 0054 0055 #ifdef JDNS_OS_UNIX 0056 # include <unistd.h> 0057 # include <netinet/in.h> 0058 #endif 0059 0060 #include "jdns.h" 0061 #include "jdns_packet.h" 0062 0063 /* jdns_util.c */ 0064 void *jdns_alloc(int size); 0065 void *jdns_realloc(void *p, int size); 0066 void jdns_free(void *p); 0067 char *jdns_strdup(const char *s); 0068 unsigned char *jdns_copy_array(const unsigned char *src, int size); 0069 int jdns_domain_cmp(const unsigned char *a, const unsigned char *b); 0070 0071 int jdns_sprintf_s(char *str, int n, const char *format, ...); 0072 int jdns_vsprintf_s(char *str, int n, const char *format, va_list ap); 0073 FILE *jdns_fopen(const char *path, const char *mode); 0074 jdns_string_t *jdns_getenv(const char *name); 0075 char *jdns_strcpy(char *dst, const char *src); 0076 0077 int jdns_string_indexOf(const jdns_string_t *s, unsigned char c, int pos); 0078 jdns_stringlist_t *jdns_string_split(const jdns_string_t *s, unsigned char sep); 0079 0080 jdns_dnshost_t *jdns_dnshost_new(); 0081 jdns_dnshost_t *jdns_dnshost_copy(const jdns_dnshost_t *a); 0082 void jdns_dnshost_delete(jdns_dnshost_t *a); 0083 jdns_dnshostlist_t *jdns_dnshostlist_new(); 0084 jdns_dnshostlist_t *jdns_dnshostlist_copy(const jdns_dnshostlist_t *a); 0085 void jdns_dnshostlist_delete(jdns_dnshostlist_t *a); 0086 void jdns_dnshostlist_append(jdns_dnshostlist_t *a, const jdns_dnshost_t *host); 0087 0088 jdns_rr_t *jdns_rr_from_resource(const jdns_packet_resource_t *pr, const jdns_packet_t *ref); 0089 void jdns_response_remove_extra(jdns_response_t *r); 0090 void jdns_response_remove_answer(jdns_response_t *r, int pos); 0091 0092 #define alloc_type(type) (type *)jdns_alloc(sizeof(type)) 0093 #define _ustrdup(str) (unsigned char *)jdns_strdup((const char *)str) 0094 #define _ustrlen(str) strlen((const char *)str) 0095 #define _ustrcmp(a, b) strcmp((const char *)a, (const char *)b) 0096 0097 #endif