File:  [ELWIX - Embedded LightWeight unIX -] / libaitio / example / Attic / test_n2.c
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Thu Mar 29 01:31:33 2012 UTC (12 years, 3 months ago) by misho
Branches: MAIN
CVS tags: io5_0, io4_1, io4_0, io3_9, io3_8, io3_7, io3_6, io3_5, io3_4, io3_3, io3_2, io3_1, io2_8, io2_7, io2_6, IO4_1, IO4_0, IO3_9, IO3_8, IO3_7, IO3_6, IO3_5, IO3_4, IO3_3, IO3_2, IO3_1, IO3_0, IO2_7, IO2_6, IO2_5, HEAD
version 2.5

#include <stdio.h>
#include <string.h>
#include <aitio.h>


int
main(int argc, char **argv)
{
	io_sockaddr_t addr = { 0 };
	ait_val_t v, *val = NULL;

	AIT_SET_DATA(val, "shits hit the fan! --- shits with Merudia ...\n", 47);
	printf("GET DATA = %p %s t=%d l=%d\n", val, AIT_GET_DATA(val), AIT_TYPE(val), AIT_LEN(val));
	AIT_SET_DATA(val, argv[1], strlen(argv[1]) + 1);
	AIT_FREE_VAL(val);
	AIT_SET_DATA(val, argv[1], strlen(argv[1]) + 1);
	printf("GET DATA = %p %s t=%d l=%d\n", val, AIT_GET_DATA(val), AIT_TYPE(val), AIT_LEN(val));
	AIT_FREE_VAL(val);
	free(val);

	if (!io_gethostbyname(argv[1], 1234, &addr)) {
		printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
		return 1;
	}

	if (!io_n2addr(&addr, &v)) {
		printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
		return 2;
	}

	printf("Address is %s port is %u\n", AIT_GET_STR(&v), io_n2port(&addr));

	AIT_FREE_VAL(&v);
	return 0;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>