view lib-src/test-distrib.c @ 26114:c19849fe02b5

Doc fix, duplex and setpagedevice configuration. (ps-print-version): New version number (4.2). (ps-spool-config, ps-spool-tumble): New vars. (ps-print-prologue-1): Changed to defconst, adjust PostScript programming, new PostScript procedure to handle errors. (ps-print-prologue-2): Changed to defconst. (ps-print-duplex-feature): New const: duplex and tumble setting. (ps-setup, ps-begin-file): Fix funs. (ps-boolean-capitalized): New fun. Doc fix, n-up printing. (ps-print-version): New version number (5.0). (ps-page-dimensions-database): Added document media. (ps-n-up-printing, ps-n-up-margin, ps-n-up-border-p, ps-n-up-filling) (ps-page-order, ps-printing-region-p): New vars. (ps-n-up-printing, ps-n-up-filling, ps-header-sheet, ps-end-job): New funs. (ps-page-dimensions-get-media, ps-n-up-landscape, ps-n-up-lines) (ps-n-up-columns, ps-n-up-missing, ps-n-up-xcolumn, ps-n-up-ycolumn) (ps-n-up-xline, ps-n-up-yline, ps-n-up-repeat, ps-n-up-end) (ps-n-up-xstart, ps-n-up-ystart): New macros. (ps-print-begin-sheet-hook): New hook. (ps-boundingbox-re, ps-n-up-database, ps-n-up-filling-database): New const. (ps-setup, ps-begin-file, ps-get-buffer-name, ps-begin-job) (ps-end-file, ps-dummy-page, ps-generate): Fix funs. (ps-print-prologue-1): Adjust PostScript programming for n-up printing. (ps-count-lines): Changed to defun. (ps-header-page): Changed to defsubst, fix fun. (ps-printing-region): Doc fix, adjust programming code. (ps-output-boolean, ps-background-pages, ps-background-text) (ps-background-image, ps-background, ps-get-boundingbox): Adjust programming code. Doc fix, better customization. (ps-print-region-function, ps-number-of-columns, ps-spool-tumble) (ps-print-color-p, ps-printing-region-p, ps-n-up-database) (ps-end-file): Doc fix. (ps-setup, ps-begin-file): Fun fix. (postscript): New group. (ps-zebra-gray, ps-banner-page-when-duplexing): New vars. (ps-print-prologue-1): Adjust PostScript programming. (ps-print): Adjust group hierarchy. (ps-print-n-up, ps-print-zebra, ps-print-background, ps-print-printer) (ps-print-page): New subgroups. (ps-print-prologue-header, ps-printer-name, ps-lpr-command) (ps-lpr-switches, ps-page-dimensions-database, ps-paper-type) (ps-landscape-mode, ps-print-control-characters, ps-n-up-printing) (ps-n-up-margin, ps-n-up-border-p, ps-n-up-filling, ps-zebra-stripes) (ps-zebra-stripe-height, ps-print-background-image) (ps-print-background-text, ps-spool-config): Adjust customization. (dos-ps-printer): Definition eliminated.
author Kenichi Handa <handa@m17n.org>
date Wed, 20 Oct 1999 01:06:27 +0000
parents 134b57acef68
children c8fb06423da0
line wrap: on
line source

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#ifndef O_RDONLY
#define O_RDONLY 0
#endif

/* Break string in two parts to avoid buggy C compilers that ignore characters
   after nulls in strings.  */

char string1[] = "Testing distribution of nonprinting chars:\n\
Should be 0177: \177 Should be 0377: \377 Should be 0212: \212.\n\
Should be 0000: ";

char string2[] = ".\n\
This file is read by the `test-distribution' program.\n\
If you change it, you will make that program fail.\n";

char buf[300];
  
/* Like `read' but keeps trying until it gets SIZE bytes or reaches eof.  */
int
cool_read (fd, buf, size)
     int fd;
     char *buf;
     int size;
{
  int num, sofar = 0;

  while (1)
    {
      if ((num = read (fd, buf + sofar, size - sofar)) == 0)
	return sofar;
      else if (num < 0)
	return num;
      sofar += num;
    }
}

int
main (argc, argv)
     int argc;
     char **argv;
{
  int fd;

  if (argc != 2)
    {
      fprintf (stderr, "Usage: %s testfile\n", argv[0]);
      exit (2);
    }
  fd = open (argv[1], O_RDONLY);
  if (fd < 0)
    {
      perror (argv[1]);
      exit (2);
    }
  if (cool_read (fd, buf, sizeof string1) != sizeof string1 ||
      strcmp (buf, string1) ||
      cool_read (fd, buf, sizeof string2) != sizeof string2 - 1 ||
      strncmp (buf, string2, sizeof string2 - 1))
    {
      fprintf (stderr, "Data in file `%s' has been damaged.\n\
Most likely this means that many nonprinting characters\n\
have been corrupted in the files of Emacs, and it will not work.\n",
	       argv[1]);
      exit (2);
    }
  close (fd);
#ifdef VMS
  exit (1);			/* On VMS, success is 1.  */
#endif
  return (0);
}