~ubuntu-branches/ubuntu/precise/t1utils/precise-updates

« back to all changes in this revision

Viewing changes to t1mac.c

  • Committer: Bazaar Package Importer
  • Author(s): C.M. Connelly
  • Date: 2004-03-02 09:25:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040302092534-gi8xtc77vz1gbuue
Tags: 1.32-1
* New upstream release
* Fixes memory corruption bug

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * 1 fonts stored in MacBinary (I or II), AppleSingle, AppleDouble, BinHex, or
5
5
 * raw resource fork format.
6
6
 *
7
 
 * Copyright (c) 2000-2001 by Eddie Kohler, all rights reserved.
 
7
 * Copyright (c) 2000-2003 by Eddie Kohler, all rights reserved.
8
8
 *
9
9
 * Permission is hereby granted to use, modify, and distribute this program
10
10
 * for any purpose provided this copyright notice and the one below remain
27
27
#include <stdarg.h>
28
28
#include <errno.h>
29
29
#include <time.h>
30
 
#include "clp.h"
 
30
#include <lcdf/clp.h>
31
31
#include "t1lib.h"
32
32
 
 
33
#ifdef __cplusplus
 
34
extern "C" {
 
35
#endif
 
36
 
33
37
typedef unsigned char byte;
34
38
 
35
39
void fatal_error(const char *message, ...);
352
356
}
353
357
 
354
358
static void
355
 
t1mac_output_ascii(char *s)
 
359
t1mac_output_ascii(char *s, int len)
356
360
{
357
 
  int l = strlen(s);
358
361
  if (blocktyp == POST_BINARY) {
359
362
    output_current_post();
360
363
    blocktyp = POST_ASCII;
361
364
  }
362
365
  /* Mac line endings */
363
 
  if (l > 0 && s[l-1] == '\n')
364
 
    s[l-1] = '\r';
365
 
  t1mac_output_data((byte *)s, l);
 
366
  if (len > 0 && s[len-1] == '\n')
 
367
    s[len-1] = '\r';
 
368
  t1mac_output_data((byte *)s, len);
366
369
  if (strncmp(s, "/FontName", 9) == 0) {
367
370
    for (s += 9; isspace(*s); s++) ;
368
371
    if (*s == '/') {
753
756
  { "raw", 'r', RAW_OPT, 0, 0 },
754
757
  { "version", 0, VERSION_OPT, 0, 0 },
755
758
};
756
 
static char *program_name;
 
759
static const char *program_name;
757
760
 
758
761
 
759
762
void
810
813
  -h, --help                  Print this message and exit.\n\
811
814
      --version               Print version number and warranty and exit.\n\
812
815
\n\
813
 
Report bugs to <eddietwo@lcs.mit.edu>.\n", program_name);
814
 
}
 
816
Report bugs to <kohler@icir.org>.\n", program_name);
 
817
}
 
818
 
 
819
#ifdef __cplusplus
 
820
}
 
821
#endif
815
822
 
816
823
 
817
824
int
818
 
main(int argc, char **argv)
 
825
main(int argc, char *argv[])
819
826
{
820
827
  int i, c;
821
828
  FILE *ifp = 0, *ofp = 0;
827
834
  int raw = 0, macbinary = 1, applesingle = 0, appledouble = 0, binhex = 0;
828
835
  
829
836
  Clp_Parser *clp =
830
 
    Clp_NewParser(argc, argv, sizeof(options) / sizeof(options[0]), options);
831
 
  program_name = (char *)Clp_ProgramName(clp);
 
837
    Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options);
 
838
  program_name = Clp_ProgramName(clp);
832
839
  
833
840
  /* interpret command line arguments using CLP */
834
841
  while (1) {
886
893
      
887
894
     case VERSION_OPT:
888
895
      printf("t1mac (LCDF t1utils) %s\n", VERSION);
889
 
      printf("Copyright (C) 2000-2001 Eddie Kohler et al.\n\
 
896
      printf("Copyright (C) 2000-2003 Eddie Kohler et al.\n\
890
897
This is free software; see the source for copying conditions.\n\
891
898
There is NO warranty, not even for merchantability or fitness for a\n\
892
899
particular purpose.\n");
934
941
  fr.output_end = t1mac_output_end;
935
942
 
936
943
  /* prepare resource fork file */
937
 
  rfork_f = fopen("/tmp/rfork", "w+b");//tmpfile();
 
944
  rfork_f = tmpfile();
938
945
  if (!rfork_f)
939
946
    fatal_error("cannot open temorary file: %s", strerror(errno));
940
947
  for (i = 0; i < RFORK_HEADERLEN; i++)