Back to index

tetex-bin  3.0
flisearch.c
Go to the documentation of this file.
00001 /*
00002  * FILE:    psearch.c
00003  * PURPOSE: search files through possible recursive path
00004  * VERSION: 1.0 (Oct. 1995)
00005  * AUTHOR:  Piet Tutelaers
00006  */
00007 
00008 #include <stdio.h>
00009 #include <string.h>         /* strcmp() */
00010 #include "basics.h"         /* fatal(), msg() */
00011 #include "filenames.h"             /* */
00012 #include "psearch.h"        /* search_flipath() */
00013 
00014 char *fontname; int dpi, margin = 0;
00015 
00016 int main(int argc, char *argv[]) {
00017    char *path, *file, *fn;
00018    int matching(char *, int);
00019 
00020    /* get path and file arguments */
00021    if (argc != 4) fatal("Usage: psearch path fontname dpi\n");
00022    path = argv[1]; fontname = argv[2]; dpi = atoi(argv[3]);
00023 
00024    /* find <file> in <path> */
00025    fn = search_flipath(path, matching);
00026    if (fn == NULL) msg("%s at %d dpi not found\n", fontname, dpi);
00027    else msg("%s: %s at %d dpi found\n", fn, fontname, dpi);
00028    exit(0);
00029 }
00030 
00031 /*
00032  * Function used to search for one single font in FLI path
00033  */
00034 int matching(char *font, int size) {
00035 
00036    if ((strcmp(font, fontname) == 0) && (size == dpi ||
00037       (size >= dpi - margin && size <= dpi+margin))) 
00038       return 1;
00039    else
00040       return 0;
00041 }
00042