gfsd-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gfsd]Windows build of catdoc


From: Andrea Borning
Subject: [gfsd]Windows build of catdoc
Date: Thu, 21 Jun 2001 09:38:55 -0700

I was unable to build a windows build of catdoc.

Here is the list of my changes including the code additions and changes.
These changes should not affect the unix build.

    Andrea Borning
    Insightful Corporation
    http://www.insightful.com/
    address@hidden

-----------

To do a successful windows build you must copy Makefile.mak into
the catdoc root directory.  The following files must be put into
the catdoc src directory: unistdwin32.c and unistdwin32.h

In addition the files listed under "1. files modified" must have the
modifications listed.

To build a debug exe, "catdocd.exe", (the default),
  type: "nmake -f Makefile.mak".

To build a release version, "catdoc.exe",
  type: "nmake -f Makefile.mak catdoc_release".

If you are tired of typing -f Makefile.mak to build a debug version
copy Makefile.mak to Makefile and type: "nmake".

The exe will be placed in the bin directory.
  To translate word file to ascii, type:
  "bin\catdoc.exe -a <full path name to word.doc file>"


Changes made to create windows build:

----------------------------------------------------------------------
----------------------------------------------------------------------
1. files modified (changes included below):
     catdoc.h, catdoc.c, fileutil.c
----------------------------------------------------------------------
//   catdoc.h
//    what follows include the changes which are only in the headers

#ifdef __unix
...
#else
#ifdef __WATCOMC__
#define USERRC "catdoc.rc"
#endif
...


----------------------------------------------------------------------
//   catdoc.c
//    what follows include the changes which are only in the headers and
//    the beginning of main

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

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef  __unix || __TURBOC__
#include <unistd.h>
#endif
#ifdef  __MSDOS__
#include "unistdwin32.h"
#endif
#include <ctype.h>
#include "catdoc.h"

void help(void);

char *source_csname=SOURCE_CHARSET, *dest_csname=TARGET_CHARSET;
char *format_name="ascii";

int signature_check = 1;
int wrap_margin = WRAP_MARGIN;
int (*get_unicode_char)(FILE *f) =get_8bit_char;

char *input_buffer, *output_buffer;
#ifdef __MSDOS__ || __WATCOMC__
/* watcom doesn't provide way to access program args via global variable */
/* so we would hack it ourselves in Borland-compatible way*/
char **_argv;
int _argc;
#endif
/**************************************************************/
/*       Main program                                         */
/*  Processes options, reads charsets  files and substitution */
/*  maps and passes all remaining args to processfile         */
/**************************************************************/
int main(int argc, char **argv) {
FILE *f;
int c,i;
char *tempname;
short int *tmp_charset;
int stdin_processed=0;
#ifdef __MSDOS__ || __WATCOMC__
_argv=argv;
_argc=argc;
#endif
#ifdef __unix || __WATCOMC__
read_config_file(SYSTEMRC);
#endif
#ifdef USERRC
tempname=find_file(strdup(USERRC),getenv("HOME"));
if (tempname) {
  read_config_file(tempname);
  free(tempname);
}
#endif
while...
...
}

----------------------------------------------------------------------
//   fileutil.c
//     what follows include the changes which are only in the headers

#ifdef  __unix || __TURBOC__
#include <unistd.h>
#endif
#ifdef _MSDOS__
#include "unistdwin32.h"
#include <io.h>
#endif
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
#include "catdoc.h"
#ifdef __TURBOC__
#include <dir.h>
#include <dos.h>
#endif
#if defined(MSDOS) && !defined(__MSDOS__)
#define __MSDOS__
#endif
#ifdef __MSDOS__ || __WATCOMC__
extern char **_argv;
extern int _argc;
#endif


----------------------------------------------------------------------
----------------------------------------------------------------------
2. files added (contents of each file included below):
    Makefile.mak
    src\unistdwin32.h
    src\unistdwin32.c  /* includes a utility for getopt */
----------------------------------------------------------------------
//  Makefile.mak


## To build a debug version (the default), type: "nmake -f Makefile.mak".
## To build a release version type: "nmake -f Makefile.mak catdoc_release".
## If you are tired of typing -f Makefile.mak to build a debug version
## copy Makefile.mak to Makefile and type: "nmake".

