-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlbp800.c
108 lines (90 loc) · 2.76 KB
/
lbp800.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* Linux Canon LBP800 CAPT driver
* main file
* Copyright (c) 2007 Massimo Del Fedele <[email protected]>
*
* Adapted from a printer driver for Samsung ML-85G laser printer
* (C) Copyleft, 2000 Rildo Pragana <[email protected]>
* and from Linux Canon CAPT LBP810 driver
* Copyright (C) 2004 Nicolas Boichat <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "machine.h"
#include "errcapt.h"
#include "bmcapt.h"
#include "lbp800.h"
////////////////////////////////////////////////////////////////
// PROGRAMMA PRINCIPALE
int main(int argc, char** argv)
{
int c;
fprintf(stderr,"lbp800:main is here\n");
// BITMAP SORGENTE
TSourceBitmap Bitmap;
// IL FILE TEMPORANEO CONTENENTE IL BITMAP COMPRESSO
FILE *CBitmapf;
// INIZIALIZZA I VALORI DI DEFAULT
Bitmap.Bitmapf = stdin;
Bitmap.TopSkip = 0;
Bitmap.LeftSkip = 0;
// LEGGE GLI ARGOMENTI ED IMPOSTA I PARAMETRI RICHIESTI
while ((c = getopt(argc,argv,"t:l:f:d:")) != -1)
{
switch (c)
{
// TOP SKIP
case 't' :
sscanf(optarg, "%d", &Bitmap.TopSkip);
break;
// LEFT SKIP
case 'l' :
sscanf(optarg, "%d", &Bitmap.LeftSkip);
break;
// FILE BITMAP
case 'f' :
Bitmap.Bitmapf = fopen(optarg, "r");
fprintf(stderr,"lbp800:main Open file %s\n", optarg);
if (!Bitmap.Bitmapf)
{
fprintf(stderr,ErrorMessages[CAPT_NoBitmap], optarg);
exit(4);
}
break;
default:
fprintf(stderr, "Usage: %s [-t topskip] [-l leftskip] [-f file]\n",
argv[0]);
exit(EXIT_FAILURE);
} // END switch()
} // END while
// COMPRIME IL BITMAP
if( (CBitmapf = CompressBitmaps(&Bitmap)) != NULL)
{
fseek(CBitmapf, 0L, SEEK_SET);
// STAMPA IL BITMAP
PrintBitmaps(CBitmapf);
// CHIUDE IL BITMAP COMPRESSO
fclose(CBitmapf);
} // if CompressBitmap
// CHIUDE IL BITMAP SORGENTE
if(Bitmap.Bitmapf != stdin)
fclose(Bitmap.Bitmapf);
// RITORNA TUTTO OK
return 0;
} // END Main()