| 1 |
/* |
| 2 |
* FILE: psearch.c |
| 3 |
* PURPOSE: search files through possible recursive path |
| 4 |
* VERSION: 1.0 (Oct. 1995) |
| 5 |
* AUTHOR: Piet Tutelaers |
| 6 |
*/ |
| 7 |
|
| 8 |
#include <stdio.h> |
| 9 |
#include <string.h> /* strcmp() */ |
| 10 |
#include "basics.h" /* fatal(), msg() */ |
| 11 |
#include "filenames.h" /* */ |
| 12 |
#include "psearch.h" /* search_flipath() */ |
| 13 |
|
| 14 |
char *fontname; int dpi, margin = 0; |
| 15 |
|
| 16 |
int main(int argc, char *argv[]) { |
| 17 |
char *path, *file, *fn; |
| 18 |
int matching(char *, int); |
| 19 |
|
| 20 |
/* get path and file arguments */ |
| 21 |
if (argc != 4) fatal("Usage: psearch path fontname dpi\n"); |
| 22 |
path = argv[1]; fontname = argv[2]; dpi = atoi(argv[3]); |
| 23 |
|
| 24 |
/* find <file> in <path> */ |
| 25 |
fn = search_flipath(path, matching); |
| 26 |
if (fn == NULL) msg("%s at %d dpi not found\n", fontname, dpi); |
| 27 |
else msg("%s: %s at %d dpi found\n", fn, fontname, dpi); |
| 28 |
exit(0); |
| 29 |
} |
| 30 |
|
| 31 |
/* |
| 32 |
* Function used to search for one single font in FLI path |
| 33 |
*/ |
| 34 |
int matching(char *font, int size) { |
| 35 |
|
| 36 |
if ((strcmp(font, fontname) == 0) && (size == dpi || |
| 37 |
(size >= dpi - margin && size <= dpi+margin))) |
| 38 |
return 1; |
| 39 |
else |
| 40 |
return 0; |
| 41 |
} |
| 42 |
|