Back to index

tetex-bin  3.0
Defines | Functions | Variables
texmfmp.c File Reference
#include "TEX-OR-MF-OR-MPd.h"
#include <kpathsea/c-ctype.h>
#include <kpathsea/line.h>
#include <kpathsea/readable.h>
#include <kpathsea/variable.h>
#include <kpathsea/absolute.h>
#include <time.h>
#include <signal.h>
#include <texmfmp-help.h>

Go to the source code of this file.

Defines

#define EXTERN   /* Instantiate data from {tex,mf,mp}d.h here. */
#define ARGUMENT_IS(a)   STREQ (long_options[option_index].name, a)
#define SWAP(x, y)   temp = (x); (x) = (y); (y) = temp
#define ELGORDO   0x7fffffff
#define TWEXP31   2147483648.0
#define TWEXP28   268435456.0
#define TWEXP16   65536.0
#define TWEXP_16   (1.0/65536.0)
#define TWEXP_28   (1.0/268435456.0)

Functions

static void
parse_src_specials_option 
P1H (const_string)
TEXDLL void mainbody P1H (void)
static void parse_options P2H (int, string *)
void TEXDLL maininit P2C (int, ac, string *, av)
string normalize_quotes P2C (const_string, name, const_string, mesg)
static void parse_options P2C (int, argc, string *, argv)
static void parse_first_line P1C (const_string, filename)
static boolean opennameok P3C (const_string, fname, const_string, check_var, const_string, default_choice)
boolean openinnameok P1C (const_string, fname)
static RETSIGTYPE catch_interrupt P1C (int, arg)
void get_date_and_time P4C (integer *, minutes, integer *, day, integer *, month, integer *, year)
integer getrandomseed ()
boolean input_line P1C (FILE *, f)
void calledit P4C (packedASCIIcode *, filename, poolpointer, fnstart, integer, fnlength, integer, linenumber)
static void swap_items P3C (char *, p, int, nitems, int, size)
void do_dump P4C (char *, p, int, item_size, int, nitems, FILE *, out_file)
void do_undump P4C (char *, p, int, item_size, int, nitems, FILE *, in_file)
void setupboundvariable P3C (integer *, var, const_string, var_name, integer, dflt)
integer ztakefraction P2C (integer, p, integer, q)

Variables

char ** argv
int argc
static string user_progname
static const_string dump_name
static const_string job_name
string fullnameoffile
string translate_filename
string default_translate_filename
static char * last_source_name
static int last_lineno
static boolean srcspecialsoption = false
static struct option []
static char * edit_value = EDITOR

Define Documentation

#define ARGUMENT_IS (   a)    STREQ (long_options[option_index].name, a)

Definition at line 752 of file texmfmp.c.

#define ELGORDO   0x7fffffff

Definition at line 1809 of file texmfmp.c.

#define EXTERN   /* Instantiate data from {tex,mf,mp}d.h here. */

Definition at line 8 of file texmfmp.c.

#define SWAP (   x,
  y 
)    temp = (x); (x) = (y); (y) = temp

Definition at line 1431 of file texmfmp.c.

#define TWEXP16   65536.0

Definition at line 1812 of file texmfmp.c.

#define TWEXP28   268435456.0

Definition at line 1811 of file texmfmp.c.

#define TWEXP31   2147483648.0

Definition at line 1810 of file texmfmp.c.

#define TWEXP_16   (1.0/65536.0)

Definition at line 1813 of file texmfmp.c.

#define TWEXP_28   (1.0/268435456.0)

Definition at line 1814 of file texmfmp.c.


Function Documentation

Definition at line 1256 of file texmfmp.c.

{
#if defined (HAVE_GETTIMEOFDAY)
  struct timeval tv;
  gettimeofday(&tv, NULL);
  return (tv.tv_usec + 1000000 * tv.tv_usec);
#elif defined (HAVE_FTIME)
  struct timeb tb;
  ftime(&tb);
  return (tb.millitm + 1000 * tb.time);
#else
  time_t clock = time ((time_t*)NULL);
  struct tm *tmptr = localtime(&clock);
  return (tmptr->tm_sec + 60*(tmptr->tm_min + 60*tmptr->tm_hour));
#endif
}
static void parse_first_line P1C ( const_string  ,
filename   
) [static]

Definition at line 1013 of file texmfmp.c.

