/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 *  Copyright (C) 2000 Helix Code Inc.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/* mkindex.c: a simple client, part 1 */

#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "ibex.h"

extern int optind;
extern char *optarg;

static void
usage (void)
{
	fprintf (stderr, "Usage: mkindex [-f indexfile] file ...\n");
	exit (1);
}

int
main (int argc, char **argv)
{
	ibex *ib;
	int opt;
	char *file = "INDEX";

	while ((opt = getopt (argc, argv, "f:")) != -1) {
		switch (opt) {
		case 'f':
			file = optarg;
			break;

		default:
			usage ();
			break;
		}
	}
	argc -= optind;
	argv += optind;

	if (argc == 0)
		usage ();

	ib = ibex_open (file, O_CREAT|O_RDWR, 0600);
	if (!ib) {
		fprintf (stderr, "Couldn't open index file %s: %s\n",
			 file, strerror (errno));
		exit (1);
	}

	while (argc--) {
		if (ibex_index_file (ib, argv[argc]) == -1) {
			fprintf (stderr, "Couldn't index %s: %s\n",
				 argv[argc], strerror (errno));
			exit (1);
		}
	}

	if (ibex_close (ib) != 0) {
		fprintf (stderr, "Failed to write index file %s: %s\n",
			 file, strerror (errno));
		exit (1);
	}
	exit (0);
}
d></tr></table>
<table class='tabs'><tr><td>
<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/about/'>about</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/'>summary</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/refs/?id=2d45f65861448ee7c8d2d352cd9780293960fb94'>refs</a><a class='active' href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/log/misc/esniper'>log</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/tree/misc/esniper?id=2d45f65861448ee7c8d2d352cd9780293960fb94'>tree</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/commit/misc/esniper?id=2d45f65861448ee7c8d2d352cd9780293960fb94'>commit</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/diff/misc/esniper?id=2d45f65861448ee7c8d2d352cd9780293960fb94'>diff</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/stats/misc/esniper'>stats</a></td><td class='form'><form class='right' method='get' action='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/log/misc/esniper'>
<input type='hidden' name='id' value='2d45f65861448ee7c8d2d352cd9780293960fb94'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/log/?id=2d45f65861448ee7c8d2d352cd9780293960fb94'>root</a>/<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/log/misc?id=2d45f65861448ee7c8d2d352cd9780293960fb94'>misc</a>/<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/log/misc/esniper?id=2d45f65861448ee7c8d2d352cd9780293960fb94'>esniper</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th></th><th class='left'>Commit message (<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/log/misc/esniper?id=2d45f65861448ee7c8d2d352cd9780293960fb94&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Age</th><th class='left'>Files</th><th class='left'>Lines</th></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/commit/misc/esniper?id=de4cf73f5446a2a8a2c782e21edd36968046a9e7'>Update the ftp/curl port to 7.16.0.</a></td><td>roam</td><td><span title='2006-12-13 20:41:35 +0800'>2006-12-13</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+2</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/commit/misc/esniper?id=0adb9a3ec78e6e40e0d16ef194129118e0e8a1ce'>- Update to 2-15-0</a></td><td>miwi</td><td><span title='2006-11-09 05:06:02 +0800'>2006-11-09</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/commit/misc/esniper?id=6716ac831109769b08e100b10ad2a14c2c9cdf31'>SHA256ify</a></td><td>edwin</td><td><span title='2006-01-22 20:59:47 +0800'>2006-01-22</span></td><td>1</td><td><span class='deletions'>-0</span>/<span class='insertions'>+1</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-graphics/commit/misc/esniper?id=8e1936dbea4ab3d4a274dda61faa83268ecca23c'>Update to 2.14.0</a></td><td>ehaupt</td><td><span title='2005-10-27 01:48:12 +0800'>2005-10-27</span></td><td>2</td><td><span class='deletions'>-3</span>/<span class='insertions'>+3</span></td></tr>