[llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/Makefile add.c bind.c compare.c dixie.h error.c globals.c init.c list.c modify.c modrdn.c parse.c read.c remove.c search.c send.c test.c util.c version.c

Chris Lattner lattner at cs.uiuc.edu
Tue Oct 5 12:30:02 PDT 2004



Changes in directory llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie:

Makefile added (r1.1)
add.c added (r1.1)
bind.c added (r1.1)
compare.c added (r1.1)
dixie.h added (r1.1)
error.c added (r1.1)
globals.c added (r1.1)
init.c added (r1.1)
list.c added (r1.1)
modify.c added (r1.1)
modrdn.c added (r1.1)
parse.c added (r1.1)
read.c added (r1.1)
remove.c added (r1.1)
search.c added (r1.1)
send.c added (r1.1)
test.c added (r1.1)
util.c added (r1.1)
version.c added (r1.1)
---
Log message:

Another "benchmark" without an input


---
Diffs of the changes:  (+2259 -0)

Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/Makefile
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/Makefile:1.1
*** /dev/null	Tue Oct  5 14:30:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/Makefile	Tue Oct  5 14:29:50 2004
***************
*** 0 ****
--- 1,6 ----
+ LEVEL = ../../../..
+ 
+ PROG = dixie
+ #STDIN_FILENAME = $(SourceDir)/testset
+ include $(LEVEL)/MultiSource/Makefile.multisrc
+ 


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/add.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/add.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/add.c	Tue Oct  5 14:29:50 2004
***************
*** 0 ****
--- 1,54 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  add.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include <stdio.h>
+ #include "dixie.h"
+ #include <string.h>
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int
+                      anslen, int scope );
+ 
+ /*
+  * dxi_add - do a dixie (X.500) add operation.  The DN of the entry to
+  * add is supplied (in text form) in who.  The attributes that the new
+  * entry will have are supplied in the array of char *'s entry.
+  *
+  * Example:
+  *	dxi_add( "c=us at cn=bob", entry )
+  */
+ 
+ int dxi_add(char *who, char **entry )
+ {
+ 	int		i, len;
+ 	char		*tmp;
+ 	char		ans[ DXI_H_SIZE + 1 ];
+ 	extern char	*dxi_buffer;
+ 	extern int	dxi_errno;
+ 
+ 	strcpy( dxi_buffer, who );
+ 	len = strlen( dxi_buffer ) + 1;
+ 	tmp = dxi_buffer + len;
+ 	for ( i = 0; entry[i] != NULL; i++ ) {
+ 		strcpy( tmp, entry[i] );
+ 		len += strlen( entry[i] ) + 1;
+ 		tmp = dxi_buffer + len;
+ 	}
+ 
+ 	/* and now ship it */
+ 	if ( (i = dxi_send( DXI_ADD, dxi_buffer, len, ans, sizeof(ans), 0 ))
+ 	    == -1 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( -1 );
+ 	}
+ 	dxi_errno = ans[DXI_H_RC];
+ 
+ 	return( dxi_errno == DXI_SUCCESS ? 0 : -1 );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/bind.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/bind.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/bind.c	Tue Oct  5 14:29:50 2004
***************
*** 0 ****
--- 1,145 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  bind.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include "dixie.h"
+ #include <string.h>
+ #if defined(MACOS) || defined(DOS) || defined(VMS)
+ #include <types.h>
+ #include <stdlib.h>
+ #ifdef MACOS
+ #include "tcp.h"
+ #endif
+ #ifdef VMS
+ #include <in.h>
+ #endif
+ #else
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #endif
+ 
+ extern int	dxi_limit;
+ extern char	*dxi_buffer;
+ extern int	dxi_errno;
+ extern int	dxi_debug;
+ extern int	dxi_bound;
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int scope );
+ extern int open_sock( unsigned long address, int port );
+ extern u_long inet_addr( char *s );
+ 
+ int nullbound;
+ 
+ /*
+  * dxi_udpbind - bind to the dixie server (and X.500).  The dn and password
+  * of the entry to which to bind are supplied.  0 is returned on success,
+  * -1 if the DSA could not be contacted, or the length of the error packet
+  * in case or other trouble.
+  *
+  * Example:
+  *	dxi_udpbind( "c=us at o=university of michigan at cn=manager", "secret" )
+  */
+ 
+ int dxi_udpbind(char *who, char *passwd)
+ {
+ 	char		answer[256];
+ 	char		*temp;
+ 	int		len, i;
+ 	unsigned long	address;
+ 	int		port;
+ 
+ 	dxi_errno = 0;
+ 
+ 	/* 
+ 	 * build the packet.  it looks like this:
+ 	 * 	who\0passwd\0
+ 	 */
+ 
+ 	nullbound = (who == NULL || *who == '\0');
+ 	if ( who == NULL )
+ 		who = "";
+ 	if ( passwd == NULL )
+ 		passwd = "";
+ 	strcpy( dxi_buffer, who );
+ 	len = strlen( who ) + 1;
+ 	temp = dxi_buffer + len;
+ 	strcpy( temp, passwd );
+ 	len += strlen( passwd );
+ 	dxi_buffer[len++] = '\0';
+ 
+ 	/* send it */
+ 	if ( (len = dxi_send( DXI_BIND,  dxi_buffer, len, answer,
+ 	    sizeof(answer), 0 )) < 0 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( len );
+ 	}
+ 	dxi_errno = answer[DXI_H_RC];
+ 
+ 	/* see if it was successful */
+ 	switch ( dxi_errno ) {
+ 	case DXI_SUCCESS :
+ 		if ( dxi_bound >= 0 )
+ 			return( 0 );
+ 		temp = NULL;
+ 		for ( i = DXI_H_SIZE; i < len; i++ ) {
+ 			if ( answer[i] == DXI_VAL_SEP ) {
+ 				answer[i] = '\0';
+ 				if ( temp == NULL )
+ 					temp = &(answer[i + 1]);
+ 			}
+ 		}
+ 		address = inet_addr( &(answer[DXI_H_SIZE]) );
+ 		port = atoi( temp );
+ 		dxi_bound = open_sock( address, port );
+ 		return( dxi_bound < 0 ? -1 : 0 );
+ 
+ 	default:
+ 		return( -1 );
+ 	}
+ }
+ 
+ /*
+  * dxi_bind - bind to the dixie server (and X.500).  The dn and password
+  * of the entry to which to bind are supplied.  0 is returned on success,
+  * -1 if the DSA could not be contacted, or the length of the error packet
+  * in case or other trouble.  This bind is done via TCP.
+  *
+  * Example:
+  *	dxi_bind( "c=us at o=university of michigan at cn=manager", "secret" )
+  */
+ 
+ #if defined(MACOS) || defined(DOS)
+ extern ip_addr dixieaddr;
+ #else
+ extern struct sockaddr_in dixieaddr;
+ #endif
+ 
+ int dxi_bind( char *who, char *passwd )
+ {
+ 	nullbound = (who == NULL || *who == '\0');
+ 	if ( dxi_bound >= 0 )
+ 		return( dxi_udpbind( who, passwd ) );
+ #if defined(MACOS) || defined(DOS)
+ 	dxi_bound = open_sock( dixieaddr, DXI_PORT );
+ #else
+ 	dxi_bound = open_sock( dixieaddr.sin_addr.s_addr, DXI_PORT );
+ #endif
+ 
+ 	if ( dxi_bound < 0 )
+ 		return( -1 );
+ 
+ 	dxi_errno = DXI_SUCCESS;
+ 	if ( who == NULL || *who == '\0' )
+ 		return( 0 );
+ 
+ 	return( dxi_udpbind( who, passwd ) );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/compare.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/compare.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/compare.c	Tue Oct  5 14:29:50 2004
***************
*** 0 ****
--- 1,56 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  compare.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include <stdio.h>
+ #include "dixie.h"
+ #include <string.h>
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int scope );
+ 
+ /*
+  * dxi_compare - do a dixie (X.500) compare operation.  The DN of the entry
+  * is supplied (in text form), along with the attribute and value to compare
+  * (in attr and value).
+  *
+  * Example:
+  *	dxi_compare( "c=us at cn=bob", "userPassword", "foo")
+  */
+ 
+ int dxi_compare( char *who, char *attr, char *value)
+ {
+ 	int		len;
+ 	extern char	*dxi_buffer;
+ 	extern int	dxi_errno;
+ 	char	ans[ DXI_H_SIZE + 1 ];
+ 	char *p;
+ 
+ 	strcpy( dxi_buffer, who );
+ 	len = strlen( who );
+ 	p = &dxi_buffer[len];
+ 	p++;
+ 	len++;
+ 	strcpy(p,attr);
+ 	p += strlen(attr) + 1;
+ 	len += strlen(attr) + 1;
+ 	strcpy(p,value);
+ 	len += strlen(value) + 1;
+ 	/* and now ship it */
+ 
+ 	if ( dxi_send( DXI_COMPARE, dxi_buffer, len, ans, sizeof(ans), 0 )
+ 	    == -1 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( -1 );
+ 	}
+ 	dxi_errno = ans[DXI_H_RC];
+ 
+ 	return( dxi_errno == DXI_SUCCESS ? 0 : 
+ 	    dxi_errno == DXI_COMPAREFAILED ? 1 : -1 );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/dixie.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/dixie.h:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/dixie.h	Tue Oct  5 14:29:50 2004
***************
*** 0 ****
--- 1,173 ----
+ /* dixie.h */
+ /*
+  * Copyright (c) 1990 Regents of the University of Michigan.
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms are permitted
+  * provided that this notice is preserved and that due credit is given
+  * to the University of Michigan at Ann Arbor. The name of the University
+  * may not be used to endorse or promote products derived from this
+  * software without specific prior written permission. This software
+  * is provided ``as is'' without express or implied warranty.
+  */
+ 
+ #ifdef MACOS
+ #include "macos.h"
+ #define NOUDP		1
+ #define NEEDINETADDR	1
+ #endif
+ 
+ #ifdef DOS
+ #define NOUDP	1
+ 
+ typedef unsigned short us;
+ typedef unsigned long ul;
+ #define ntohs(i) ((us)( (((us)i & 0xff) << 8)  + (((us)i & 0xff00) >> 8) ))
+ #define ntohl(i) ((ul)( (((ul)i & 0xff) << 24) + (((ul)i & 0xff00) << 8) + \
+ 			(((ul)i & 0xff0000) >> 8) +  \
+ 			(((ul)i & 0xff000000) >> 24) ))
+ #define htons(i) ((unsigned) (((unsigned)i & 0xff00) >> 8) + \
+ 			(((unsigned) i & 0xff) << 8))
+ 
+ typedef unsigned long ip_addr;
+ typedef unsigned long u_long;
+ typedef unsigned char u_char;
+ 
+ #include <malloc.h>
+ #include "proto.h"
+ #endif /* DOS */
+ 
+ #define DXI_PORT 	96
+ 
+ #define K		1024
+ #define MAX_PKT_SIZE	(30*K)
+ #define MAX_PKT_FRAG	(K/2)
+ 
+ /* dixie op codes */
+ #define DXI_READ		0x01
+ #define DXI_WRITE		0x02
+ #define DXI_SEARCH		0x03
+ #define DXI_BIND		0x04
+ #define DXI_SEARCH1		0x05
+ #define DXI_ACK			0x06
+ #define DXI_NACK		0x07
+ #define DXI_SEARCH_APPROX	0x08
+ #define DXI_SEARCH_EXACT	0x09
+ #define DXI_RESEND		0x0a
+ #define DXI_PING		0x0b
+ #define DXI_SEARCH_ISUB		0x0c
+ #define DXI_SEARCH_FSUB		0x0d
+ #define DXI_SEARCH_IFSUB	0x0e
+ #define DXI_SEARCH_GEN		0x0f
+ #define DXI_LIST		0x10
+ #define DXI_ADD			0x11
+ #define DXI_REMOVE		0x12
+ #define DXI_MODRDN		0x13
+ #define DXI_COMPARE		0x14
+ 
+ /* dixie search scopes */
+ #define DXI_SRCH_BASE		0x01
+ #define DXI_SRCH_ONELEVEL	0x02
+ #define DXI_SRCH_SUBTREE	0x03
+ 
+ /* dixie return values */
+ #define DXI_SUCCESS		0x01
+ #define DXI_NOTFOUND		0x02
+ #define DXI_ERROR		0x03
+ #define DXI_BADCMD		0x04
+ #define DXI_REFUSED		0x05
+ #define DXI_BADDN		0x06
+ #define DXI_SIZELIMIT		0x07
+ #define DXI_NOTCONN		0x08
+ #define DXI_SEQNOTFOUND		0x09
+ #define DXI_BAD_ATTR		0x0a
+ #define DXI_NEX_ATTR		0x0b
+ #define DXI_BAD_ATTRVAL		0x0c
+ #define DXI_NEX_ATTRVAL		0x0d
+ #define DXI_NO_RDN_MOD		0x0e
+ #define DXI_NAME_ERROR		0x0f
+ #define DXI_REFER_ERROR 	0x10
+ #define DXI_DSA_DOWN		0x11
+ #define DXI_TIMELIMIT		0x12
+ #define DXI_TOOBIG		0x13
+ #define DXI_DOWN		0x14
+ #define DXI_EXISTS		0x15
+ #define DXI_COMPAREFAILED	0x16
+ #define DXI_BAD_FILTER		0x17
+ 
+ /* for compatibility ... */
+ #define DXI_LIMIT	0x07
+ 
+ #define DXI_VAL_SEP	0x01
+ #define DXI_ATR_SEP	0x02
+ #define DXI_DNS_SEP	0x03
+ #define DXI_ATEND_FLAG	0x04
+ 
+ #define DXI_H_RC		0	/* char */
+ #define DXI_H_OP		0	/* char */
+ #define DXI_H_ID		1	/* short */
+ #define DXI_H_TOTLEN		3	/* long */
+ #define DXI_H_SEQUENCE		7	/* short */
+ #define DXI_H_OPTIONS		9	/* char */
+ #define DXI_H_VERSION 		10	/* char */
+ #define DXI_H_SRCH_SCOPE	11	/* char */
+ #define DXI_H_TIMELIMIT		12	/* short */
+ #define DXI_H_SIZELIMIT		14	/* short */
+ #define DXI_H_SIZE		16	/* unused */
+ 
+ #define DXI_OPT_FILEATTR		1
+ #define DXI_OPT_DONTDEREF		2
+ #define DXI_OPT_DONTSEARCHALIASES	4
+ 
+ #define DXI_PHOTO_G3FAX_TWODIM	0x01
+ #define DXI_PHOTO_JPEG		0x02
+ 
+ #define ID	short
+ 
+ #if !defined(MACOS) & !defined(DOS)
+ extern int bprint();
+ 
+ extern int dxi_init(char *host, int timeout, int retries);
+ extern int dxi_bind(char *who, char *passwd);
+ extern int dxi_udpbind(char *who, char *passwd);
+ extern int dxi_read(char *who, char **attrs, char *ans);
+ extern int dxi_list(char *who, char *ans);
+ extern int dxi_search(char *base, int scope, char *filter, char *attrlist[],
+                       char *answer);
+ extern int dxi_modify(char *who, char **what);
+ extern int dxi_modrdn(char *who, char *newrdn);
+ extern int dxi_add(char *who, char **entry);
+ extern int dxi_remove(char *who);
+ extern void dxi_perror(char *s);
+ extern int dxi_matches(char *buf);
+ extern int dxi_close(void);
+ extern int dxi_compare(char *who, char *attr, char *value);
+ extern void dxi_det61(char *s);
+ 
+ extern char *dxi_firstentry(char *buf);
+ extern char *dxi_nextentry(void);
+ extern char *dxi_getdn(char *buf);
+ extern char *dxi_lastdncomp(char *dn);
+ extern char *dxi_firstattr(char *ent);
+ extern char *dxi_nextattr(char *attr);
+ 
+ extern char **dxi_getvalues(char *buf, char *at);
+ 
+ extern void dxi_valuefree(char **av);
+ #endif /* MACOS DOS */
+ 
+ extern int dxi_debug;
+ extern int dxi_errno;
+ extern int dxi_not61;
+ extern char dxi_options;
+ extern short dxi_sizelimit;
+ extern short dxi_timelimit;
+ extern char *dxi_errlist[];
+ #ifdef VMS
+ #define index(x) strchr(x)
+ #define rindex(x) strrchr(x)
+ #endif
+ 
+ #ifdef __svr4__
+ #define bzero(x,y) memset(x,0,y)
+ #endif


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/error.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/error.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/error.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,43 ----
+ #include <stdio.h>
+ #include "dixie.h"
+ #include <string.h>
+ 
+ #ifdef VMS_MULTINET
+ extern char *dxierrlist[20];
+ #else
+ char *dxi_errlist[] = {
+ 	"Invalid error",			/* 0 is not valid 	*/
+ 	"Success",				/* DXI_SUCCESS 		*/
+ 	"No matches found",			/* DXI_NOTFOUND 	*/
+ 	"Generic DIXIE error",			/* DXI_ERROR		*/
+ 	"Unknown op code",			/* DXI_BADCMD		*/
+ 	"Access denied",			/* DXI_REFUSED		*/
+ 	"Malformed DN",				/* DXI_BADDN		*/
+ 	"Size limit exceeded",			/* DXI_SIZELIMIT	*/
+ 	"Not bound",				/* DXI_NOTCONN		*/
+ 	"Fragment not found",			/* DXI_SEQNOTFOUND	*/
+ 	"Invalid attribute type",		/* DXI_BAD_ATTR		*/
+ 	"Attribute type not found",		/* DXI_NEX_ATTR		*/
+ 	"Invalid attribute value",		/* DXI_BAD_VALUE	*/
+ 	"Attribute value not found",		/* DXI_NEX_VALUE	*/
+ 	"ModRDN not allowed",			/* DXI_NO_RDN_MOD	*/
+ 	"Entry does not exist",			/* DXI_NAME_ERROR	*/
+ 	"Referral error",			/* DXI_REFER_ERROR	*/
+ 	"Can't contact DSA",			/* DXI_DSA_DOWN		*/
+ 	"Time limit exceeded",			/* DXI_TIMELIMIT	*/
+ 	"UDP packet too big",			/* DXI_TOOBIG		*/
+ 	"Can't contact DIXIE server",		/* DXI_DOWN		*/
+ 	"Attr, value, or name already exists",	/* DXI_EXISTS		*/
+ 	"Compare failed",			/* DXI_COMPAREFAILED	*/
+ 	"Bad search filter"			/* DXI_BAD_FILTER	*/
+ };
+ #endif /* vms_multinet */
+ 
+ void dxi_perror( char *s )
+ {
+ 	if ( dxi_errno <= DXI_BAD_FILTER && dxi_errno >= DXI_SUCCESS ) {
+ 		fprintf( stderr, "%s: %s\n", s, dxi_errlist[dxi_errno] );
+ 	} else {
+ 		fprintf( stderr, "%s: Unknown error\n", s );
+ 	}
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/globals.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/globals.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/globals.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,14 ----
+ #include "dixie.h"
+ 
+ char	*dxi_buffer;
+ int	dxi_errno;
+ int	dxi_limitiserror;
+ int	dxi_limit;
+ int	dxi_debug;
+ int	dxi_bound = -1;
+ int	dxi_timeout;
+ int	dxi_retries;
+ int	dxi_not61;
+ char	dxi_options;
+ short	dxi_sizelimit;
+ short	dxi_timelimit;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/init.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/init.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/init.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,103 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  show.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include "dixie.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #if !defined(__STDC__) && !defined(VMS)
+ #include <memory.h>
+ #endif
+ #ifdef DOS
+ #include <malloc.h>
+ #endif
+ #if defined(MACOS) || defined(DOS)
+ #include <types.h>
+ #include "tcp.h"
+ #else
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <netdb.h>
+ #include <signal.h>
+ #endif
+ 
+ #ifndef INADDR_LOOPBACK
+ #define INADDR_LOOPBACK 0x7f000001
+ #endif
+ 
+ extern u_long inet_addr( char *s );
+ extern int add_server( u_long ns );
+ 
+ /*
+  * dxi_init - initialize the dixie library.  host is used as the dixie
+  * host, timeout and retries as the default initial number of seconds
+  * to wait before retransmitting packets, and number of retries to make,
+  * respectively.  Supplying 0 for timeout or retries resorts to the
+  * default values of 2 and 4, respectively.  Supplying NULL for the host
+  * causes the localhost to be used.
+  *
+  * Example:
+  *	dxi_init( "some.host.some.domain", 2, 4 )
+  */
+ 
+ int dxi_init( char *host, int timeout, int retries )
+ {
+ #if defined(MACOS) || defined(DOS)
+ 	struct hostInfo *hip;
+ #else
+ 	extern void attempt_rebind();
+ 	struct hostent	*hp;
+ #endif
+ 	unsigned long	server;
+ 	extern char	*dxi_buffer;
+ 	extern int	dxi_timeout, dxi_retries;
+ 
+ 	dxi_errno = DXI_ERROR;	/* pessimistic, but efficient... */
+ 	if ( dxi_buffer == NULL ) {
+ 		if ( (dxi_buffer = (char *) malloc( MAX_PKT_SIZE )) == NULL )
+ 			return( -1 );
+ 	}
+ 
+ 	if ( host != NULL ) {
+ #if defined(MACOS) || defined(DOS)
+ 		if ( (hip = gethostinfobyname( host )) == NULL ) {
+ 			return( -1 );
+ 		}
+ 		(void) memcpy( (char *) & server, (char *) &hip->addr[ 0 ],
+ 		    sizeof(long) );
+ 		
+ #else
+ 		if ( (server = inet_addr( host )) == -1 ) {
+ 			if ( (hp = gethostbyname( host )) == NULL ) {
+ 				return( -1 );
+ 			}
+ 			(void) memcpy( (char *) &server, (char *) hp->h_addr,
+ 			    sizeof(long) );
+ 		}
+ #endif
+ 	} else {
+ 		server = INADDR_LOOPBACK;
+ 	}
+ 
+ 	if ( add_server( server ) < 0 )
+ 		return( -1 );
+ 
+ #if !defined(MACOS) && !defined(DOS)
+ 	(void) signal( SIGPIPE, attempt_rebind );
+ #endif
+ 
+ 	dxi_timeout = timeout <= 0 ? 2 : timeout;
+ 	dxi_retries = retries <= 0 ? 4 : retries;
+ 	dxi_options = 0;
+ 
+ 	dxi_errno = DXI_SUCCESS;
+ 	return( 0 );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/list.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/list.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/list.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,50 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  list.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include "dixie.h"
+ #include <string.h>
+ #include <stdio.h>
+ 
+ /*
+  * dxi_list - do a dixie (X.500) list operation.  The DN of the entry to
+  * list is supplied (in text form).  The result of the list
+  * is passed back in ans, which should point to enough space.
+  *
+  * Example:
+  *	dxi_list( "c=us at cn=bob", answerbuffer )
+  */
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int scope );
+ 
+ int dxi_list( char *who, char *ans )
+ {
+ 	int		len;
+ 	extern char	*dxi_buffer;
+ 	extern int	dxi_errno;
+ 	extern int	dxi_limitiserror;
+ 
+ 	strcpy( dxi_buffer, who );
+ 	len = strlen( who ) + 1;
+ 
+ 	/* and now ship it */
+ 	if ( dxi_send( DXI_LIST, dxi_buffer, len, ans, MAX_PKT_SIZE, 0 )
+ 	    == -1 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( -1 );
+ 	}
+ 	dxi_errno = ans[DXI_H_RC];
+ 
+ 	if ( dxi_limitiserror )
+ 		return( dxi_errno == DXI_SUCCESS ? 0 : -1 );
+ 	else
+ 		return( dxi_errno == DXI_SUCCESS || dxi_errno == DXI_SIZELIMIT
+ 		    || dxi_errno == DXI_TIMELIMIT ? 0 : -1 );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/modify.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/modify.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/modify.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,70 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  mod.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include <stdio.h>
+ #include "dixie.h"
+ #include <string.h>
+ #include <ctype.h>
+ 
+ extern int	dxi_limit;
+ extern char	*dxi_buffer;
+ extern int	dxi_errno;
+ extern int	dxi_debug;
+ extern int	dxi_bound;
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int scope );
+ 
+ /*
+  * dxi_modify - do a dixie (x.500) modify operation.  Who contains the DN
+  * of the entry to modify, what contains null-terminated array of char *
+  * changes to make, each of which has one of the following forms:
+  *	attribute		: delete attribute
+  *	attribute=value		: make value the sole value for attribute
+  *	attribute+=value	: add value to attribute
+  *	attribute-=value	: remove value from attribute
+  * value can specify multiple values by separating them with &'s.
+  *
+  * Example:
+  *	char	*changes[] = { "cn+=bob", "mail-=fred at bob.edu", 0 };
+  *	dxi_modify( "c=us at cn=bob", changes );
+  */
+ 
+ int dxi_modify( char *who, char **what )
+ {
+ 	int	i, rc, len;
+ 	char	*tmp;
+ 	char	answer[ DXI_H_SIZE + 1 ];
+ 
+ 	/* we need to be talking over TCP */
+ 	if ( dxi_bound < 0 ) {
+ 		dxi_errno = DXI_NOTCONN;
+ 		return( -1 );
+ 	}
+ 
+ 	strcpy( dxi_buffer, who );
+ 	len = strlen( dxi_buffer ) + 1;
+ 	tmp = dxi_buffer + len;
+ 	for ( i = 0; what[i] != NULL; i++ ) {
+ 		strcpy( tmp, what[i] );
+ 		len += strlen( what[i] ) + 1;
+ 		tmp = dxi_buffer + len;
+ 	}
+ 
+ 	/* ship it */
+ 	if ( (rc = dxi_send( DXI_WRITE,  dxi_buffer, len, answer,
+ 	    sizeof(answer), 0 )) < 0 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( rc );
+ 	}
+ 	dxi_errno = answer[DXI_H_RC];
+ 
+ 	return( dxi_errno == DXI_SUCCESS ? 0 : -1 );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/modrdn.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/modrdn.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/modrdn.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,49 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  modrdn.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include "dixie.h"
+ #include <string.h>
+ #include <stdio.h>
+ 
+ /*
+  * dxi_modrdn - do a dixie (X.500) modrdn operation.  The DN of the entry to
+  * modrdn is supplied (in text form), along with the new RDN.
+  *
+  * Example:
+  *	dxi_modrdn( "c=us at cn=bob", "cn=fred" )
+  */
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int
+ 		     scope );
+ 
+ int dxi_modrdn( char *who, char *newrdn )
+ {
+ 	int		len;
+ 	char		*tmp, ans[ DXI_H_SIZE + 1 ];
+ 	extern char	*dxi_buffer;
+ 	extern int	dxi_errno;
+ 
+ 	strcpy( dxi_buffer, who );
+ 	len = strlen( who ) + 1;
+ 	tmp = dxi_buffer + len;
+ 	strcpy( tmp, newrdn );
+ 	len += strlen( newrdn ) + 1;
+ 
+ 	/* ship it */
+ 	if ( dxi_send( DXI_MODRDN, dxi_buffer, len, ans, sizeof(ans), 0 )
+ 	    == -1 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( -1 );
+ 	}
+ 	dxi_errno = ans[DXI_H_RC];
+ 
+ 	return( dxi_errno == DXI_SUCCESS ? 0 : -1 );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/parse.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/parse.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/parse.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,400 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  show.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include "dixie.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <ctype.h>
+ #include <string.h>
+ #if !defined(__STDC__) && !defined(VMS)
+ #include <memory.h>
+ #endif
+ #if !defined(MACOS) & !defined(NeXT) & !defined(DOS)
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #endif /* MACOS NeXT DOS */
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int scope);
+ 
+ static char	*dxi_current;
+ static char	dxi_attr[ 64 ];
+ 
+ #ifdef VMS
+ 
+ long strncasecmp( char * string1, char * string2, unsigned long maxlen )
+ {
+     char copystring1[256], copystring2[256];
+     long i;
+ 
+     strncpy (copystring1, string1, 256);
+     strncpy (copystring2, string2, 256);
+     
+     i = 0;
+     while ((i < 256) && (copystring1[i] != '\0'))
+     {
+         toupper (copystring1[i]);
+     i++;
+     };
+     i = 0;
+     while ((i < 256) && (copystring2[i] != '\0'))
+     {
+         toupper (copystring2[i]);
+     i++;
+     };
+     return (strncmp (copystring1, copystring2, maxlen));
+ }
+ 
+ long strcasecmp( char * string1, char * string2)
+ {
+   return (strncasecmp (string1, string2, 256));
+ }
+ 
+ #endif
+ 
+ char *dxi_findtype( char *buf, char *at )
+ {
+ 	char	*p, *s, save;
+ 
+ 	s = p = buf;
+ 	while ( 1 ) {
+ 		while ( *s != DXI_ATR_SEP && *s != DXI_DNS_SEP && *s != '\0' )
+ 			s++;
+ 		if ( *s == '\0' || *s == DXI_DNS_SEP )
+ 			break;
+ 		s++;
+ 
+ 		p = s;
+ 		while ( *s != DXI_VAL_SEP && *s != DXI_ATR_SEP
+ 		    && *s != DXI_DNS_SEP && *s != '\0' )
+ 			s++;
+ 		if ( *s == '\0' )
+ 			break;
+ 
+ 		save = *s;
+ 		*s = '\0';
+ 
+ 		if ( strcasecmp( at, p ) == 0 ) {
+ 			*s = save;
+ 			return( p );
+ 		}
+ 
+ 		*s = save;
+ 	}
+ 
+ 	return( NULL );
+ }
+ 
+ char *dxi_firstattr( char *ent )
+ {
+ 	char		*p, *a;
+ 
+ 	for ( p = ent; *p != DXI_ATR_SEP && *p != '\0'; p++ )
+ 		;	/* NULL */
+ 
+ 	if ( *p == '\0' || *++p == DXI_DNS_SEP || *p == '\0' )
+ 		return( NULL );
+ 
+ 	a = dxi_attr;
+ 	while ( *p != DXI_VAL_SEP && *p != DXI_ATR_SEP && *p != DXI_DNS_SEP )
+ 		*a++ = *p++;
+ 	*a = '\0';
+ 
+ 	return( dxi_attr );
+ }
+ 
+ char *dxi_nextattr( char *attr )
+ {
+ 	char	*p, *a;
+ 
+ 	if ( (p = dxi_findtype( dxi_current, attr )) == NULL )
+ 		return( NULL );
+ 
+ 	while ( *p != DXI_ATR_SEP && *p != DXI_DNS_SEP && *p != '\0' )
+ 		p++;
+ 
+ 	if ( *p == '\0' || *p++ == DXI_DNS_SEP )
+ 		return( NULL );
+ 
+ 	a = dxi_attr;
+ 	while ( *p != DXI_VAL_SEP && *p != DXI_ATR_SEP && *p != DXI_DNS_SEP )
+ 		*a++ = *p++;
+ 	*a = '\0';
+ 
+ 	return( dxi_attr );
+ }
+ 
+ int dxi_matches( char *buf )
+ {
+ 	short	matches;
+ 
+ 	if ( buf[DXI_H_RC] != DXI_SUCCESS && buf[DXI_H_RC] != DXI_SIZELIMIT
+ 	    && buf[DXI_H_RC] != DXI_TIMELIMIT )
+ 		return( 0 );	/* no matches */
+ 	else if ( buf[DXI_H_SIZE + 1] != DXI_DNS_SEP && buf[DXI_H_SIZE + 2]
+ 	    != DXI_DNS_SEP )
+ 		if ( buf[DXI_H_SIZE + 2] == 0 )
+ 			return( 0 );	/* no matches */
+ 		else
+ 			return( 1 );	/* read result - one match */
+ 	else if ( buf[DXI_H_VERSION] == 0 )
+ 		return( buf[DXI_H_SIZE] );	/* search result */
+ 	else {
+ 		short	tmp;
+ 
+ 		(void) memcpy( (char *) &tmp, &buf[DXI_H_SIZE], sizeof(short) );
+ 		matches = ntohs( tmp );
+ 		return( matches );
+ 	}
+ }
+ 
+ int dxi_countvalues( char *avl )
+ {
+ 	int	num = 0;
+ 
+ 	while ( *avl && *avl != DXI_ATR_SEP && *avl != DXI_DNS_SEP )
+ 		if ( *avl++ == DXI_VAL_SEP ) num++;
+ 
+ 	return( num );
+ }
+ 
+ char *dxi_firstentry( char *buf )
+ {
+ 	if ( buf[DXI_H_RC] != DXI_SUCCESS && buf[DXI_H_RC] != DXI_LIMIT
+ 	    && buf[DXI_H_RC] != DXI_TIMELIMIT
+ 	    || buf[DXI_H_SIZE + 2] == 0 )
+ 		return( 0 );	/* no entries */
+ 	if ( buf[DXI_H_SIZE + 2] == DXI_DNS_SEP )
+ 		return( dxi_current = &buf[DXI_H_SIZE + 3] );
+ 	else if ( buf[DXI_H_SIZE + 1] == DXI_DNS_SEP )
+ 		return( dxi_current = &buf[DXI_H_SIZE + 2] );
+ 	else
+ 		return( dxi_current = &buf[DXI_H_SIZE] );
+ }
+ 
+ char *dxi_getreadentry( char *buf )
+ {
+ 	if ( buf[DXI_H_RC] != DXI_SUCCESS && buf[DXI_H_RC] != DXI_LIMIT
+ 	    && buf[DXI_H_RC] != DXI_TIMELIMIT
+ 	    || buf[DXI_H_SIZE + 2] == 0 )
+ 		return( 0 );	/* no entries */
+ 	if ( buf[DXI_H_SIZE + 2] == DXI_DNS_SEP )
+ 		return( &buf[DXI_H_SIZE + 3] );
+ 	else if ( buf[DXI_H_SIZE + 1] == DXI_DNS_SEP )
+ 		return( &buf[DXI_H_SIZE + 2] );
+ 	else
+ 		return( &buf[DXI_H_SIZE] );
+ }
+ 
+ char *dxi_nextentry(void)
+ {
+ 	dxi_current = strchr( dxi_current, DXI_DNS_SEP );
+ 	return( dxi_current ? ++dxi_current : NULL );
+ }
+ 
+ char *dxi_getdn( char *buf )
+ {
+ 	char	*result, *p, save;
+ 
+ 	for ( p = buf; *p && *p != DXI_ATR_SEP && *p != DXI_DNS_SEP; p++ )
+ 		;	/* NULL */
+ 
+ 	save = *p;
+ 	*p = '\0';
+ 	result = (char *) strdup( buf );
+ 	*p = save;
+ 
+ 	return( result );
+ }
+ 
+ char **dxi_getvalues( char *buf, char *at )
+ {
+ 	char	*p, *s, save;
+ 	char	**av;
+ 	int	num, i;
+ 
+ 	if ( (p = dxi_findtype( buf, at )) == NULL )
+ 		return( (char **) 0 );
+ 
+ 	if ( (num = dxi_countvalues( p )) == 0 )
+ 		return( (char **) 0 );
+ 
+ 	if ( (av = (char **) calloc( num + 1, sizeof(char *) )) == (char **) 0 )
+ 		return( (char **) 0 );
+ 
+ 	p = strchr( p, DXI_VAL_SEP ) + 1;
+ 	for ( i = 0; i < num; i++ ) {
+ 		s = p;
+ 		while ( *s && *s != DXI_VAL_SEP && *s != DXI_ATR_SEP
+ 		    && *s != DXI_DNS_SEP )
+ 			s++;
+ 		save = *s;
+ 		*s = '\0';
+ 
+ 		if ( *p == DXI_ATEND_FLAG ) {
+ 			char		*last;
+ 			unsigned long	len;
+ 
+ 			/* 
+ 			 * find the end of the packet - what we want should
+ 			 * be just after that
+ 			 */
+ 
+ 			last = strchr( s + 1, '\0' );
+ 			last++;
+ 
+ 			(void) memcpy( (char *) &len, last, sizeof(len) );
+ 
+ 			if ( (av[i] = (char *) malloc( len + 4 )) == NULL )
+ 				return( (char **) 0 );
+ 
+ 			(void) memcpy( av[i], last, len + 4 );
+ 		} else {
+ 			av[i] = (char *) strdup( p );
+ 			if ( dxi_not61 )
+ 				dxi_det61( av[i] );
+ 		}
+ 
+ 		*s = save;
+ 		p = s + 1;
+ 	}
+ 	av[num] = NULL;
+ 
+ 	return( av );
+ }
+ 
+ void dxi_valuefree( char **av )
+ {
+ 	int	i;
+ 
+ 	if ( av == (char **) 0 )
+ 		return;
+ 
+ 	for ( i = 0; av[i] != NULL; i++ )
+ 		free( av[i] );
+ 	free( av );
+ }
+ 
+ char *dxi_lastdncomp( char *dn )
+ {
+ 	char	*p;
+ 
+ 	if ( (p = strrchr( dn, '@' )) == NULL )
+ 		p = dn;
+ 
+ 	while ( *p && *p != '=' ) p++;
+ 
+ 	return( ++p );
+ }
+ 
+ #ifdef DOS
+ /* for some reason, this wasn't working in dos, so we write our own! */
+ static char *mystrcat( char *a, char *b )
+ {
+ 	char	*save = a;
+ 
+ 	while ( *a )
+ 		a++;
+ 
+ 	while ( *a++ = *b++ )
+ 		;	/* NULL */
+ 
+ 	return( save );
+ }
+ #endif
+ 
+ /*
+  * dxi_dn2ufn returns the ufn representation of dn.  dn may be trashed.
+  */
+ 
+ char *dxi_dn2ufn( char *dn )
+ {
+ 	char		*p;
+ 	int		first;
+ 	static char	buf[512];
+ 
+ 	buf[0] = '\0';
+ 	first = 1;
+ 	while ( (p = strrchr( dn, '=' )) != NULL ) {
+ 		if ( first == 0 )
+ #ifdef DOS
+ 			mystrcat( buf, ", " );
+ #else
+ 			strcat( buf, ", " );
+ #endif
+ 		else
+ 			first = 0;
+ 
+ #ifdef DOS
+ 		mystrcat( buf, p + 1 );
+ #else
+ 		strcat( buf, p + 1 );
+ #endif
+ 
+ 		if ( (p = strrchr( dn, '@' )) != NULL )
+ 			*p = '\0';
+ 		else
+ 			break;
+ 	}
+ 
+ 	return( buf );
+ }
+ 
+ #define T61	"{T.61}"
+ #define T61LEN	6
+ 
+ void dxi_det61( char *s )
+ {
+ 	char	*next = s;
+ 	int	c, hex;
+ 
+ 	while ( *s ) {
+ 		switch ( *s ) {
+ 		case '{' :
+ 			if ( strncasecmp( s, T61, T61LEN) == 0 ) {
+ 				s += T61LEN;
+ 			} else {
+ 				*next++ = *s++;
+ 			}
+ 			break;
+ 
+ 		case '\\':
+ 			c = *(s + 1);
+ 			if ( c == '\n' ) {
+ 				s++;
+ 				*next++ = *s++;
+ 				break;
+ 			      }
+ 			if ( isdigit( c ) )
+ 				hex = c - '0';
+ 			else if ( isupper( c ) )
+ 				hex = c - 'A' + 10;
+ 			else
+ 				hex = c - 'a' + 10;
+ 			hex <<= 4;
+ 			c = *(s + 2);
+ 			if ( isdigit( c) )
+ 				hex += c - '0';
+ 			else if ( isupper( c ) )
+ 				hex += c - 'A' + 10;
+ 			else
+ 				hex += c - 'a' + 10;
+ 
+ 			*next++ = hex;
+ 			s += 3;
+ 			break;
+ 
+ 		default:
+ 			*next++ = *s++;
+ 			break;
+ 		}
+ 	}
+ 	*next = '\0';
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/read.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/read.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/read.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,68 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  show.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include <stdio.h>
+ #include "dixie.h"
+ #include <string.h>
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int scope );
+ 
+ 
+ /*
+  * dxi_read - do a dixie (X.500) read operation.  The DN of the entry to
+  * read is supplied (in text form), along with the attributes to read
+  * (in attrs).  Attrs is a null-terminated array of attribute types to
+  * be returned, NULL if all attrs are wanted.  The result of the read
+  * is passed back in ans, which should point to enough space.
+  *
+  * Example:
+  *	char	*attrs[] = { "cn", "sn", "mail", 0 };
+  *	dxi_read( "c=us at cn=bob", attrs, answerbuffer )
+  */
+ 
+ int dxi_read( char *who, char **attrs, char *ans )
+ {
+ 	int		i, len;
+ 	extern char	*dxi_buffer;
+ 	extern int	dxi_errno;
+ 
+ 	if ( attrs == NULL ) {
+ 		strcpy( dxi_buffer, who );
+ 		len = strlen( who );
+ 		dxi_buffer[len++] = '\0';
+ 		dxi_buffer[len++] = '\0';
+ 	} else {
+ 		strcpy( dxi_buffer, who );
+ 		len = strlen( who );
+ 		for ( i = 0; attrs[i] != NULL; i++ ) {
+ 			dxi_buffer[len++] = DXI_VAL_SEP;
+ 			dxi_buffer[len] = '\0';
+ 			strcat( dxi_buffer, attrs[i] );
+ 			len += strlen( attrs[i] );
+ 		}
+ 		for ( i = 0; i < len; i++ ) {
+ 			if ( dxi_buffer[i] == DXI_VAL_SEP )
+ 				dxi_buffer[i] = '\0';
+ 		}
+ 		dxi_buffer[++len] = '\0';
+ 		len++;
+ 	}
+ 
+ 	/* and now ship it */
+ 	if ( (i = dxi_send( DXI_READ, dxi_buffer, len, ans, MAX_PKT_SIZE, 0 ))
+ 	    == -1 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( -1 );
+ 	}
+ 	dxi_errno = ans[DXI_H_RC];
+ 
+ 	return( dxi_errno == DXI_SUCCESS ? 0 : -1 );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/remove.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/remove.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/remove.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,45 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  remove.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include <stdio.h>
+ #include "dixie.h"
+ #include <string.h>
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int scope );
+ 
+ /*
+  * dxi_remove - do a dixie (X.500) remove operation.  The DN of the entry to
+  * remove is supplied (in text form).
+  *
+  * Example:
+  *	dxi_remove( "c=us at cn=bob" )
+  */
+ 
+ int dxi_remove( char *who )
+ {
+ 	int		len;
+ 	char		ans[ DXI_H_SIZE + 1 ];
+ 	extern char	*dxi_buffer;
+ 	extern int	dxi_errno;
+ 
+ 	strcpy( dxi_buffer, who );
+ 	len = strlen( dxi_buffer ) + 1;
+ 
+ 	/* ship it */
+ 	if ( dxi_send( DXI_REMOVE, dxi_buffer, len, ans, sizeof(ans), 0 )
+ 	    == -1 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( -1 );
+ 	}
+ 	dxi_errno = ans[DXI_H_RC];
+ 
+ 	return( dxi_errno == DXI_SUCCESS ? 0 : -1 );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/search.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/search.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/search.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,79 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  search.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include <ctype.h>
+ #include <stdio.h>
+ #include "dixie.h"
+ #include <string.h>
+ 
+ extern int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int scope );
+ 
+ /*
+  * dxi_search - do a dixie (X.500) search operation.  Parameters are
+  * 	base:		text form of the DN to start the search at
+  *	scope:		the search scope (see dixie.h)
+  *	filter:		a string containing the filter (e.g., cn~=bob)
+  *	attrlist:	list of attribute types to return for matches
+  *	answer:		buffer where the result will be placed
+  *
+  * Example:
+  *	char	*attrs[] = { "mail", "title", 0 };
+  *	dxi_search( "c=us at o=university of michigan", DXI_SRCH_SUBTREE,
+  *	    "cn~=bob", attrs, answerbuffer )
+  */
+ 
+ int dxi_search( char *base, int scope, char *filter, char *attrlist[], char *answer )
+ {
+ 	int	i, len, rc;
+ 	extern char	*dxi_buffer;
+ 	extern int	dxi_errno;
+ 	extern int	dxi_limitiserror;
+ 
+ 	dxi_errno = DXI_SUCCESS;
+ 
+ 	strcpy( dxi_buffer, base );
+ 	len = strlen( base );
+ 	dxi_buffer[len++] = DXI_VAL_SEP;
+ 	dxi_buffer[len] = '\0';
+ 	strcat( dxi_buffer, filter );
+ 	len += strlen( filter );
+ 	if ( attrlist == NULL ) {
+ 		dxi_buffer[len++] = '\0';
+ 	} else {
+ 		for ( i = 0; attrlist[i] != NULL; i++ ) {
+ 			dxi_buffer[len++] = DXI_VAL_SEP;
+ 			dxi_buffer[len] = '\0';
+ 			strcat( dxi_buffer, attrlist[i] );
+ 			len += strlen( attrlist[i] );
+ 		}
+ 		dxi_buffer[++len] = '\0';
+ 	}
+ 	for ( i = 0; i < len; i++ ) {
+ 		if ( dxi_buffer[i] == DXI_VAL_SEP )
+ 			dxi_buffer[i] = '\0';
+ 	}
+ 
+ 	/* ship it */
+ 	if ( (rc = dxi_send( DXI_SEARCH_GEN, dxi_buffer, len, answer,
+ 	    MAX_PKT_SIZE, scope )) < 0 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( rc );
+ 	}
+ 
+ 	dxi_errno = answer[DXI_H_RC];
+ 	if ( dxi_limitiserror )
+ 		return( dxi_errno == DXI_SUCCESS || dxi_errno == DXI_NOTFOUND
+ 		    ? 0 : -1 );
+ 	else
+ 		return( dxi_errno == DXI_SUCCESS || dxi_errno == DXI_SIZELIMIT
+ 		    || dxi_errno == DXI_TIMELIMIT || dxi_errno == DXI_NOTFOUND
+ 		    ? 0 : -1 );
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/send.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/send.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/send.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,500 ----
+ /*
+  *  Copyright (c) 1990 Regents of the University of Michigan.
+  *  All rights reserved.
+  *
+  *  send.c
+  */
+ 
+ #ifndef lint 
+ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+ #endif
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include "dixie.h"
+ #include <string.h>
+ #if !defined(__STDC__) && !defined(VMS)
+ #include <memory.h>
+ #endif
+ #if defined(MACOS)
+ #include "tcp.h"
+ #else
+ #ifdef VMS
+ #include <types.h>
+ #include <in.h>
+ #include <signal.h>
+ #else
+ #include <sys/types.h>
+ #include <sys/uio.h>
+ #include <netinet/in.h>
+ #endif
+ #include <sys/param.h>
+ #include <sys/time.h>
+ #include <sys/socket.h>
+ #include <netdb.h>
+ #include <arpa/inet.h>
+ #include <arpa/nameser.h>
+ #include <resolv.h>
+ #include <errno.h>
+ #include <sys/ioctl.h>
+ #include <unistd.h>
+ #endif
+ 
+ #define MAX_RETRY		3
+ #define MAX_DIXIE_SERVERS	5
+ 
+ #define DXI_GETLEN(x, y) { (void) memcpy( (char *) &x, &y[DXI_H_TOTLEN], \
+ 			sizeof(long)); x = ntohl(x);}
+ #define DXI_GETID(x, y) { (void) memcpy( (char *) &x, &y[DXI_H_ID], \
+ 			sizeof(short));}
+ #define DXI_SETID(x, y) { (void) memcpy( (char *) &y[DXI_H_ID], (char *) &x, \
+ 			sizeof(short));}
+ #define DXI_SETOP(x, y) { (void) memcpy( (char *) &y[DXI_H_OP], (char *) &x, \
+ 			sizeof(short));}
+ #define DXI_SETSCOPE(x, y) {y[DXI_H_SRCH_SCOPE] = x;}
+ #define DXI_SETVERSION(x, y) {y[DXI_H_VERSION] = x;}
+ #define DXI_SETOPTIONS(x, y) {y[DXI_H_OPTIONS] = x;}
+ #define DXI_SETTIMELIMIT(x, y) { (void) memcpy( &y[DXI_H_TIMELIMIT], \
+ 			(char *) &x, sizeof(short));}
+ #define DXI_SETSIZELIMIT(x, y) { (void) memcpy( &y[DXI_H_SIZELIMIT], \
+ 			(char *) &x, sizeof(short));}
+ 
+ extern void *memset(void *s, int c, size_t n);
+ extern int errno, dxi_debug, dxi_timeout, dxi_retries;
+ extern char dxi_options;
+ 
+ #ifndef INADDR_LOOPBACK
+ #define INADDR_LOOPBACK 0x7f000001
+ #endif
+ 
+ #ifndef FD_SET
+ #define	NFDBITS		32
+ #define	FD_SETSIZE	32
+ #define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
+ #define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
+ #define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
+ #define FD_ZERO(p)	(void) memset((char *)(p), 0, sizeof(*(p)))
+ #endif
+ 
+ #ifndef VMS
+ char    *h_errlist[] = {
+ 	"Error 0",
+ 	"Unknown host",                         /* 1 HOST_NOT_FOUND */
+ 	"Host name lookup failure",             /* 2 TRY_AGAIN */
+ 	"Unknown server error",                 /* 3 NO_RECOVERY */
+ 	"No address associated with name",      /* 4 NO_ADDRESS */
+ };
+ #endif
+ 
+ static int			s = -1;		/* socket used for UDP */
+ #if defined(MACOS) || defined(DOS)
+ ip_addr				dixieaddr;	/* address of dixie server */
+ #else
+ void attempt_rebind();
+ struct sockaddr_in		dixieaddr;	/* address of dixie server */
+ extern int nullbound;
+ #endif
+ static int			servers;
+ static char		*dxibuf;
+ 
+ #if !defined(NOUDP) && !defined(VMS_MULTINET)
+ int xres_selwait(int sock, struct timeval *timeout)
+ {
+         fd_set dsmask;
+         register int n;
+ 
+         FD_ZERO(&dsmask);
+         FD_SET(sock, &dsmask);
+         n = select(sock+1, &dsmask, (fd_set *)NULL, (fd_set *)NULL, timeout);
+         return(n);
+ }
+ #endif /* !NOUDP & !vms_multinet */
+ 
+ int dxi_send( char type, char *buf, int buflen, char *answer, int anslen, int scope )
+ {
+ 	int			i, n;
+ 	int			retry;
+ 	long		resplen, totlen;
+ 	short			nshort;
+ #ifndef NOUDP
+ 	struct timeval		timeout;
+ #endif
+ 	static unsigned short 	id = 0;
+ 	extern int		dxi_bound;
+ 
+ 	if ( dxibuf == NULL )
+ 		dxibuf = (char *) calloc( MAX_PKT_SIZE + DXI_H_SIZE, 1 );
+ 
+ 	/*
+ 	 *  First, we need to take the buffer we were given and the type
+ 	 *  that was specified and build a valid packet.  The query type
+ 	 *  should be put in the first byte of the header, which should
+ 	 *  then be padded out with zeroes.
+ 	 *
+ 	 *  Then update the buffer size to reflect the addition of the
+ 	 *  header and point buffer to the newly formed packet.
+ 	 */
+ 
+ 	bzero(dxibuf, DXI_H_SIZE);
+ 	DXI_SETOP(type, dxibuf);
+ 	DXI_SETSCOPE(scope, dxibuf);
+ 	DXI_SETVERSION(1, dxibuf);
+ 	DXI_SETOPTIONS(dxi_options, dxibuf);
+ 	DXI_SETTIMELIMIT(dxi_timelimit, dxibuf);
+ 	DXI_SETSIZELIMIT(dxi_sizelimit, dxibuf);
+ 	(void) memcpy(&dxibuf[DXI_H_SIZE], buf, buflen);
+ 	buflen += DXI_H_SIZE;
+ 	buf = dxibuf;
+ 
+ 	/* use the default DIXIE server if none defined */
+ 	if (servers == 0)
+ 		add_server(INADDR_LOOPBACK);
+ 	id++;
+ 	nshort = htons(id);
+ 
+ 	/* if bound to a DSA use our open TCP socket */
+ 	if (dxi_bound >= 0) {
+ 		(void) memcpy( &buf[DXI_H_ID], (char *) &nshort, sizeof(short));
+ 		(void) memset( answer, 0, DXI_H_SIZE );
+ #ifdef DEBUG
+ 		if (dxi_debug > 5) {
+ 			printf("Sending (%d) over TCP:\n", buflen);
+ 			dxi_bprint(buf, buflen);
+ 		}
+ #endif
+ 
+ #if defined(DOS) || defined(MACOS) || defined VMS_MULTINET
+ #ifdef DOS
+ 		if ( netwrite( dxi_bound, (u_char *) buf, buflen ) < 0 ) {
+ 			return( -1 );
+ 		}
+ 		if ( (resplen = nread( dxi_bound, answer, anslen )) < 0 ) {
+ 			return( -1 );
+ 		}
+ #else /* macos or vms */
+ #ifdef MACOS
+ 		if (tcpwrite(dxi_bound, (u_char *)buf, buflen ) != 0 ) {
+ 			return(-1);
+ 		}
+ 		if ((resplen = tcpread(dxi_bound, 0, (u_char *)answer, anslen, (DialogPtr)NULL )) < 0 ) {
+ 			return( -1 );
+ 		}
+ #else /* vms */
+                 while (TRUE)
+                 {
+                     if (socket_write(dxi_bound, buf, buflen) != buflen)
+                         if (socket_errno == EWOULDBLOCK)
+                         {
+                             continue;
+                         }
+                         else
+                         {
+                             socket_perror("write");
+                             return(-1);
+                         };
+                     break;
+                 }
+                 while (TRUE)
+                 {
+                     if ((resplen = socket_read(dxi_bound, answer, anslen)) < 0)
+                         if (socket_errno == EWOULDBLOCK)
+                         {
+                             continue;
+                         }
+                         else
+                         {
+                             socket_perror("read");
+                             return(-1);
+                         };
+                     break;
+                 }
+ #endif /* vms */
+ #endif /* macos or vms */
+ #else /* unix */
+ 		for ( i = 0; i < 2; i++ ) {
+ 			if (write(dxi_bound, buf, buflen) != buflen) {
+ 				if ( dxi_bound >= 0 )
+ 					close( dxi_bound );
+ 				dxi_bound = -1;
+ 
+ 				if ( ! nullbound )
+ 					return( -1 );
+ 
+ 				(void) dxi_bind( NULL, NULL );
+ 				continue;
+ 			}
+ 
+ 			if ((resplen = read(dxi_bound, answer, anslen)) <= 0) {
+ 				if ( dxi_bound >= 0 )
+ 					close( dxi_bound );
+ 				dxi_bound = -1;
+ 
+ 				if ( ! nullbound )
+ 					return( -1 );
+ 
+ 				(void) dxi_bind( NULL, NULL );
+ 				continue;
+ 			}
+ 			break;
+ 		}
+ 
+ 		if ( dxi_bound < 0 ) {
+ 			return(-1);
+ 		}
+ #endif
+ 		DXI_GETLEN( totlen, answer );
+ 		totlen += DXI_H_SIZE;
+ 		n = resplen;
+ 		if ( dxi_debug > 5 ) printf("totlen is %d\n", totlen );
+ 		while ( resplen < totlen ) {
+ 			if ( dxi_debug > 5 ) 
+ 				printf("...%d to go\n", totlen - resplen);
+ #if defined(DOS) || defined(MACOS) || defined(VMS_MULTINET)
+ #ifdef DOS
+ 			if ( (n = nread( dxi_bound, answer + resplen,
+ 			    totlen - n )) < 0 ) {
+ 				return( -1 );
+ 			}
+ #else /* MACOS or VMS_MULTINET */
+ #ifdef MACOS
+ 			if ((n = tcpread( dxi_bound, 0, (u_char *)answer + resplen, totlen - n,
+ 				(DialogPtr)NULL )) < 0 ) {
+ 				return( -1 );
+ 			}
+ #else /* VMS_MULTINET */
+ 			if ( (n = socket_read( dxi_bound, answer + resplen,
+ 				totlen - n )) < 0 ) {
+ 			        socket_perror( "read" );
+ 				return( -1 );
+ 			}
+ #endif /* MACOS */
+ #endif /* MACOS or VMS_MULTINET */
+ #else /* UNIX */
+ 			if ( (n = read( dxi_bound, answer + resplen,
+ 			    totlen - n )) <= 0 ) {
+ 				perror( "read" );
+ 				return( -1 );
+ 			}
+ #endif
+ 			if ( dxi_debug > 5 ) 
+ 				printf("...read %d\n", n );
+ 			resplen += n;
+ 		}
+ #ifdef DEBUG
+ 		if (dxi_debug > 5) {
+ 			printf("Received (%d):\n", resplen);
+ 			dxi_bprint(answer, resplen);
+ 		}
+ #endif
+ 		return(resplen);
+ 	}
+ 
+ 	/*
+ 	 *  OK, we weren't bound, so we'll need to use UDP.
+ 	 */
+ #ifndef NOUDP
+ 
+ 	/* Get a socket if we don't already have one */
+ 	if ( s < 0 ) {
+ 		if ( (s = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) {
+ 			perror( "socket" );
+ 			return( -1 );
+ 		}
+ 	}
+ 
+ 	DXI_SETID( nshort, buf );
+ 	(void) memset( answer, 0, DXI_H_SIZE );
+ 	timeout.tv_sec = 0;
+ 	timeout.tv_usec = 0;
+ 	for ( retry = 0; retry < dxi_retries; retry++ ) {
+ #ifdef DEBUG
+ 		if ( dxi_debug & 4 ) {
+ 			printf("Sending (%d) try #%d:\n", buflen, retry);
+ 			dxi_bprint( buf, buflen );
+ 		}
+ #endif
+ 		if ( sendto( s, buf, buflen, 0, (struct sockaddr *)&dixieaddr,
+ 		    sizeof(struct sockaddr)) < 0 ) {
+ 			perror( "sendto" );
+ 			return( -1 );
+ 		}
+ 
+ 		/* wait for a reply (exponential back off) */
+ 		timeout.tv_sec = timeout.tv_sec == 0 ? dxi_timeout
+ 		    : 2 * timeout.tv_sec;
+ 		timeout.tv_usec = 0;
+ 
+ wait:
+ #ifndef VMS_MULTINET
+ 		if ( (n = xres_selwait( s, &timeout )) < 0 ) {
+ 			perror( "xres_selwait" );
+ 			continue;
+ 		}
+ 
+ 		/* timed out */
+ 		if (n == 0)
+ 			continue;
+ 
+ 		/* didn't timeout -- read the packet */
+ 		if ( (resplen = recv( s, answer, anslen, 0 )) < 0 ) {
+ 			perror( "recv" );
+ 			return( -1 );
+ 		}
+ #endif
+ #ifdef DEBUG
+ 		if ( dxi_debug & 4 ) {
+ 			printf("Received (%d):\n", resplen);
+ 			dxi_bprint( answer, resplen );
+ 		}
+ #endif
+ 		/*
+ 		 *  Fetch out the id, convert it to host order
+ 		 *  and see if its in response to the current request.
+ 		 */
+ 
+ 		DXI_GETID( nshort, answer );
+ 		if ( id != (nshort = ntohs(nshort)) ) {
+ 			if ( dxi_debug & 4 )
+ 				printf("expecting id %d got %d\n", id, nshort);
+ 			goto wait;
+ 		}
+ 
+ 		DXI_GETLEN( totlen, answer );
+ 		if ( totlen + DXI_H_SIZE != resplen ) {
+ 			answer[DXI_H_RC] = DXI_TOOBIG;
+ 			return( DXI_H_SIZE );
+ 		}
+ 
+ 		return( resplen );
+ 	}
+ 
+ 	if (s >= 0) {
+ #ifdef VMS_MULTINET
+ 		(void) socket_close( s );
+ #else
+ 		(void) close( s );
+ #endif /* vms */
+ 		s = -1;
+ 	}
+ #ifdef VMS_MULTINET
+ 	socket_errno = ETIMEDOUT;
+ #else
+ 	errno = ETIMEDOUT;
+ #endif /* vms */
+ #endif
+ 
+ 	return (-1);
+ }
+ 
+ #if defined(MACOS) || defined(DOS)
+ int open_sock(unsigned long address, short port)
+ {
+ 	short	s;
+ 	
+ 	if (( s = tcpopen( NULL, TCP_BUFSIZ )) < 0 ) {
+ 		return( s );
+ 	}
+ 	
+ 	if ( tcpconnect( s, address, port ) < 0 ) {
+ 		return( -1 );
+ 	}
+ 	
+ 	return( s );
+ }
+ #else
+ int open_sock( unsigned long address, int port )
+ {
+ 	int s;
+ 	struct sockaddr_in sock;
+ 
+ 	sock.sin_addr.s_addr = htonl( address );
+ 	sock.sin_family = AF_INET;
+ 	sock.sin_port = htons( port );
+ 	if ( (s = socket( AF_INET, SOCK_STREAM, 0 )) < 0 ) {
+ 		dxi_errno = DXI_ERROR;
+ 		return( s );
+ 	}
+ 	if ( connect( s, (struct sockaddr *) &sock, sizeof(sock) ) < 0 ) {
+ 		dxi_errno = DXI_DOWN;
+ 		return( -1 );
+ 	}
+ 	if (dxi_debug) printf("open_sock returning %d\n", s);
+ 	return( s );
+ }
+ #endif
+ 
+ int add_server( u_long ns )
+ {
+ #if !defined(MACOS) & !defined(DOS)
+ 	struct hostent *hp;
+ 	struct servent *sp;
+ 	struct in_addr in;
+ 	extern int h_errno;
+ #endif
+ 	int port;
+ 
+ 	/* give up if earlier routines failed */
+ 	if ( ns == 0 ) return( -1 );
+ 
+ 	/* DIXIE port? */
+ #if defined(MACOS) || defined(DOS)
+ 	port = DXI_PORT;
+ 	dixieaddr = ns;
+ #else
+ 	if ( (sp = getservbyname( "dixie", "udp" )) == NULL )
+ 		port = DXI_PORT;
+ 	else
+ 		port = sp->s_port;
+ 	in.s_addr = ns;
+ 
+ 	/* add the new server */
+ 	hp = gethostbyaddr( (char *) &in, sizeof(in), AF_INET );
+ 	if ( hp == NULL && h_errno != TRY_AGAIN ) {
+ 		return( -1 );
+ 	}
+ 	dixieaddr.sin_addr.s_addr = htonl( ns );
+ 	dixieaddr.sin_family = AF_INET;
+ 	dixieaddr.sin_port = htons( port );
+ #endif
+ 	servers = 1;
+ 
+ 	return( 0 );
+ }
+ 
+ 
+ int dxi_close(void)
+ {
+ 	extern int dxi_bound;
+ 
+ 	if (dxi_bound >= 0) {
+ #ifndef NOUDP
+ 		if ( s >= 0 ) {			/* close UDP socket */
+ 			close( s );
+ 			s = -1;
+ 		}
+ #endif
+ 
+ #if defined(MACOS) || defined(DOS)
+ 		tcpclose( dxi_bound );	/* close TCP socket */
+ #else
+ 		close( dxi_bound );		/* close TCP socket */
+ #endif
+ 	}
+ 	
+ 	if (dxi_debug) printf("**** dxi_close ****\n");
+ 	dxi_bound = -1;
+ 	if ( dxibuf != NULL ) {		/* free the message buffer */
+ 		free( dxibuf );
+ 		dxibuf = NULL;
+ 	}
+ 	return -99;
+ }
+ 
+ #if !defined(MACOS) && !defined(DOS)
+ 
+ void attempt_rebind(void)
+ {
+ 
+ }
+ 
+ #endif


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/test.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/test.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/test.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,297 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <ctype.h>
+ #include "dixie.h"
+ #include <string.h>
+ #if !defined(__STDC__) && !defined(VMS)
+ #include <memory.h>
+ #endif
+ #if defined(MACOS) || defined(DOS)
+ #include <memory.h>
+ #include <stdlib.h>
+ #endif
+ 
+ extern char *dxi_dn2ufn( char *dn );
+ 
+ static char *getlinex( char *line, int len, FILE *s, char *prompt )
+ {
+ 	printf(prompt);
+ 
+ 	if ( fgets( line, len, s ) == NULL ) {
+ 		dxi_close();
+ 		exit( 0 );
+ 	}
+ 
+ 	line[ strlen( line ) - 1 ] = '\0';
+ 
+ 	return( line );
+ }
+ 
+ static void print_listpacket( char *ans )
+ {
+ 	char	*entry, *dn;
+ 	int	i;
+ 
+ 	if ( (i = dxi_matches( ans )) != -1 )
+ 		printf("%d matches:\n", i);
+ 
+ 	for ( entry = dxi_firstentry( ans ); entry != NULL;
+ 	    entry = dxi_nextentry() ) {
+ 		dn = dxi_getdn( entry );
+ 		printf("\t%s\n", dn);
+ 		printf("\t(UFN) %s\n", dxi_dn2ufn( dn ));
+ 		free( dn );
+ 	}
+ }
+ 
+ static void print_packet( char *ans )
+ {
+ 	char	*entry, *at, *dn;
+ 	char	**av;
+ 	int	i;
+ 
+ 	/*
+ 	 * step through each attr type in attrs and print the
+ 	 * corresponding values
+ 	 */
+ 
+ 	if ( (i = dxi_matches( ans )) != -1 )
+ 		printf("%d matches:\n", i);
+ 
+ 	for ( entry = dxi_firstentry( ans ); entry != NULL;
+ 	    entry = dxi_nextentry() ) {
+ 		dn = dxi_getdn( entry );
+ 		printf("\n%s\n", dn);
+ 		printf("(UFN) %s\n", dxi_dn2ufn( dn ));
+ 		free( dn );
+ 
+ 		for ( at = dxi_firstattr( entry ); at != NULL;
+ 		    at = dxi_nextattr( at ) ) {
+ 			printf("\t%s\n", at);
+ 			av = dxi_getvalues( entry, at );
+ 			if ( av == (char **) 0 )
+ 				printf("\t\t*** NO VALUES ***\n");
+ 			else {
+ 				if ( strcmp( at, "photo" ) == 0 ) {
+ 					unsigned long	len;
+ 
+ 					(void) memcpy( (char *) &len, av[0],
+ 					    sizeof(len) );
+ 					printf("\t\t%d bytes of %s photo\n",
+ 					    len, av[0][4] == DXI_PHOTO_JPEG ?
+ 					    "JPEG" : "G3Fax");
+ 				} else {
+ 					for ( i = 0; av[i] != NULL; i++ ) {
+ 						printf("\t\t%s\n", av[i]);
+ 					}
+ 				}
+ 				dxi_valuefree( av );
+ 			}
+ 		}
+ 	}
+ }
+ 
+ static char **get_list( char *prompt )
+ {
+ 	static char	buf[256];
+ 	int		num;
+ 	char		**result;
+ 
+ 	num = 0;
+ 	result = (char **) 0;
+ 	while ( 1 ) {
+ 		getlinex( buf, sizeof(buf), stdin, prompt );
+ 
+ 		if ( *buf == '\0' )
+ 			break;
+ 
+ 		if ( result == (char **) 0 )
+ 			result = (char **) malloc( sizeof(char *) );
+ 		else
+ 			result = (char **) realloc( result,
+ 			    sizeof(char *) * (num + 1) );
+ 
+ 		result[num++] = (char *) strdup( buf );
+ 	}
+ 	if ( result == (char **) 0 )
+ 		return( NULL );
+ 	result = (char **) realloc( result, sizeof(char *) * (num + 1) );
+ 	result[num] = NULL;
+ 
+ 	return( result );
+ }
+ 
+ int main( int argc, char **argv )
+ {
+ 	char	*ans;
+ 	int	alen;
+ 	char	line[256], command, *lp;
+ 	char	searchattr[80], attr[180], who[256];
+ 	char	new1[80], value[256];
+ 	int	genscope;
+ 	char	**entry;
+ 	extern int	dxi_debug;
+ 
+ 	if (( ans = (char *) malloc( MAX_PKT_SIZE )) == NULL ) {
+ 		perror( "malloc" );
+ 		exit(1);
+ 	}
+ #if defined(MACOS) || defined(DOS)
+ 	getlinex( line, sizeof(line), stdin, "dixie server? " );
+ 	if ( dxi_init( line, 2, 4 ) != 0 ) {
+ #else
+ 	if ( dxi_init( argc > 1 ? argv[1] : NULL, 2, 4 ) != 0 ) {
+ #endif
+ 		perror( "dxi_init" );
+ 		exit(1);
+ 	}
+ 
+ 	while ( getlinex( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) {
+ 		command = line[0];
+ 		for ( lp = line; *lp && !isspace(*lp); lp++ )
+ 			;	/* NULL */
+ 		
+ 		alen = 0;
+ 		switch ( command ) {
+ 		case 'l':	/* list */
+ 			getlinex( who, sizeof(who), stdin, "dn? " );
+ 
+ 			alen = dxi_list( who, ans );
+ 			break;
+ 
+ 		case 'r':	/* read */
+ 			getlinex( who, sizeof(who), stdin, "dn? " );
+ 			entry = get_list( "attr to return? " );
+ 
+ 			alen = dxi_read( who, entry, ans );
+ 			break;
+ 
+ 		case 's':	/* search */
+ 			getlinex( who, sizeof(who), stdin, "searchbase? " );
+ 			getlinex( line, sizeof(line), stdin,
+ 			    "scope (1=Base, 2=One Level, 3=Subtree)?" );
+ 			genscope = atoi( line );
+ 			getlinex( searchattr, sizeof(searchattr), stdin,
+ 			    "search filter (e.g. sn=jones)? " );
+ 			entry = get_list( "attr to return? " );
+ 
+ 			alen = dxi_search( who, genscope, searchattr, entry,
+ 			    ans );
+ 			break;
+ 
+ 		case 'm':	/* modify */
+ 			getlinex( who, sizeof(who), stdin, "dn? " );
+ 			entry = get_list( "modify list? " );
+ 
+ 			alen = dxi_modify( who, entry );
+ 
+ 			dxi_valuefree( entry );
+ 			break;
+ 
+ 		case 'a':	/* add */
+ 			getlinex( who, sizeof(who), stdin, "dn? " );
+ 			entry = get_list( "attr to return? " );
+ 
+ 			alen = dxi_add( who, entry );
+ 
+ 			dxi_valuefree( entry );
+ 			break;
+ 
+ 		case 'v':	/* remove */
+ 			getlinex( who, sizeof(who), stdin, "dn? " );
+ 
+ 			alen = dxi_remove( who );
+ 			break;
+ 
+ 		case 'c':	/* modify rdn */
+ 			getlinex( who, sizeof(who), stdin, "olddn? " );
+ 			getlinex( new1, sizeof(new1), stdin, "newrdn? " );
+ 
+ 			alen = dxi_modrdn( who, new1 );
+ 			break;
+ 
+ 		case 'p':	/* compare */
+ 			getlinex( who, sizeof(who), stdin, "dn? " );
+ 			getlinex( attr, sizeof(attr), stdin, "attr? " );
+ 			getlinex( value, sizeof(value), stdin, "value? " );
+ 			if ( (alen = dxi_compare( who, attr, value )) == -1 )
+ 				break;
+ 			printf("%d\n", alen);
+ 			continue;
+ 
+ 		case 'u':	/* udp bind */
+ 			getlinex( who, sizeof(who), stdin, "dn? " );
+ 			getlinex( line, sizeof(line), stdin, "password? " );
+ 
+ 			alen = dxi_udpbind( who, line );
+ 			break;
+ 
+ 		case 'b':	/* tcp bind */
+ 			getlinex( who, sizeof(who), stdin, "dn? " );
+ 			if ( who[0] != '\0' )
+ 				getlinex( line, sizeof(line), stdin,
+ 				    "password? " );
+ 			else
+ 				line[0] = '\0';
+ 
+ 			alen = dxi_bind( who, line );
+ 			break;
+ 
+ 		case 'd':	/* turn on debugging */
+ 			getlinex( line, sizeof(line), stdin, "debug level? " );
+ 			dxi_debug = atoi( line );
+ 			continue;
+ 			break;
+ 
+ 		case 'o':	/* set dxi_options, size & time limits */
+ 			getlinex( line, sizeof(line), stdin,
+ 			   "options (not61 or s# or t# or #)? " );
+ 			if ( line[0] == 's' )
+ 				dxi_sizelimit = atoi( line + 1 );
+ 			else if ( line[0] == 't' )
+ 				dxi_timelimit = atoi( line + 1 );
+ 			else if ( line[0] == 'n' )
+ 				dxi_not61 = 1;
+ 			else
+ 				dxi_options = atoi( line );
+ 			continue;
+ 			break;
+ 
+ 		case 'q':	/* quit */
+ 			dxi_close();
+ 			exit( 0 );
+ 			break;
+ 
+ 		case '?':	/* help */
+ 			printf("Commands: [r]ead, [s]earch, [m]odify, ");
+ 			printf("[b]ind, [l]ist, [q]uit, [d]ebug, [?]help\n");
+ 			printf("          [a]dd, remo[v]e, [c]modifyrdn, ");
+ 			printf("[u]dpbind [o]ptions [p]compare\n");
+ 			continue;
+ 			break;
+ 
+ 		default:
+ 			printf("Invalid command.  Type ? for help.\n");
+ 			continue;
+ 			break;
+ 		}
+ 
+ 		line[ 0 ] = command;
+ 		line[ 1 ] = '\0';
+ 		
+ 		if ( alen < 0 ) {	/* alen < 0 is an error */
+ 			dxi_perror( line );
+ 		} else {		/* alen == 0 might be OK */
+ 			if ( dxi_errno != DXI_SUCCESS )
+ 				dxi_perror( line );
+ 
+ 			if ( command == 's' || command == 'r' )
+ 				print_packet( ans );
+ 			else if ( command == 'l' )
+ 				print_listpacket( ans );
+ 		} 
+ 	}
+ 
+ 	dxi_close();
+ 	return 0;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/util.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/util.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/util.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,94 ----
+ #include "dixie.h"
+ #include <string.h>
+ #if defined(MACOS) || defined(DOS)
+ #include <stdlib.h>
+ #include <stdio.h>
+ #endif
+ #include <ctype.h>
+ 
+ /*
+  * Print arbitrary stuff, for debugging.
+  */
+ 
+ #ifdef DEBUG
+ 
+ #define BPLEN	48
+ 
+ void dxi_bprint( char *data, int len )
+ {
+     static char	hexdig[] = "0123456789abcdef";
+     char	out[ BPLEN ];
+     int		i = 0;
+ 
+     bzero( out, BPLEN );
+     for ( ;; ) {
+ 	if ( len < 1 ) {
+ 	    printf( "\t%s\n", ( i == 0 ) ? "(end)" : out );
+ 	    break;
+ 	}
+ 
+ 	if ( isgraph( (unsigned char)*data )) {
+ 	    out[ i ] = ' ';
+ 	    out[ i+1 ] = *data;
+ 	} else {
+ 	    out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
+ 	    out[ i+1 ] = hexdig[ *data & 0x0f ];
+ 	}
+ 	i += 2;
+ 	len--;
+ 	data++;
+ 
+ 	if ( i > BPLEN - 2 ) {
+ 	    printf( "\t%s\n", out );
+ 	    bzero( out, BPLEN );
+ 	    i = 0;
+ 	    continue;
+ 	}
+ 	out[ i++ ] = ' ';
+     }
+ }
+ 
+ #endif
+ 
+ 
+ #ifndef DOS
+ 
+ #undef SUNOS3
+ #ifdef SUNOS3
+ char *strdup( char *p )
+ {
+ 	char	*r;
+ 
+ 	r = (char *) malloc( strlen( p ) + 1 );
+ 	strcpy( r, p );
+ 
+ 	return( r );
+ }
+ #endif
+ 
+ #ifdef NEEDINETADDR
+ /*
+  * this implementation works for decimal dot separated strings only!
+  */
+ u_long inet_addr( char *s )
+ {
+ 	int		i;
+ 	char 	*p;
+ 	u_long	addr;
+ 	
+ 	addr = 0;
+ 	
+ 	for ( i = 0; i < 3; ++i ) {
+ 		if (( p = strchr( s, '.' )) == NULL ) {
+ 			return( 0 );
+ 		}
+ 		*p = '\0';
+ 		addr += atoi( s );
+ 		addr <<= 8;
+ 		*p = '.';
+ 	}
+ 	
+ 	return( addr );
+ }
+ #endif
+ #endif


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/version.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/version.c:1.1
*** /dev/null	Tue Oct  5 14:30:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/dixie/version.c	Tue Oct  5 14:29:51 2004
***************
*** 0 ****
--- 1,13 ----
+ /*
+  * Copyright (c) 1991 Regents of the University of Michigan.
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms are permitted
+  * provided that this notice is preserved and that due credit is given
+  * to the University of Michigan at Ann Arbor. The name of the University
+  * may not be used to endorse or promote products derived from this
+  * software without specific prior written permission. This software
+  * is provided ``as is'' without express or implied warranty.
+  */
+ 
+ char Version[] = "  DIXIE library 1.1 (Fri Apr 21 16:41:40 EDT 1995)\n\txxzhang at cadenza.rutgers.edu:/a/fac/u23/xxzhang/Mod-test/dixie\n";






More information about the llvm-commits mailing list