{
  FILE *f = filename ? fopen (filename, FOPEN_R_MODE) : NULL;
  if (f) {
    string first_line = read_line (f);
    xfclose (f, filename);

    /* We deal with the general format "%&fmt --translate-file=tcx" */
    /* The idea of using this format came from Wlodzimierz Bzyl
       <matwb@monika.univ.gda.pl> */
    if (first_line && first_line[0] == '%' && first_line[1] == '&') {
      /* Parse the first line into at most three space-separated parts. */
      char *s;
      char *part[4];
      int npart;
      char **parse;

      for (s = first_line+2; ISBLANK(*s); ++s)
        ;
      npart = 0;
      while (*s && npart != 3) {
        part[npart++] = s;
        while (*s && *s != ' ') s++;
        while (*s == ' ') *s++ = '\0';
      }
      part[npart] = NULL;
      parse = part;
      /* Look at what we've got.  Very crude! */
      if (*parse && **parse != '-') {
        /* A format name */
        if (dump_name) {
          /* format already determined, do nothing. */
        } else {
          string f_name = concat (part[0], DUMP_EXT);
          string d_name = kpse_find_file (f_name, DUMP_FORMAT, false);
          if (d_name && kpse_readable_file (d_name)) {
            dump_name = xstrdup (part[0]);
            kpse_reset_program_name (dump_name);
            /* Tell TeX/MF/MP we have a %&name line... */
            dumpline = true;
          }
          free (f_name);
        }
        parse++;
      }
      /* The tcx stuff, if any.  Should we support the -translate-file
         form as well as --translate-file?  */
      if (*parse) {
        if (translate_filename) {
          /* TCX file already set, do nothing. */
        } else if (STREQ (*parse, "--translate-file")) {
          s = *(parse+1);
        } else if (STREQ (*parse, "-translate-file")) {
          s = *(parse+1);
        } else if (STRNEQ (*parse, "--translate-file=", 17)) {
          s = *parse+17;
        } else if (STRNEQ (*parse, "-translate-file=", 16)) {
          s = *parse+16;
        }
        /* Just set the name, no sanity checks here. */
        /* FIXME: remove trailing spaces. */
        if (s && *s) {
          translate_filename = xstrdup(s);
        }
      }
    }
    if (first_line)
      free (first_line);
  }
}

Here is the call graph for this function:

boolean openoutnameok P1C ( const_string  ,
fname   
)

Definition at line 1161 of file texmfmp.c.

{
    /* For input default to all. */
    return opennameok (fname, "openin_any", "a");
}
static RETSIGTYPE catch_interrupt P1C ( int  ,
arg   
) [static]

Definition at line 1192 of file texmfmp.c.

{
  interrupt = 1;
#ifdef OS2
  (void) signal (SIGINT, SIG_ACK);
#else
  (void) signal (SIGINT, catch_interrupt);
#endif /* not OS2 */
}

Here is the call graph for this function:

boolean input_line P1C ( FILE ,
f   
)

Definition at line 1279 of file texmfmp.c.

{
  int i;

  /* Recognize either LF or CR as a line terminator.  */
  last = first;
  while (last < bufsize && (i = getc (f)) != EOF && i != '\n' && i != '\r')
    buffer[last++] = i;

  if (i == EOF && errno != EINTR && last == first)
    return false;

  /* We didn't get the whole line because our buffer was too small.  */
  if (i != EOF && i != '\n' && i != '\r') {
    fprintf (stderr, "! Unable to read an entire line---bufsize=%u.\n",
                     (unsigned) bufsize);
    fputs ("Please increase buf_size in texmf.cnf.\n", stderr);
    uexit (1);
  }

  buffer[last] = ' ';
  if (last >= maxbufstack)
    maxbufstack = last;

  /* If next char is LF of a CRLF, read it.  */
  if (i == '\r') {
    while ((i = getc (f)) == EOF && errno == EINTR)
      ;
    if (i != '\n')
      ungetc (i, f);
  }
  
  /* Trim trailing whitespace.  */
  while (last > first && ISBLANK (buffer[last - 1]))
    --last;

  /* Don't bother using xord if we don't need to.  */
#if !defined(Omega) && !defined(eOmega) && !defined(Aleph)
  for (i = first; i <= last; i++)
     buffer[i] = xord[buffer[i]];
#endif

    return true;
}

Here is the call graph for this function:

