• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

MakefileH A D14-Sep-2006508 135

READMEH A D04-Jan-20083.2 KiB130108

TargetsH A D27-Sep-2018220 75

cmpdir.cH A D28-Nov-20194.4 KiB194145

fetchdir.cH A D28-Nov-20195.5 KiB229176

find.cH A D07-Sep-201966.9 KiB2,9882,450

find_list.cH A D16-Sep-20197.5 KiB314263

find_list.hH A D10-Jul-2009959 3210

find_main.cH A D20-Aug-20216.5 KiB290231

find_misc.cH A D12-Sep-20153.6 KiB171124

find_misc.hH A D14-Sep-20191.6 KiB6535

find_tok.hH A D29-Oct-20188.4 KiB225199

idcache.cH A D20-May-20187.2 KiB334267

libfind-mapversH A D25-Nov-20192.2 KiB9586

libfind.mkH A D12-Sep-2015862 3115

libfind_p.mkH A D12-Sep-2015928 3318

noshlfind.mkH A D01-Jun-2020536 146

ptime.cH A D28-Oct-20186.9 KiB338253

shlfind.mkH A D28-Nov-2019944 3318

version.hH A D23-Jul-2021191 93

walk.cH A D28-Nov-201924.6 KiB1,143893

README

1Libfind allows to be used for adding find(1) like command line features
2to other programs (e.g. star and mkisofs). It also allows to implement
3a find(1) command in 10 lines of code and it allows to be used as shell
4built in function.
5
6Example code for a complete find(1) program:
7/*--------------------------------------------------------------------------*/
8/* %Z%%M%	%I% %E% Copyright 2004-2007 J. Schilling */
9#ifndef lint
10static	char sccsid[] =
11	"%Z%%M%	%I% %E% Copyright 2004-2007 J. Schilling";
12#endif
13/*
14 *	Another find implementation...
15 *
16 *	Copyright (c) 2004-2007 J. Schilling
17 */
18/*
19 * The contents of this file are subject to the terms of the
20 * Common Development and Distribution License, Version 1.0 only
21 * (the "License").  You may not use this file except in compliance
22 * with the License.
23 *
24 * See the file CDDL.Schily.txt in this distribution for details.
25 *
26 * When distributing Covered Code, include this CDDL HEADER in each
27 * file and include the License file CDDL.Schily.txt from this distribution.
28 */
29
30#include <schily/mconfig.h>
31#include <schily/unistd.h>
32#include <schily/standard.h>
33#include <schily/schily.h>
34
35#include "walk.h"
36#include "find.h"
37
38EXPORT	int	main		__PR((int ac, char **av));
39
40EXPORT int
41main(ac, av)
42	int	ac;
43	char	**av;
44{
45	FILE	*std[3];
46
47	std[0] = stdin;
48	std[1] = stdout;
49	std[2] = stderr;
50	return (find_main(ac, av, NULL, std, NULL));
51}
52/*--------------------------------------------------------------------------*/
53
54Example code for redirecting I/O and for catching/handling signals in "bsh":
55/*--------------------------------------------------------------------------*/
56#include "../libfind/walk.h"
57#include "../libfind/find.h"
58
59LOCAL int
60quitfun(void *arg)
61{
62	return (*((int *)arg) != 0);	/* Return TRUE is a signal was catched */
63}
64
65/* ARGSUSED */
66EXPORT void
67bfind(vp, std, flag)
68	vector	*vp;
69	FILE	*std[];
70	int	flag;
71{
72	squit_t	quit;
73
74	quit.quitfun = quitfun;	/* The function to evaluate "ctlc" */
75	quit.qfarg = &ctlc;	/* The ^C catched counter	   */
76
77	ex_status = find_main(vp->v_ac, vp->v_av, evarray, std, &quit);
78}
79/*--------------------------------------------------------------------------*/
80
81Example code for how to redirect I/O in ksh93 and how to catch signals:
82NOTE: as th ksh93 does not use stdio but sfio, you need two wrapper
83functions in order to run a standard program inside ksh93.
84/*--------------------------------------------------------------------------*/
85a.c:    (compiled against sfio)
86
87int
88quitfun(void *dummy)
89{
90	return (cmdquit() != 0);
91}
92
93int
94b_find(int ac, char **av, void* context))
95{
96	int	i, o, e;
97
98	cmdinit(ac, av, context, ERROR_CATALOG, ERROR_NOTIFY);
99
100	i = fileno(stdin);
101	o = fileno(stdout);
102	e = fileno(stderr);
103
104	return xfind(ac, av, dup(i), dup(o), dup(e), quitfun);
105}
106
107------
108b.c: (compiled against stdio)
109
110int
111xfind(int ac, char **av, int i, int o, int e, int (*quitfun)(void *))
112{
113	int	ret;
114	FILE	*std[3];
115	squit_t	quit;
116
117	quit.quitfun = quitfun;	/* The function to evaluate "ctlc" */
118	quit.qfarg = NULL;	/* Dummy			   */
119
120	std[0] = fdopen(i, "r+");
121	std[1] = fdopen(o, "w");
122	std[2] = fdopen(e, "w+");
123	ret = find_main(ac, av, NULL, std, &quit);
124	fclose(std[0]);
125	fclose(std[1]);
126	fclose(std[2]);
127	return (ret);
128}
129/*--------------------------------------------------------------------------*/
130