1c7b4381aSmrg/* lsfontdir [<font path entry> ...] 2c7b4381aSmrg * 3c7b4381aSmrg * Lists entries from fonts.dir file in given directory paths. 4c7b4381aSmrg * Defaults to "catalogue:/etc/X11/fontpath.d" & "built-ins" if no paths given. 5c7b4381aSmrg */ 6c7b4381aSmrg 7c7b4381aSmrg/* 86a46240fSmrg * Copyright (c) 2015, 2019, Oracle and/or its affiliates. 9c7b4381aSmrg * 10c7b4381aSmrg * Permission is hereby granted, free of charge, to any person obtaining a 11c7b4381aSmrg * copy of this software and associated documentation files (the "Software"), 12c7b4381aSmrg * to deal in the Software without restriction, including without limitation 13c7b4381aSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14c7b4381aSmrg * and/or sell copies of the Software, and to permit persons to whom the 15c7b4381aSmrg * Software is furnished to do so, subject to the following conditions: 16c7b4381aSmrg * 17c7b4381aSmrg * The above copyright notice and this permission notice (including the next 18c7b4381aSmrg * paragraph) shall be included in all copies or substantial portions of the 19c7b4381aSmrg * Software. 20c7b4381aSmrg * 21c7b4381aSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22c7b4381aSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23c7b4381aSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24c7b4381aSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25c7b4381aSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26c7b4381aSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27c7b4381aSmrg * DEALINGS IN THE SOFTWARE. 28c7b4381aSmrg */ 29c7b4381aSmrg 30c7b4381aSmrg#include "font-test-utils.h" 31c7b4381aSmrg#include <stdio.h> 32c7b4381aSmrg#include <assert.h> 3360da515cSmrg#ifdef HAVE_ERR_H 34c7b4381aSmrg#include <err.h> 3560da515cSmrg#endif 3660da515cSmrg#include "src/util/replace.h" 37c7b4381aSmrg 38c7b4381aSmrgint 39c7b4381aSmrgmain(int argc, char **argv) 40c7b4381aSmrg{ 41c7b4381aSmrg FontPathElementPtr *fpe_list; 42c7b4381aSmrg xfont2_fpe_funcs_rec const **fpe_functions; 43c7b4381aSmrg int fpe_function_count, fpe_list_count; 44c7b4381aSmrg int i, n; 45c7b4381aSmrg 46c7b4381aSmrg fpe_functions = init_font_handlers(&fpe_function_count); 47c7b4381aSmrg 48c7b4381aSmrg fpe_list_count = argc - 1; 49c7b4381aSmrg fpe_list = init_font_paths((const char **) argv + 1, &fpe_list_count); 50c7b4381aSmrg 51c7b4381aSmrg for (i = 0; i < fpe_list_count; i++) { 52c7b4381aSmrg FontPathElementPtr fpe = fpe_list[i]; 53c7b4381aSmrg FontNamesPtr names; 54c7b4381aSmrg const int max_names_count = 8192; 55c7b4381aSmrg const char *pattern = "*"; 56c7b4381aSmrg int result; 57c7b4381aSmrg 58c7b4381aSmrg /* Don't allocate max size up front to allow testing expansion code */ 59c7b4381aSmrg names = xfont2_make_font_names_record(max_names_count / 16); 60c7b4381aSmrg assert(names != NULL); 61c7b4381aSmrg 62c7b4381aSmrg result = (*fpe_functions[fpe->type]->list_fonts) 63c7b4381aSmrg (NULL, fpe, pattern, strlen(pattern), max_names_count, names); 64c7b4381aSmrg if (result != Successful) 65c7b4381aSmrg err(result, "list_font failed for font path %s: error %d", 66c7b4381aSmrg fpe->name, result); 67c7b4381aSmrg 68c7b4381aSmrg printf("--- %s:\n", fpe->name); 69c7b4381aSmrg for (n = 0 ; n < names->nnames; n++) { 70c7b4381aSmrg printf("%s\n", names->names[n]); 71c7b4381aSmrg } 72c7b4381aSmrg 73c7b4381aSmrg xfont2_free_font_names(names); 74c7b4381aSmrg } 75c7b4381aSmrg 76c7b4381aSmrg return 0; 77c7b4381aSmrg} 78