ftp.nice.ch/pub/next/text/tex/apps/TeXview-kp0.25.s.tar.gz#/TeXview-grey/search.c

This is search.c in view mode; [Download] [Up]

/*
 *   The search routine takes a directory list, separated by PATHSEP, and
 *   tries to open a file.  Null directory components indicate current
 *   directory.  In an environment variable, null directory components
 *   indicate substitution of the default path list at that point.
 */
#include "structures.h" /* The copyright notice in that file is included too! */
#include <kpathsea/tex-file.h>
#include <kpathsea/tex-glyph.h>
#define MAXPATHLEN (256)
char name[MAXPATHLEN];
#define FATAL_PERROR(s) do { perror (s); exit (EXIT_FAILURE); } while (0)
#define EXIT_FAILURE 1
/*
 *   We hope MAXPATHLEN is enough -- only rudimentary checking is done!
 */

#ifdef SECURE
extern Boolean secure;
#endif
#ifdef DEBUG
extern integer debug_flag;
#endif  /* DEBUG */
extern char *mfmode ;
extern int actualdpi ;
#define mode "r"
string Krealnameoffile ;

FILE *
search(format, file)
    kpse_file_format_type format;
    char *file ;
{
  FILE *ret;
  string found_name;

#ifdef SECURE
  /* This change suggested by maj@cl.cam.ac.uk to disallow reading of
     arbitrary files.  */
  if (secure && kpse_absolute_p (file)) return NULL;
#endif

  /* Most file looked for through here must exist -- the exception is
     VF's. Bitmap fonts go through pksearch. */
  found_name = kpse_find_file (file, format, format != vfpath);

  if (found_name)
    {
      strcpy (name, found_name);
      ret = fopen (name, mode);
      if (!ret)
        FATAL_PERROR (name);
      Krealnameoffile = name;
    }
  else
    ret = NULL;

  return ret;
}               /* end search */

FILE *
pksearch(path, file, name_ret, dpi, dpi_ret)
        char *path, *file ;
	char **name_ret ;
	halfword dpi;
	int *dpi_ret ;
{
  FILE *ret;
  kpse_glyph_file_type font_file;
  string found_name = kpse_find_pk (file, dpi, &font_file);
  
  if (found_name)
    {
      strcpy (name, found_name);
      
      ret = fopen (name, mode);
      if (!ret)
        FATAL_PERROR (name);
      Krealnameoffile = name;
      *name_ret = font_file.name;
      *dpi_ret = font_file.dpi;
    }
  else
    ret = NULL;

  return ret;
}               /* end search */

/* do we report file openings? */

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.