示例#1
0
/* read from the fd, then parse the data */
TEG_STATUS client_recv( int fd )
{
	int i,j;
	PARSER p;
	char str[PROT_MAX_LEN];
	DELIM igualador={ '=', '=', '=' };
	DELIM separador={ ';', ';', ';' };

	p.igualador = &igualador;
	p.separador = &separador;

	memset(str,0,sizeof(str));
	j=net_readline( fd, str, PROT_MAX_LEN );

	if( j<1 ) {
		teg_disconnect();
		return TEG_STATUS_CONNCLOSED;
	}

	p.data = str;

	do {
		if( (i=parser_call( &p )) ) {
			if( client_lookup( fd,&p ) == TEG_STATUS_CONNCLOSED ) {
				return TEG_STATUS_CONNCLOSED;
			}
		}
	} while( i && p.hay_otro);

	return TEG_STATUS_SUCCESS;
}
示例#2
0
文件: export.c 项目: kouril/nfs-utils
/**
 * export_create - create an in-core nfs_export record from an export entry
 * @xep: export entry to lookup
 * @canonical: if set, e_hostname is known to be canonical DNS name
 *
 * Returns a freshly instantiated export record, or NULL if
 * a problem occurred.
 */
nfs_export *
export_create(struct exportent *xep, int canonical)
{
    nfs_client	*clp;
    nfs_export	*exp;

    if (!(clp = client_lookup(xep->e_hostname, canonical))) {
        /* bad export entry; complaint already logged */
        return NULL;
    }
    exp = (nfs_export *) xmalloc(sizeof(*exp));
    export_init(exp, clp, xep);
    export_add(exp);

    return exp;
}
示例#3
0
文件: mrp.c 项目: AVnu/Open-AVB
int mrp_client_add(client_t ** list, struct sockaddr_in *newclient)
{
	client_t *client_item;

	client_item = *list;

	if (NULL == newclient)
		return -1;

	if (client_lookup(client_item, newclient))
		return 0;	/* already present */

	/* handle 1st entry into list */
	if (NULL == client_item) {
		client_item = (client_t *)malloc(sizeof(client_t));
		if (NULL == client_item)
			return -1;
		client_item->next = NULL;
		client_item->client = *newclient;
		*list = client_item;
		return 0;
	}

	while (client_item) {
		if (NULL == client_item->next) {
			client_item->next = (client_t *)malloc(sizeof(client_t));
			if (NULL == client_item->next)
				return -1;
			client_item = client_item->next;
			client_item->next = NULL;
			client_item->client = *newclient;
			return 0;
		}
		client_item = client_item->next;
	}
	return -1;
}