[BACK]Return to test.c CVS log [TXT][DIR] Up to [local] / OpenXM / doc / oxlib

File: [local] / OpenXM / doc / oxlib / test.c (download)

Revision 1.1, Mon Feb 25 07:09:01 2002 UTC (22 years, 2 months ago) by noro
Branch: MAIN

A sample program file to call libasir.a.

/* $OpenXM: OpenXM/doc/oxlib/test.c,v 1.1 2002/02/25 07:09:01 noro Exp $ */
#include <asir/ox.h>

main() {
	char ibuf[BUFSIZ];
	char *s,*buf;
	int len,len0;

	asir_ox_init(1);  /* Use the network byte order */

	len0 = BUFSIZ;
	buf = (char *)malloc(len0);
	while ( 1 ) {
		fgets(ibuf,BUFSIZ,stdin);
		if ( !strncmp(ibuf,"bye",3) )
			exit(0);
		asir_ox_execute_string(ibuf);
		len = asir_ox_peek_cmo_string_length();
		if ( len > len0 ) {
			len0 = len;
			buf = (char *)realloc(buf,len0);
		}
		asir_ox_pop_string(buf,len0);
		printf("%s\n",buf);
	}
}