static string
try_format P4C(const_string, font_name,  unsigned, dpi,
               const_string, path,  const_string, extension)
{
  string name, ret;
  
  /* Set the suffix on the name we'll be searching for.  */
  xputenv ("KPATHSEA_FORMAT", extension);

  name = bitmap_name (font_name, dpi, extension);
  ret = kpse_path_search (path, name, true);
  
  if (name != ret)
    free (name);
    
  return ret;
}
示例#2
0
void
test_path_search (const_string path, const_string file)
{
  string answer;
  string *answer_list;
  
  printf ("\nSearch %s for %s:\t", path, file);
  answer = kpse_path_search (path, file);
  puts (answer ? answer : "(nil)");

  printf ("Search %s for all %s:\t", path, file);
  answer_list = kpse_all_path_search (path, file);
  putchar ('\n');
  while (*answer_list)
    {
      putchar ('\t');
      puts (*answer_list);
      answer_list++;
    }
}
示例#3
0
static string
try_format P3C(const_string, fontname,  unsigned, dpi,
               kpse_file_format_type,  format)
{
  static const_string bitmap_specs[]
    = { UNIX_BITMAP_SPEC, DPI_BITMAP_SPEC, NULL };
  const_string *spec;
  boolean must_exist;
  string ret = NULL;
  const_string path = kpse_format_info[format].path;
  const_string *sfx;
  if (!path)
    path = kpse_init_format (format);
  
  /* Set the suffix on the name we'll be searching for.  */
  sfx = kpse_format_info[format].suffix;
  if (sfx && *sfx) 
    xputenv ("KPATHSEA_FORMAT", *sfx);

  /* OK, the limits on this for loop are a little hokey, but it saves
     having to repeat the body.  We want to do it once with `must_exist'
     false to avoid looking on the disk for cmr10.600pk if
     dpi600/cmr10.pk is in ls-R.  (The time spent in the extra variable
     expansions and db searches is negligible.)  */
  for (must_exist = false; !ret && must_exist <= true; must_exist++)
    {
      for (spec = bitmap_specs; !ret && *spec; spec++)
        {
          string name = kpse_var_expand (*spec);
          ret = kpse_path_search (path, name, must_exist);
          if (name != ret)
            free (name);
        }
    }
    
  return ret;
}
示例#4
0
static void
map_file_parse P1C(const_string, map_filename)
{
  char *orig_l;
  unsigned map_lineno = 0;
  FILE *f = xfopen (map_filename, FOPEN_R_MODE);
  
  while ((orig_l = read_line (f)) != NULL) {
    string filename;
    string l = orig_l;
    string comment_loc = strrchr (l, '%');
    if (!comment_loc) {
      comment_loc = strstr (l, "@c");
    }
    
    /* Ignore anything after a % or @c.  */
    if (comment_loc)
      *comment_loc = 0;

    map_lineno++;

    /* Skip leading whitespace so we can use strlen below.  Can't use
       strtok since this routine is recursive.  */
    while (*l && ISSPACE (*l))
      l++;
      
    /* If we don't have any filename, that's ok, the line is blank.  */
    filename = token (l);
    if (filename) {
      string alias = token (l + strlen (filename));

      if (STREQ (filename, "include")) {
        if (alias == NULL) {
          WARNING2 ("%s:%u: Filename argument for include directive missing",
                    map_filename, map_lineno);
        } else {
          string include_fname = kpse_path_search (map_path, alias, false);
          if (include_fname) {
            map_file_parse (include_fname);
            if (include_fname != alias)
              free (include_fname);
          } else {
            WARNING3 ("%s:%u: Can't find fontname include file `%s'",
                      map_filename, map_lineno, alias);
          }
          free (alias);
          free (filename);
        }

      /* But if we have a filename and no alias, something's wrong.  */
      } else if (alias == NULL) {
        WARNING3 ("%s:%u: Fontname alias missing for filename `%s'",
                  map_filename, map_lineno, filename);
        free (filename);

      } else {
        /* We've got everything.  Insert the new entry.  They were
           already dynamically allocated, so don't bother with xstrdup.  */
        hash_insert_normalized (&map, alias, filename);
      }
    }

    free (l);
  }
  
  xfclose (f, map_filename);
}