static void parse_src_specials_option P1H ( const_string  ) [static]
TEXDLL void mainbody P1H ( void  ) [read]

Definition at line 260 of file afm2tfm.c.

                  {
   register char *p ;
   register int c ;

   param = buffer ;
   for (p=buffer; (c=getc(afmin)) != EOF;) {
      if (p - buffer >= INBUFSIZE)
         error("! input line too long; perhaps input file is malformed?") ;
      *p++ = c ;
      if (c == '\r') {
         c = getc(afmin) ;
         if (c != EOF) {
            if (c == '\n') {
               *p++ = c ;
            } else {
               ungetc(c, afmin) ;
            }
         }
         break ;
      } else if (c == '\n') {
         break ;
      }
   }
   *p = 0 ;
   (void)strcpy(obuffer, buffer) ;
   if (p == buffer && c == EOF)
      return(0) ;
   else
      return(1) ;
}
void TEXDLL maininit P2C ( int  ,
ac  ,
string ,
av   
)

Definition at line 166 of file texmfmp.c.

{
  string main_input_file;

  /* Save to pass along to topenin.  */
  argc = ac;
  argv = av;

  /* Must be initialized before options are parsed.  */
  interactionoption = 4;

#if defined(pdfTeX) || defined(pdfeTeX) || defined(pdfxTeX)
  ptexbanner = BANNER;
#endif

  /* If the user says --help or --version, we need to notice early.  And
     since we want the --ini option, have to do it before getting into
     the web (which would read the base file, etc.).  */
  parse_options (ac, av);
  
  /* Do this early so we can inspect program_invocation_name and
     kpse_program_name below, and because we have to do this before
     any path searching.  */
  kpse_set_program_name (argv[0], user_progname);

  /* FIXME: gather engine names in a single spot. */
  xputenv("engine", TEXMFENGINENAME);
  
  /* Were we given a simple filename? */
  main_input_file = get_input_file_name();

  /* Second chance to activate file:line:error style messages, this
     time from texmf.cnf. */
  if (filelineerrorstylep < 0) {
    filelineerrorstylep = 0;
  } else if (!filelineerrorstylep) {
    string file_line_error_style = kpse_var_value ("file_line_error_style");
    filelineerrorstylep = (file_line_error_style
                           && (*file_line_error_style == 't'
                               || *file_line_error_style == 'y'
                               || *file_line_error_style == '1'));
  }

  /* If no dump default yet, and we're not doing anything special on
     this run, we may want to look at the first line of the main input
     file for a %&<dumpname> specifier.  */
  if (parsefirstlinep < 0) {
    parsefirstlinep = 0;
  } else if (!parsefirstlinep) {
    string parse_first_line = kpse_var_value ("parse_first_line");
    parsefirstlinep = (parse_first_line
                       && (*parse_first_line == 't'
                           || *parse_first_line == 'y'
                           || *parse_first_line == '1'));
  }
  if (parsefirstlinep && (!dump_name || !translate_filename)) {
    parse_first_line (main_input_file);
  }
  /* Check whether there still is no translate_filename known.  If so,
     use the default_translate_filename. */
  /* FIXME: deprecated. */
  if (!translate_filename) {
    translate_filename = default_translate_filename;
  }
  /* If we're preloaded, I guess everything is set up.  I don't really
     know any more, it's been so long since anyone preloaded.  */
  if (readyalready != 314159) {
    /* The `ini_version' variable is declared/used in the change files.  */
    boolean virversion = false;
    if (FILESTRCASEEQ (kpse_program_name, INI_PROGRAM)) {
      iniversion = true;
    } else if (FILESTRCASEEQ (kpse_program_name, VIR_PROGRAM)) {
      virversion = true;
#ifdef TeX
    } else if (FILESTRCASEEQ (kpse_program_name, "initex")) {
      iniversion = true;
    } else if (FILESTRCASEEQ (kpse_program_name, "virtex")) {
      virversion = true;
#if !defined(Omega) && !defined(eOmega) && !defined(Aleph)
    } else if (FILESTRCASEEQ (kpse_program_name, "mltex")) {
      mltexp = true;
#endif /* !Omega && !eOmega && !Aleph */
#endif /* TeX */
    }

    if (!dump_name) {
      /* If called as *vir{mf,tex,mpost} use `plain'.  Otherwise, use the
         name we were invoked under.  */
      dump_name = (virversion ? "plain" : kpse_program_name);
    }
  }
  
#ifdef TeX
#if !defined(Omega) && !defined(eOmega) && !defined(Aleph)
  /* Sanity check: -mltex and -enc only work in combination with -ini. */
  if (!iniversion) {
    if (mltexp) {
      fprintf(stderr, "-mltex only works with -ini\n");
    }
    if (enctexp) {
      fprintf(stderr, "-enc only works with -ini\n");
    }
  }
#endif
#endif
  
  /* If we've set up the fmt/base default in any of the various ways
     above, also set its length.  */
  if (dump_name) {
    /* adjust array for Pascal and provide extension */
    DUMP_VAR = concat3 (" ", dump_name, DUMP_EXT);
    DUMP_LENGTH_VAR = strlen (DUMP_VAR + 1);
  } else {
    /* For dump_name to be NULL is a bug.  */
    abort();
  }

  /* Additional initializations.  No particular reason for doing them
     here instead of first thing in the change file; less symbols to
     propagate through Webc, that's all.  */
#ifdef MF
  kpse_set_program_enabled (kpse_mf_format, MAKE_TEX_MF_BY_DEFAULT,
                            kpse_src_compile);
  kpse_set_program_enabled (kpse_base_format, MAKE_TEX_FMT_BY_DEFAULT,
                            kpse_src_compile);
#endif /* MF */
#ifdef MP
  kpse_set_program_enabled (kpse_mem_format, MAKE_TEX_FMT_BY_DEFAULT,
                            kpse_src_compile);
#endif /* MP */
#ifdef TeX
#if defined(Omega) || defined (eOmega) || defined (Aleph)
  kpse_set_program_enabled (kpse_ocp_format, MAKE_OMEGA_OCP_BY_DEFAULT,
                            kpse_src_compile);
  kpse_set_program_enabled (kpse_ofm_format, MAKE_OMEGA_OFM_BY_DEFAULT,
                            kpse_src_compile);
  kpse_set_program_enabled (kpse_tfm_format, false, kpse_src_compile);
#else /* !Omega && !eOmega && !Aleph */
  kpse_set_program_enabled (kpse_tfm_format, MAKE_TEX_TFM_BY_DEFAULT,
                            kpse_src_compile);
#endif /* !Omega && !eOmega  && !Aleph */
  kpse_set_program_enabled (kpse_tex_format, MAKE_TEX_TEX_BY_DEFAULT,
                            kpse_src_compile);
  kpse_set_program_enabled (kpse_fmt_format, MAKE_TEX_FMT_BY_DEFAULT,
                            kpse_src_compile);

  if (shellenabledp < 0) {
    shellenabledp = 0;
  } else if (!shellenabledp) {
    string shell_escape = kpse_var_value ("shell_escape");
    shellenabledp = (shell_escape
                     && (*shell_escape == 't'
                         || *shell_escape == 'y'
                         || *shell_escape == '1'));
  }
  if (!outputcomment) {
    outputcomment = kpse_var_value ("output_comment");
  }
#endif /* TeX */
}

