home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Meeting Pearls 3
/
Meeting_Pearls_III.iso
/
Pearls
/
texmf
/
source
/
driver
/
print
/
amiga
/
PrintOpt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-15
|
13KB
|
392 lines
/*
** This file generated by localize 2.9 (AmigaDOS 2.1) from PrintOpt.c
*/
/* externally define -dTEST to compile a standalone version */
/* otherwise, link to DVIprint */
#ifdef TEST
#define MAIN
#endif
#define TEX
#include "defines.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <dos.h>
#include "globals.h"
#ifdef TEST
#include <clib/dos_protos.h>
#include <pragmas/dos_pragmas.h>
extern struct DosLibrary *DOSBase;
#endif
#include "muiprint.h"
#include "GetOpt.h"
#include "GetOpt.i"
#include "globals.i"
#include "PrintOpt.i"
#ifndef TEST
#include "prhelp.h"
#include "prhelp.i"
#endif
/*
* Fuer die locale-Library:
*
* Hier duerfen *nur* die MSG_#? Nummern eingebunden werden!
* Achtung:
* Es muss/sollte 'multiple-include' erlaubt sein!
*/
#include "local.i"
#undef CATCOMP_ARRAY
#undef CATCOMP_BLOCK
#undef CATCOMP_STRINGS
#define CATCOMP_NUMBERS
#include "localstr.h"
#ifdef TEST
extern char *_ProgramName;
#endif /* TEST */
static void PrintHelp(struct Options opt[], short long_hlp);
static long help = FALSE;
static long o_nlogging = FALSE;
static long odd = FALSE;
static long even = FALSE;
static char *resolution_str = NULL;
static char *filenameptr = NULL;
static long skip_formfeed = FALSE;
static char *g_paper = NULL;
START_PARAM(opt)
/* req? key-name abbrev type variable help-txt */
NOREQ_PARAM ("HELP", "?", OPT_HELP, &help, MSG_OPTIONS_HELP, 0)
NOREQ_PARAM ("GUI", NULL, OPT_BOOLEAN, &usegui, MSG_OPTIONS_GUI, 0)
NOREQ_PARAM ("FONTDir", "-a", OPT_STRING, &PXLpath, MSG_OPTIONS_FONTDIR, 0)
NOREQ_PARAM ("FONTMem", "-b", OPT_LONG, &fontmemsize, MSG_OPTIONS_FONTMEM, 0)
NOREQ_PARAM ("MAXBITMem", "-m", OPT_LONG, &maxbitmapsize, MSG_OPTIONS_MAXBITMEM,MSG_OPTIONS_MAXBITMEM2)
NOREQ_PARAM ("PRTBUFfer", "-e", OPT_LONG, &bufflen, MSG_OPTIONS_PRTBUFFER, 0)
NOREQ_PARAM ("From", "-f", OPT_LONG, &FirstPage, MSG_OPTIONS_FROM, 0)
NOREQ_PARAM ("To", "-t", OPT_LONG, &LastPage, MSG_OPTIONS_TO, 0)
NOREQ_PARAM ("Number", "-n", OPT_LONG, &NrOfPagesToPrint, MSG_OPTIONS_NUMBER, 0)
NOREQ_PARAM ("ODD", "-1", OPT_BOOLEAN, &odd, MSG_OPTIONS_ODD, 0)
NOREQ_PARAM ("EVEN", "-2", OPT_BOOLEAN, &even, MSG_OPTIONS_EVEN, 0)
NOREQ_PARAM ("PHYsical", "-y", OPT_BOOLEAN, &PhyPageNumbers, MSG_OPTIONS_PHYSICAL, 0)
NOREQ_PARAM ("HOFFset", "-h", OPT_TEX_DIM, &hoffset_in_fix, MSG_OPTIONS_HOFFSET,MSG_OPTIONS_HVOFFSET2)
NOREQ_PARAM ("VOFFset", "-v", OPT_TEX_DIM, &voffset_in_fix, MSG_OPTIONS_VOFFSET,MSG_OPTIONS_HVOFFSET2)
NOREQ_PARAM ("Printer", "-d", OPT_STRING, &o_printer_name, MSG_OPTIONS_PRINTER, 0)
NOREQ_PARAM ("OPTimize", "-o", OPT_BOOLEAN, &o_optimize, MSG_OPTIONS_OPTIMIZE,0)
NOREQ_PARAM ("DRAft", NULL, OPT_BOOLEAN, &draft, MSG_OPTIONS_DRAFT, 0)
NOREQ_PARAM ("DENsity", "-O", OPT_LONG, &o_density, MSG_OPTIONS_DENSITY,MSG_OPTIONS_DENSITY2)
NOREQ_PARAM ("UNIdirect", "-u", OPT_BOOLEAN, &unidirect, MSG_OPTIONS_UNIDIRECT, 0)
NOREQ_PARAM ("COPies", "-c", OPT_LONG, &ncopies, MSG_OPTIONS_COPIES, 0)
NOREQ_PARAM ("LANDscape", "-g", OPT_BOOLEAN, &landscape, MSG_OPTIONS_LANDSCAPE, 0)
NOREQ_PARAM ("TWOup", NULL, OPT_BOOLEAN, &twopage, MSG_OPTIONS_TWOPAGE, 0)
NOREQ_PARAM ("MOFFset", NULL, OPT_TEX_DIM, &moffset_in_fix, MSG_OPTIONS_MOFFSET,MSG_OPTIONS_HVOFFSET2)
HIDDEN_PARAM("BOOK", NULL, OPT_BOOLEAN, &bookmode, MSG_OPTIONS_BOOK, 0)
NOREQ_PARAM ("IFF", "-i", OPT_BOOLEAN, &iffprint, MSG_OPTIONS_IFF, 0)
NOREQ_PARAM ("SKIPformfeed","-x", OPT_BOOLEAN, &skip_formfeed, MSG_OPTIONS_SKIPFORMFEED, 0)
NOREQ_PARAM ("REVerse", "-r", OPT_BOOLEAN, &Reverse, MSG_OPTIONS_REVERSE, 0)
NOREQ_PARAM ("RESolution", "-z", OPT_STRING, &resolution_str, MSG_OPTIONS_RESOLUTION,MSG_OPTIONS_RESOLUTION2)
NOREQ_PARAM ("WIDTH", NULL, OPT_TEX_DIM, &user_paper_width_in, MSG_OPTIONS_WIDTH, 0)
NOREQ_PARAM ("HEIGHT", NULL, OPT_TEX_DIM, &user_paper_height_in, MSG_OPTIONS_HEIGHT, 0)
NOREQ_PARAM ("PAPERSIZE", NULL, OPT_STRING, &g_paper, MSG_OPTIONS_PAPER, MSG_OPTIONS_PAPER2)
NOREQ_PARAM ("PUBscreen", NULL, OPT_STRING, &ArgPubname, MSG_OPTIONS_PUBSCREEN, 0)
NOREQ_PARAM ("PREload", "-p", OPT_BOOLEAN, &PreLoad, MSG_OPTIONS_PRELOAD, 0)
HIDDEN_PARAM("FAST", "-T", OPT_BOOLEAN, &turbo_mode, MSG_OPTIONS_FAST,MSG_OPTIONS_FAST2)
NOREQ_PARAM ("MARK", NULL, OPT_BOOLEAN, &mark_fonts, MSG_OPTIONS_MARK, 0)
NOREQ_PARAM ("STATistic", "-s", OPT_BOOLEAN, &Stats, MSG_OPTIONS_STATISTIC, 0)
HIDDEN_PARAM("DEBUGStat", "-S", OPT_BOOLEAN, &DebugStats, MSG_OPTIONS_DEBUGSTAT, 0)
NOREQ_PARAM ("NOLog", "-l", OPT_BOOLEAN, &o_nlogging, MSG_OPTIONS_NOLOG, 0)
NOREQ_PARAM ("OUTto", "->", OPT_STRING, &output_file_name, MSG_OPTIONS_OUTTO,MSG_OPTIONS_OUTTO2)
NOREQ_PARAM ("LOGName", NULL, OPT_STRING, &g_Logname, MSG_OPTIONS_LOGNAME, 0)
NOREQ_PARAM ("SHOWPrinters",NULL, OPT_BOOLEAN, &o_showprinter, MSG_OPTIONS_SHOWPRINTERS, 0)
NOREQ_PARAM ("ACCounting", NULL, OPT_BOOLEAN, &do_accounting, MSG_OPTIONS_ACCOUNTING, 0)
NOREQ_PARAM ("PRIOrity", NULL, OPT_LONG, &task_priority, MSG_OPTIONS_PRIORITY, 0)
NOREQ_PARAM ("SPECIALhost", NULL, OPT_BOOLEAN, &start_specialhost,MSG_OPTIONS_SPECIALHOST, 0)
HIDDEN_PARAM("PRINTAUTHOR", NULL, OPT_BOOLEAN, &g_authors, MSG_OPTIONS_PRINTAUTHOR, 0)
NOREQ_PARAM (NULL, NULL, OPT_OPTIONSTRING, &filenameptr, MSG_OPTIONS_DVIFILE, 0)
END_PARAM
void DecodeArgs(int argc, char *argv[])
{
BOOL error;
char pri;
#ifdef TEST
o_printer_name= "generic";
#else /* TEST */
o_printer_name= default_printer_name;
#endif /* TEST */
/* PXLpath = FONTAREA; */ /* default font area */
hoffset_in_fix = HOFFSET_IN; /* inch */
hoffset_is_true = TRUE; /* true inch? */
voffset_in_fix = VOFFSET_IN; /* inch */
voffset_is_true = TRUE; /* true inch? */
moffset_in_fix = MOFFSET_IN; /* twopage mid-offset */
moffset_is_true = TRUE;
twopage = leftpage = FALSE;
mark_fonts = FALSE;
GetOneOpt(&hoffset_in_fix, opt)->special = 1;
GetOneOpt(&voffset_in_fix, opt)->special = 1;
o_optimize = TRUE;
unidirect = TRUE; /* safe default */
fontmemsize = FONTMEMSIZE;
maxbitmapsize = MAXBITMAPSIZE; /* maximal size of bitmap */
FirstPage =-1000000L; /* first page to print (uses count0) */
LastPage = 1000000L; /* last page to print */
bufflen = 10240L; /* printer buffer */
do_accounting = FALSE; /* default: no accounting */
ncopies = 1; /* default: one copy */
NrOfPagesToPrint = 1000000L; /* default: viele viele Seiten drucken */
PhyPageNumbers = FALSE;
usegui = FALSE; /* default: kein GUI */
/*----------------------------------------------------------------*/
error = GetOpt(argc, argv, "DVIprint", TRUE, opt);
/*----------------------------------------------------------------*/
if (error) {
PrintHelp(opt, FALSE);
AbortRun(5); /* Programm Ende */
}
if (help) {
PrintHelp(opt, TRUE);
AbortRun(0);
}
if (g_paper) {
int i;
for (i=0; psizes[i].name; i++) {
if (!stricmp(g_paper, psizes[i].name)) {
// Papiergroesse *inklusive* dem Offset!
if (abs(user_paper_width_in+13.13) > 0.01) Warning(MSG_PAPER_WIDTH_HEIGHT_ERR, "WIDTH");
if (abs(user_paper_height_in+13.13) > 0.01) Warning(MSG_PAPER_WIDTH_HEIGHT_ERR, "HEIGHT");
user_paper_width_in = psizes[i].width;
user_paper_height_in = psizes[i].height;
break;
}
}
if (!psizes[i].name) {
Fatal(5, MSG_UNKNOWN_PAPER_SIZE, g_paper);
}
}
if (Reverse && twopage) {
Fatal(1, MSG_REVERSE_TWOUP_ERR);
}
/* Now we can check the arguments */
g_logging = o_nlogging ? -1 : 0;
last_form_feed= !skip_formfeed;
if (Reverse) PreLoad = TRUE;
if (DebugStats) Stats = 2L;
if (landscape || iffprint) full_page_in_ram = TRUE;
pri = (char)task_priority;
if (task_priority > 10 || task_priority < -10) {
task_priority = 0;
}
else {
task_priority = 0;
task_priority |= (unsigned long)((unsigned char)pri);
}
if (ncopies <= 0 || ncopies > 99) {
Fatal(5,MSG_WRONG_NUM_COPIES);
}
if (NrOfPagesToPrint < 1) {
Fatal(5,MSG_PRINT_AT_LEAST_ONE_PAGE);
}
/* true Flags setzen (die Flags sind nicht mehr von Interesse (IMMER true)) */
hoffset_is_true = GetOneOpt(&hoffset_in_fix, opt)->special;
voffset_is_true = GetOneOpt(&voffset_in_fix, opt)->special;
moffset_is_true = GetOneOpt(&moffset_in_fix, opt)->special;
if ( 0 < CheckOpt_Given(&resolution_str,opt)) {
if (2 != sscanf(resolution_str, "%d/%d%*c ", &hconvresolution, &vconvresolution)) {
if (1 != sscanf(resolution_str, "%d%*c ", &resolution)) {
Fatal(5,MSG_WRONG_RESO_FORMAT, resolution_str);
}
else hconvresolution = vconvresolution = resolution; /* 1 */
}
else resolution = 0; /* 2 */
}
if (twopage) {
leftpage = TRUE; // bei zweiseiten fangen wir immer links an :)
}
/* bufflen testen ? */
/* check incoherencies */
if (odd && even) {
Fatal(5,MSG_NO_ODD_NO_EVEN);
}
if (odd) print_page_numbers = 1;
if (even) print_page_numbers = 2;
/* density testen */
if (0 < CheckOpt_Given(&o_density,opt)) {
if (o_density < 1 || o_density > 7) {
Fatal(5,MSG_DENSITY_RANGE);
}
}
if (maxbitmapsize != 0L && maxbitmapsize < MINBITMAPSIZE) {
maxbitmapsize = MINBITMAPSIZE;
Warning(MSG_BITMAP_MEM_MINIMUM,maxbitmapsize);
}
if (turbo_mode && (iffprint || output_file_name)) {
turbo_mode = FALSE; /* Aber kein Fehler */
}
if (iffprint) ToDo |= DO_NOZERO;
if (output_file_name) ToDo |= DO_OUTFILE | DO_NOZERO;
if (!iffprint && !output_file_name) ToDo |= DO_REALPRINT;
/* und DO_NOZERO fuer HP und SLM ... ? */
/* *KEIN* DO_NOZERO fuer Generic */
/* output_file_name ? */
if (0 == CheckOpt_Given(&o_printer_name,opt)) no_printer_given = 1;
if (0 < CheckOpt_Given(&filenameptr,opt)) {
#if 0 /* allgemeines Modell */
char *p1,*p2;
p1 = strchr(filename, ':');
p2 = strrchr(p1 ? p1+1 : filename, '/');
p1 = strrchr(p2 ? p2+1 : p1+1, '.');
if (NULL == p1 || 0 != stricmp(p1,".dvi"))
strcat(filename, ".dvi");
else ; /* .tex wird nicht getestet */
#else
strcpy(filename, filenameptr);
if (getfa(filenameptr) != 1) { // also KEIN Directory
char *p;
p = strrchr(filename, '.');
if (p) {
if (!stricmp(p, ".tex")) {
strcpy(p, ".dvi"); // .tex durch .dvi ersetzen
}
}
if (!p || stricmp(p,".dvi")) { // kein . oder kein .dvi
if (getfa(filenameptr) == 0) { // File gibt es wohl so nicht
strcat(filename, ".dvi"); // dann haengen wir .dvi an
}
}
}
#endif
}
else {
filename[0]='\0';
if (no_printer_given) {
if (!o_showprinter && !usegui) {
Warning(MSG_TRY_HELP_SHOWP,
g_progname, g_progname);
AbortRun(5);
}
#if defined(LOESUNG)
else {
o_printer_name = ""; /* soll nicht nur "generic" anzeigen!! (hes) */
}
#endif
}
}
if (usegui) {
MUImainwin();
}
}
static void PrintHelp(struct Options opt[], short long_hlp)
{
char * hlp;
hlp = xmalloc(100);
MessageStr(NULL);
Message(MSG_COPYRIGHT,__DATE__);
sprintf(hlp, GetTeXString(MSG_USAGE), g_progname);
GetOptShortHelp(hlp, 73, opt);
xfree(hlp);
if (long_hlp) {
MessageStr("");
GetOptHelp(opt);
}
}
#ifdef TEST
void main(int argc, char *argv[])
{
g_progname = 0 == argc ? _ProgramName : argv[0];
g_Logname = DVIPRINT_LOGFILE;
DecodeArgs(argc, argv);
printf("help: '%ld'\n", help);
printf("PXLpath: '%s'\n", PXLpath);
printf("fontmemsize: '%ld'\n", fontmemsize);
printf("maxbitmapsize: '%ld'\n", maxbitmapsize);
printf("FirstPage: '%ld'\n", FirstPage);
printf("LastPage: '%ld'\n", LastPage);
printf("hoffset_in_fix: '%f'\n", hoffset_in_fix);
printf("voffset_in_fix: '%f'\n", voffset_in_fix);
printf("PreLoad: '%ld'\n", PreLoad);
printf("Reverse: '%ld'\n", Reverse);
printf("unidir: '%ld'\n", unidirect);
printf("resolution: '%d'\n", resolution);
printf("hresolution: '%d'\n", hconvresolution);
printf("vresolution: '%d'\n", vconvresolution);
printf("optimize: '%ld'\n", o_optimize);
printf("Stats: '%ld'\n", Stats);
printf("DebugStats: '%ld'\n", DebugStats);
printf("logging: '%ld'\n", !o_nlogging);
printf("g_authors: '%ld'\n", g_authors);
printf("Printer: '%s'\n", o_printer_name);
printf("Logfile: '%s'\n", g_Logname);
printf("Filename: '%s'\n", filename);
if (argc == 0) {
Delay(200);
}
}
#endif /* TEST */