2 * internaly sasl or its test programs use some functions which are not availible
3 * on the macintosh. these have common names like strdrup gethostname etc. defining
4 * them as routines could make conflicts with clients of the library. in config.h
5 * we macro define such names to start with xxx_. The implementation for them is
6 * here. The xxx_ is in hopes of not conflicting with a name in client program.
8 /* $Id: xxx_mac_lib.c,v 1.3 2003/02/13 19:55:59 rjs3 Exp $
9 * Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in
20 * the documentation and/or other materials provided with the
23 * 3. The name "Carnegie Mellon University" must not be used to
24 * endorse or promote products derived from this software without
25 * prior written permission. For permission or any other legal
26 * details, please contact
27 * Office of Technology Transfer
28 * Carnegie Mellon University
30 * Pittsburgh, PA 15213-3890
31 * (412) 268-4387, fax: (412) 268-7395
32 * tech-transfer@andrew.cmu.edu
34 * 4. Redistributions of any form whatsoever must retain the following
36 * "This product includes software developed by Computing Services
37 * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
39 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
40 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
41 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
42 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
43 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
44 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
45 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
53 // #include <netinet/in.h>
56 * return the smaller of two integers
58 static int xxy_min(int a,int b)
65 static int limit_strcpy(char *dest,const char *src,int len)
70 slen=xxy_min(slen,len-1);
72 memcpy(dest,src,slen);
77 int strcpy_truncate(char *dest,char *src,int len)
79 return limit_strcpy(dest,src,len);
82 int gethostname(char *dest,int destlen)
84 limit_strcpy(dest,"localhost",destlen);
88 char *strdup(const char *str)
93 const int len=strlen(str);
94 char *result=malloc(len+1);
101 int strncasecmp(const char *s1,const char *s2,int len)
112 /* last ansi spec i read tolower was undefined for non uppercase chars
113 * but it works in most implementations
127 int strcasecmp(const char *s1,const char *s2)
138 /* last ansi spec i read tolower was undefined for non uppercase chars
139 * but it works in most implementations
152 int inet_aton(const char *cp, struct in_addr *inp)
154 char *cptr1, *cptr2, *cptr3;
159 if (!(cptr1 = strchr(cptr0, '.'))) return 0;
161 if (!(cptr2 = strchr(cptr1, '.'))) return 0;
163 if (!(cptr3 = strchr(cptr2, '.'))) return 0;
165 if (!*cptr3) return 0;
167 u = ((atoi(cptr0) << 8 + atoi(cptr1)) << 8 + atoi(cptr2)) << 8 + atoi(cptr3);
168 inp->s_addr = htonl(u);