Here is the call graph for this function:

string normalize_quotes P2C ( const_string  ,
name  ,
const_string  ,
mesg   
)

Definition at line 694 of file texmfmp.c.

{
    boolean quoted = false;
    boolean must_quote = (strchr(name, ' ') != NULL);
    /* Leave room for quotes and NUL. */
    string ret = (string)xmalloc(strlen(name)+3);
    string p;
    const_string q;
    p = ret;
    if (must_quote)
        *p++ = '"';
    for (q = name; *q; q++) {
        if (*q == '"')
            quoted = !quoted;
        else
            *p++ = *q;
    }
    if (must_quote)
        *p++ = '"';
    *p = '\0';
    if (quoted) {
        fprintf(stderr, "! Unbalanced quotes in %s %s\n", mesg, name);
        uexit(1);
    }
    return ret;
}

Here is the call graph for this function:

static void parse_options P2C ( int  ,
argc  ,
string ,
argv   
) [static]

Definition at line 814 of file texmfmp.c.

{
  int g;   /* `getopt' return code.  */
  int option_index;

  for (;;) {
    g = getopt_long_only (argc, argv, "+", long_options, &option_index);

    if (g == -1) /* End of arguments, exit the loop.  */
      break;

    if (g == '?') { /* Unknown option.  */
      /* FIXME: usage (argv[0]); replaced by continue. */
      continue;
    }

    assert (g == 0); /* We have no short option names.  */

    if (ARGUMENT_IS ("kpathsea-debug")) {
      kpathsea_debug |= atoi (optarg);

    } else if (ARGUMENT_IS ("progname")) {
      user_progname = optarg;

    } else if (ARGUMENT_IS ("jobname")) {
      job_name = normalize_quotes(optarg, "jobname");
      
    } else if (ARGUMENT_IS (DUMP_OPTION)) {
      dump_name = optarg;
      if (!user_progname) user_progname = optarg;
      dumpoption = true;

#ifdef TeX
    /* FIXME: Obsolete -- for backward compatibility only. */
    } else if (ARGUMENT_IS ("efmt")) {
      dump_name = optarg;
      if (!user_progname) user_progname = optarg;
      dumpoption = true;
#endif

    } else if (ARGUMENT_IS ("output-directory")) {
      output_directory = optarg;
      
#ifdef TeX
    } else if (ARGUMENT_IS ("output-comment")) {
      unsigned len = strlen (optarg);
      if (len < 256) {
        outputcomment = optarg;
      } else {
        WARNING2 ("Comment truncated to 255 characters from %d. (%s)",
                  len, optarg);
        outputcomment = (string)xmalloc (256);
        strncpy (outputcomment, optarg, 255);
        outputcomment[255] = 0;
      }

#ifdef IPC
    } else if (ARGUMENT_IS ("ipc-start")) {
      ipc_open_out ();
      /* Try to start up the other end if it's not already.  */
      if (!ipc_is_open ()) {
        if (system (IPC_SERVER_CMD) == 0) {
          unsigned i;
          for (i = 0; i < 20 && !ipc_is_open (); i++) {
            sleep (2);
            ipc_open_out ();
          }
        }
      }
#endif /* IPC */
    } else if (ARGUMENT_IS ("src-specials")) {
       last_source_name = xstrdup("");
       /* Option `--src" without any value means `auto' mode. */
       if (optarg == NULL) {
         insertsrcspecialeverypar = true;
         insertsrcspecialauto = true;
         srcspecialsoption = true;
         srcspecialsp = true;
       } else {
          parse_src_specials_option(optarg);
       }
#endif /* TeX */
#if defined(pdfTeX) || defined(pdfeTeX) || defined(pdfxTeX)
    } else if (ARGUMENT_IS ("output-format")) {
       pdfoutputoption = 1;
       if (strcmp(optarg, "dvi") == 0) {
         pdfoutputvalue = 0;
       } else if (strcmp(optarg, "pdf") == 0) {
         pdfoutputvalue = 2;
       } else {
         WARNING1 ("Ignoring unknown value `%s' for --output-format", optarg);
         pdfoutputoption = 0;
       }
#endif /* pdfTeX || pdfeTeX || pdfxTeX */
#if defined (TeX) || defined (MF) || defined (MP)
    } else if (ARGUMENT_IS ("translate-file")) {
      translate_filename = optarg;
    } else if (ARGUMENT_IS ("default-translate-file")) {
      default_translate_filename = optarg;
#if defined(Omega) || defined(eOmega) || defined(Aleph)
    } else if (ARGUMENT_IS ("8bit")) {
      /* FIXME: print snippy message? Possibly also for above? */
#endif /* !Omega && !eOmega && !Aleph */
#endif /* TeX || MF || MP */

#if defined (TeX) || defined (MF)
    } else if (ARGUMENT_IS ("mktex")) {
      kpse_maketex_option (optarg, true);

    } else if (ARGUMENT_IS ("no-mktex")) {
      kpse_maketex_option (optarg, false);
#endif /* TeX or MF */
#if defined (MP)
    } else if (ARGUMENT_IS ("tex")) {
      mpost_tex_program = optarg;
#endif /* MP */
    } else if (ARGUMENT_IS ("interaction")) {
        /* These numbers match @d's in *.ch */
      if (STREQ (optarg, "batchmode")) {
        interactionoption = 0;
      } else if (STREQ (optarg, "nonstopmode")) {
        interactionoption = 1;
      } else if (STREQ (optarg, "scrollmode")) {
        interactionoption = 2;
      } else if (STREQ (optarg, "errorstopmode")) {
        interactionoption = 3;
      } else {
        WARNING1 ("Ignoring unknown argument `%s' to --interaction", optarg);
      }
      
    } else if (ARGUMENT_IS ("help")) {
        usagehelp (PROGRAM_HELP, BUG_ADDRESS);

    } else if (ARGUMENT_IS ("version")) {
      printversionandexit (BANNER, COPYRIGHT_HOLDER, AUTHOR);

    } /* Else it was a flag; getopt has already done the assignment.  */
  }
}

