Blame libiscsi/tests/test_logout.c

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