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