Here is the call graph for this function:

integer zmakescaled P2C ( integer  ,
p  ,
integer  ,
 
)

Definition at line 1817 of file texmfmp.c.

{      register double d;
       register integer i;
       d = (double)p * (double)q * TWEXP_28;
       if ((p^q) >= 0) {
              d += 0.5;
              if (d>=TWEXP31) {
                     if (d!=TWEXP31 || (((p&077777)*(q&077777))&040000)==0)
                            aritherror = true;
                     return ELGORDO;
              }
              i = (integer) d;
              if (d==i && (((p&077777)*(q&077777))&040000)!=0) --i;
       } else {
              d -= 0.5;
              if (d<= -TWEXP31) {
                     if (d!= -TWEXP31 || ((-(p&077777)*(q&077777))&040000)==0)
                            aritherror = true;
                     return -ELGORDO;
              }
              i = (integer) d;
              if (d==i && ((-(p&077777)*(q&077777))&040000)!=0) ++i;
       }
       return i;
}
static void parse_options P2H ( int  ,
string  
) [static]
static boolean opennameok P3C ( const_string  ,
fname  ,
const_string  ,
check_var  ,
const_string  ,
default_choice   
) [static]

Definition at line 1088 of file texmfmp.c.

{
  /* We distinguish three cases:
     'a' (any)        allows any file to be opened.
     'r' (restricted) means disallowing special file names.
     'p' (paranoid)   means being really paranoid: disallowing special file
                      names and restricting output files to be in or below
                      the working directory or $TEXMFOUTPUT, while input files
                      must be below the current directory, $TEXMFOUTPUT, or
                      (implicitly) in the system areas.
     We default to "paranoid".  The error messages from TeX will be somewhat
     puzzling...
     This function contains several return statements...  */

  const_string open_choice = kpse_var_value (check_var);

  if (!open_choice) open_choice = default_choice;

  if (*open_choice == 'a' || *open_choice == 'y' || *open_choice == '1')
    return true;

#if defined (unix) && !defined (MSDOS)
  {
    const_string base = xbasename (fname);
    /* Disallow .rhosts, .login, etc.  Allow .tex (for LaTeX).  */
    if (base[0] == 0 ||
        (base[0] == '.' && !IS_DIR_SEP(base[1]) && !STREQ (base, ".tex"))) {
      fprintf(stderr, "%s: Not writing to %s (%s = %s).\n",
              program_invocation_name, fname, check_var, open_choice);
      return false;
    }
  }
#else
  /* Other OSs don't have special names? */
#endif

  if (*open_choice == 'r' || *open_choice == 'n' || *open_choice == '0')
    return true;

  /* Paranoia supplied by Charles Karney...  */
  if (kpse_absolute_p (fname, false)) {
    const_string texmfoutput = kpse_var_value ("TEXMFOUTPUT");
    /* Absolute pathname is only OK if TEXMFOUTPUT is set, it's not empty,
       fname begins the TEXMFOUTPUT, and is followed by / */
    if (!texmfoutput || *texmfoutput == '\0'
        || fname != strstr (fname, texmfoutput)
        || !IS_DIR_SEP(fname[strlen(texmfoutput)])) {
      fprintf(stderr, "%s: Not writing to %s (%s = %s).\n",
              program_invocation_name, fname, check_var, open_choice);
      return false;
    }
  }
  /* For all pathnames, we disallow "../" at the beginning or "/../"
     anywhere.  */
  if (fname[0] == '.' && fname[1] == '.' && IS_DIR_SEP(fname[2])) {
    fprintf(stderr, "%s: Not writing to %s (%s = %s).\n",
            program_invocation_name, fname, check_var, open_choice);
    return false;
  } else {
    const_string dotpair = strstr (fname, "..");
    /* If dotpair[2] == DIR_SEP, then dotpair[-1] is well-defined. */
    if (dotpair && IS_DIR_SEP(dotpair[2]) && IS_DIR_SEP(dotpair[-1])) {
      fprintf(stderr, "%s: Not writing to %s (%s = %s).\n",
              program_invocation_name, fname, check_var, open_choice);
      return false;
    }
  }

  /* We passed all tests.  */
  return true;
}

