pdf_util.c

Fri, 21 Feb 2003 08:49:11 +0000

author
eric
date
Fri, 21 Feb 2003 08:49:11 +0000
changeset 63
6eddf63aa517
parent 62
9bd354b83e16
child 67
7add7411c1c2
permissions
-rw-r--r--

GPL.

     1 /*
     2  * t2p: Create a PDF file from the contents of one or more TIFF
     3  *      bilevel image files.  The images in the resulting PDF file
     4  *      will be compressed using ITU-T T.6 (G4) fax encoding.
     5  *
     6  * PDF routines
     7  * $Id: pdf_util.c,v 1.3 2003/02/20 04:44:17 eric Exp $
     8  * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
     9  *
    10  * This program is free software; you can redistribute it and/or modify
    11  * it under the terms of the GNU General Public License version 2 as
    12  * published by the Free Software Foundation.  Note that permission is
    13  * not granted to redistribute this program under the terms of any
    14  * other version of the General Public License.
    15  *
    16  * This program is distributed in the hope that it will be useful,
    17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
    22  * along with this program; if not, write to the Free Software
    23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
    24  */
    27 #include <stdarg.h>
    28 #include <stdbool.h>
    29 #include <stdint.h>
    30 #include <stdio.h>
    31 #include <stdlib.h>
    32 #include <string.h>
    34 #include "bitblt.h"
    35 #include "pdf.h"
    36 #include "pdf_util.h"
    39 void pdf_fatal (char *fmt, ...)
    40 {
    41   va_list ap;
    43   va_start (ap, fmt);
    44   vfprintf (stderr, fmt, ap);
    45   va_end (ap);
    47   exit (2);
    48 }
    51 void *pdf_calloc (long int size)
    52 {
    53   void *m = calloc (1, size);
    54   if (! m)
    55     pdf_fatal ("failed to allocate memory\n");
    56   return (m);
    57 }
    60 char *pdf_strdup (char *s)
    61 {
    62   unsigned long len = strlen (s);
    63   char *s2 = pdf_calloc (len + 1);
    64   strcpy (s2, s);
    65   return (s2);
    66 }