NAME = catdoc
SRC = src
ROOT = catdoc
INTDIR = $(ROOT)\int
OUTDIR = $(ROOT)\bin
LIBDIR = $(ROOT)\lib
UFILES = $(OUTDIR)\charsets
UFILES_SRC = charsets
DBG = d

CC = cl.exe
LINK32 = link.exe

CPP_PROJ_RELEASE=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D
"_CONSOLE" /D "_MBCS" /D "__MSDOS__" /Fp"$(INTDIR)\$(NAME).pch" /YX
/Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
CPP_PROJ_DEBUG=/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D
"_CONSOLE" /D "_MBCS" /D "__MSDOS__" /Fp"$(INTDIR)\$(NAME)$(DBG).pch" /YX
/Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c

LINK32_FLAGS_DEBUG=kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes
/pdb:"$(OUTDIR)\$(NAME)$(DBG).pdb" /debug /machine:I386
/out:"$(OUTDIR)\$(NAME)$(DBG).exe" /pdbtype:sept
LINK32_FLAGS_RELEASE=kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no
/pdb:"$(OUTDIR)\$(NAME).pdb" /machine:I386 /out:"$(OUTDIR)\$(NAME).exe"

FILES=$(SRC)\catdoc.c $(SRC)\charsets.c $(SRC)\substmap.c $(SRC)\reader.c
$(SRC)\writer.c $(SRC)\fileutil.c $(SRC)\unistdwin32.c

OBJ=$(INTDIR)\catdoc.obj $(INTDIR)\charsets.obj $(INTDIR)\substmap.obj
$(INTDIR)\reader.obj $(INTDIR)\writer.obj $(INTDIR)\fileutil.obj
$(INTDIR)\unistdwin32.obj



all: dirs catdoc_debug

dirs:
if not exist $(INTDIR) mkdir $(INTDIR)
if not exist $(OUTDIR) mkdir $(OUTDIR)
if not exist $(LIBDIR) mkdir $(LIBDIR)
if not exist $(UFILES) mkdir $(UFILES)
cp charsets\* $(UFILES)

objs_debug: $(FILES)
$(CC) $(CPP_PROJ_DEBUG) $(DEFS) -c $(FILES)

objs_release: $(FILES)
$(CC) $(CPP_PROJ_RELEASE) $(DEFS) -c $(FILES)

catdoc_debug: objs_debug
$(LINK32)  $(LINK32_FLAGS_DEBUG) $(OBJ)

catdoc_release: dirs objs_release
$(LINK32)  $(LINK32_FLAGS_RELEASE) $(OBJ)

clean:
del /q $(INTDIR)\*.*
del /q $(OUTDIR)\*.*


----------------------------------------------------------------------
//  src\unistdwin32.h


extern char **_argv;
extern char *optarg;
extern int  opterr, optind, optopt;
int  getopt(int, char *const *, const char *);

----------------------------------------------------------------------
//  src\unistdwin32.c  /* includes a utility for getopt */


#include <stdio.h>
#include <string.h>

int  opterr, optind, optopt;

char    *optarg;        /* Global argument pointer. */
int     optind = 0;     /* Global argv index. */

static char     *scan = NULL;   /* Private scan pointer. */

/*
* getopt - get option letter from argv
*
* from http://src.openresources.com/debian/src/news/HTML/D/getopt.html
*
*/
getopt(int argc, char *argv[], char *optstring)
/* [<][>][^][v][top][bottom][index][help] */
{
        register char c;
        register char *place;

        optarg = NULL;

        if (scan == NULL || *scan == '\0') {
                if (optind == 0)
                        optind++;

                if (optind >= argc || argv[optind][0] != '-' ||
argv[optind][1] == '\0')
                        return(EOF);
                if (strcmp(argv[optind], "--")==0) {
                        optind++;
                        return(EOF);
                }

                scan = argv[optind]+1;
                optind++;
        }

        c = *scan++;
        place = strchr(optstring, c);

        if (place == NULL || c == ':') {
                fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
                return('?');
        }

        place++;
        if (*place == ':') {
                if (*scan != '\0') {
                        optarg = scan;
                        scan = NULL;
                } else if (optind < argc) {
                        optarg = argv[optind];
                        optind++;
                } else {
                        fprintf(stderr, "%s: -%c argument missing\n",
argv[0], c);
                        return('?');
                }
        }

        return(c);
}








reply via email to

[Prev in Thread] Current Thread [Next in Thread]