Here is the call graph for this function:

static void swap_items P3C ( char *  ,
p  ,
int  ,
nitems  ,
int  ,
size   
) [static]

Definition at line 1438 of file texmfmp.c.

{
  char temp;

  /* Since `size' does not change, we can write a while loop for each
     case, and avoid testing `size' for each time.  */
  switch (size)
    {
    /* 16-byte items happen on the DEC Alpha machine when we are not
       doing sharable memory dumps.  */
    case 16:
      while (nitems--)
        {
          SWAP (p[0], p[15]);
          SWAP (p[1], p[14]);
          SWAP (p[2], p[13]);
          SWAP (p[3], p[12]);
          SWAP (p[4], p[11]);
          SWAP (p[5], p[10]);
          SWAP (p[6], p[9]);
          SWAP (p[7], p[8]);
          p += size;
        }
      break;

    case 8:
      while (nitems--)
        {
          SWAP (p[0], p[7]);
          SWAP (p[1], p[6]);
          SWAP (p[2], p[5]);
          SWAP (p[3], p[4]);
          p += size;
        }
      break;

    case 4:
      while (nitems--)
        {
          SWAP (p[0], p[3]);
          SWAP (p[1], p[2]);
          p += size;
        }
      break;

    case 2:
      while (nitems--)
        {
          SWAP (p[0], p[1]);
          p += size;
        }
      break;

    case 1:
      /* Nothing to do.  */
      break;

    default:
      FATAL1 ("Can't swap a %d-byte item for (un)dumping", size);
  }
}
void setupboundvariable P3C ( integer ,
var  ,
const_string  ,
var_name  ,
integer  ,
dflt   
)

