Blame libiscsi/tests/test_logout.c

Packit Service 37dbff
/*
Packit Service 37dbff
 * iSCSI Administration library
Packit Service 37dbff
 *
Packit Service 37dbff
 * Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved.
Packit Service 37dbff
 * Copyright (C) 2008-2009 Hans de Goede <hdegoede@redhat.com>
Packit Service 37dbff
 * maintained by open-iscsi@googlegroups.com
Packit Service 37dbff
 *
Packit Service 37dbff
 * This program is free software; you can redistribute it and/or modify
Packit Service 37dbff
 * it under the terms of the GNU General Public License as published
Packit Service 37dbff
 * by the Free Software Foundation; either version 2 of the License, or
Packit Service 37dbff
 * (at your option) any later version.
Packit Service 37dbff
 *
Packit Service 37dbff
 * This program is distributed in the hope that it will be useful, but
Packit Service 37dbff
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 37dbff
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Packit Service 37dbff
 * General Public License for more details.
Packit Service 37dbff
 *
Packit Service 37dbff
 * See the file COPYING included with this distribution for more details.
Packit Service 37dbff
 */
Packit Service 37dbff
Packit Service 37dbff
#include <stdio.h>
Packit Service 37dbff
#include <stdlib.h>
Packit Service 37dbff
#include "libiscsi.h"
Packit Service 37dbff
Packit Service 37dbff
int main(void)
Packit Service 37dbff
{
Packit Service 37dbff
	struct libiscsi_node node;
Packit Service 37dbff
	struct libiscsi_context *context;
Packit Service 37dbff
	int rc = 0;
Packit Service 37dbff
Packit Service 37dbff
	snprintf(node.name, LIBISCSI_VALUE_MAXLEN, "%s",
Packit Service 37dbff
		 "iqn.2009-01.com.example:testdisk");
Packit Service 37dbff
	node.tpgt = 1;
Packit Service 37dbff
	snprintf(node.address, NI_MAXHOST, "%s", "127.0.0.1");
Packit Service 37dbff
	node.port = 3260;
Packit Service 37dbff
	
Packit Service 37dbff
	context = libiscsi_init();
Packit Service 37dbff
	if (!context) {
Packit Service 37dbff
		fprintf(stderr, "Error initializing libiscsi\n");
Packit Service 37dbff
		return 1;
Packit Service 37dbff
	}
Packit Service 37dbff
Packit Service 37dbff
	rc = libiscsi_node_logout(context, &node);
Packit Service 37dbff
	if (rc)
Packit Service 37dbff
		fprintf(stderr, "Error logging out: %s\n",
Packit Service 37dbff
			libiscsi_get_error_string(context));
Packit Service 37dbff
Packit Service 37dbff
	libiscsi_cleanup(context);
Packit Service 37dbff
Packit Service 37dbff
	return rc;
Packit Service 37dbff
}