Definition at line 1545 of file texmfmp.c.

{
  string expansion = kpse_var_value (var_name);
  *var = dflt;

  if (expansion) {
    integer conf_val = atoi (expansion);
    /* It's ok if the cnf file specifies 0 for extra_mem_{top,bot}, etc.
       But negative numbers are always wrong.  */
    if (conf_val < 0 || (conf_val == 0 && dflt > 0)) {
      fprintf (stderr,
               "%s: Bad value (%ld) in texmf.cnf for %s, keeping %ld.\n",
               program_invocation_name,
               (long) conf_val, var_name + 1, (long) dflt);
    } else {
      *var = conf_val; /* We'll make further checks later.  */
    }
    free (expansion);
  }
}

Here is the call graph for this function:

void get_date_and_time P4C ( integer ,
minutes  ,
integer ,
day  ,
integer ,
month  ,
integer ,
year   
)

Definition at line 1210 of file texmfmp.c.

{
  time_t clock = time ((time_t *) 0);
  struct tm *tmptr = localtime (&clock);

  *minutes = tmptr->tm_hour * 60 + tmptr->tm_min;
  *day = tmptr->tm_mday;
  *month = tmptr->tm_mon + 1;
  *year = tmptr->tm_year + 1900;

  {
#ifdef SA_INTERRUPT
    /* Under SunOS 4.1.x, the default action after return from the
       signal handler is to restart the I/O if nothing has been
       transferred.  The effect on TeX is that interrupts are ignored if
       we are waiting for input.  The following tells the system to
       return EINTR from read() in this case.  From ken@cs.toronto.edu.  */

    struct sigaction a, oa;

    a.sa_handler = catch_interrupt;
    sigemptyset (&a.sa_mask);
    sigaddset (&a.sa_mask, SIGINT);
    a.sa_flags = SA_INTERRUPT;
    sigaction (SIGINT, &a, &oa);
    if (oa.sa_handler != SIG_DFL)
      sigaction (SIGINT, &oa, (struct sigaction *) 0);
#else /* no SA_INTERRUPT */
#ifdef WIN32
    SetConsoleCtrlHandler(catch_interrupt, TRUE);
#else /* not WIN32 */
    RETSIGTYPE (*old_handler) P1H(int);
    
    old_handler = signal (SIGINT, catch_interrupt);
    if (old_handler != SIG_DFL)
      signal (SIGINT, old_handler);
#endif /* not WIN32 */
#endif /* no SA_INTERRUPT */
  }
}
void calledit P4C ( packedASCIIcode *  ,
filename  ,
poolpointer  ,
fnstart  ,
integer  ,
fnlength  ,
integer  ,
linenumber   
)

Definition at line 1334 of file texmfmp.c.

{
  char *temp, *command;
  char c;
  int sdone, ddone, i;

  sdone = ddone = 0;
  filename += fnstart;

  /* Close any open input files, since we're going to kill the job.  */
  for (i = 1; i <= inopen; i++)
    xfclose (inputfile[i], "inputfile");

  /* Replace the default with the value of the appropriate environment
     variable or config file value, if it's set.  */
  temp = kpse_var_value (edit_var);
  if (temp != NULL)
    edit_value = temp;

  /* Construct the command string.  The `11' is the maximum length an
     integer might be.  */
  command = (string) xmalloc (strlen (edit_value) + fnlength + 11);

  /* So we can construct it as we go.  */
  temp = command;

  while ((c = *edit_value++) != 0)
    {
      if (c == '%')
        {
          switch (c = *edit_value++)
            {
           case 'd':
             if (ddone)
                FATAL ("call_edit: `%%d' appears twice in editor command");
              sprintf (temp, "%ld", linenumber);
              while (*temp != '\0')
                temp++;
              ddone = 1;
              break;

           case 's':
              if (sdone)
                FATAL ("call_edit: `%%s' appears twice in editor command");
              for (i =0; i < fnlength; i++)
              *temp++ = Xchr (filename[i]);
              sdone = 1;
              break;

           case '\0':
              *temp++ = '%';
              /* Back up to the null to force termination.  */
             edit_value--;
             break;

           default:
             *temp++ = '%';
             *temp++ = c;
             break;
           }
       }
      else
       *temp++ = c;
    }

  *temp = 0;

  /* Execute the command.  */
#ifdef WIN32
  /* Win32 reimplementation of the system() command
     provides opportunity to call it asynchronously */
  if (win32_system(command, true) != 0 )
#else
  if (system (command) != 0)
#endif
    fprintf (stderr, "! Trouble executing `%s'.\n", command);

  /* Quit, since we found an error.  */
  uexit (1);
}

Here is the call graph for this function:

void do_dump P4C ( char *  ,
p  ,
int  ,
item_size  ,
int  ,
nitems  ,
FILE ,
out_file   
)

Definition at line 1507 of file texmfmp.c.

{
#if !defined (WORDS_BIGENDIAN) && !defined (NO_DUMP_SHARE)
  swap_items (p, nitems, item_size);
#endif

  if (fwrite (p, item_size, nitems, out_file) != nitems)
    {
      fprintf (stderr, "! Could not write %d %d-byte item(s).\n",
               nitems, item_size);
      uexit (1);
    }

  /* Have to restore the old contents of memory, since some of it might
     get used again.  */
#if !defined (WORDS_BIGENDIAN) && !defined (NO_DUMP_SHARE)
  swap_items (p, nitems, item_size);
#endif
}

Here is the call graph for this function:

void do_undump P4C ( char *  ,
p  ,
int  ,
item_size  ,
int  ,
nitems  ,
FILE ,
in_file   
)

Definition at line 1531 of file texmfmp.c.

{
  if (fread (p, item_size, nitems, in_file) != nitems)
    FATAL2 ("Could not undump %d %d-byte item(s)", nitems, item_size);

#if !defined (WORDS_BIGENDIAN) && !defined (NO_DUMP_SHARE)
  swap_items (p, nitems, item_size);
#endif
}

Variable Documentation

Definition at line 110 of file texmfmp.c.

char** argv

Definition at line 109 of file texmfmp.c.

Definition at line 126 of file texmfmp.c.

Definition at line 116 of file texmfmp.c.

char* edit_value = EDITOR [static]

Definition at line 1326 of file texmfmp.c.

Definition at line 119 of file texmfmp.c.

int last_lineno [static]

Definition at line 130 of file texmfmp.c.

char* last_source_name [static]

Definition at line 129 of file texmfmp.c.

struct option[] [static]

Definition at line 756 of file texmfmp.c.

Definition at line 131 of file texmfmp.c.

Definition at line 125 of file texmfmp.c.

Definition at line 113 of file texmfmp.c.