Browse Source

Print + basic main compiles, runs, creates black bmp

master
suhrke 3 years ago
parent
commit
29d595963b
7 changed files with 225 additions and 151 deletions
  1. 3
    3
      Makefile
  2. 14
    9
      src/Compress.cpp
  3. 32
    23
      src/Ecc.cpp
  4. 75
    42
      src/Fileproc.cpp
  5. 23
    23
      src/Printer.cpp
  6. 47
    18
      src/main.cpp
  7. 31
    33
      src/paperbak.h

+ 3
- 3
Makefile View File

@@ -1,14 +1,14 @@
EX=paperback-cli
SDIR=./src
CC=g++
CFLAGS=-std=c++11 -I"$(SDIR)" -I"$(SDIR)/PortLibCpp/src" -I"$(SDIR)/cxxopts/include" -I"$(SDIR)/BZLIB/" -I"$(SDIR)/AES" -g
CFLAGS=-std=c++11 -I"$(SDIR)" -I"$(SDIR)/PortLibCpp/src" -I"$(SDIR)/cxxopts/include" -I"$(SDIR)/AES" -I"$(SDIR)/BZLIB"

all: main

main: $(SDIR)/main.cpp $(SDIR)/Decoder.cpp $(SDIR)/Printer.cpp $(SDIR)/Fileproc.cpp
main: $(SDIR)/main.cpp $(SDIR)/Printer.cpp $(SDIR)/Crc16.cpp $(SDIR)/Ecc.cpp $(SDIR)/BZLIB/bz_lib.cpp $(SDIR)/BZLIB/bz_blocksort.cpp $(SDIR)/BZLIB/bz_compress.cpp $(SDIR)/BZLIB/bz_crctable.cpp $(SDIR)/BZLIB/bz_decompress.cpp $(SDIR)/BZLIB/bz_huffman.cpp $(SDIR)/BZLIB/bz_randtable.cpp $(SDIR)/AES/ae_aes.cpp #$(SDIR)/Fileproc.cpp $(SDIR)/Decoder.cpp
$(CC) $^ $(CFLAGS) -o $(EX)

msys: $(SDIR)/main.cpp $(SDIR)/Decoder.cpp $(SDIR)/Printer.cpp $(SDIR)/Fileproc.cpp
msys: $(SDIR)/main.cpp $(SDIR)/Printer.cpp $(SDIR)/Fileproc.cpp $(SDIR)/Decoder.cpp
$(CC) $^ $(CFLAGS) -o $(EX) -mwin32



+ 14
- 9
src/Compress.cpp View File

@@ -1,6 +1,11 @@

/* Author: David Bourgin, 1995 */

#include <stdint.h>




#define DBITLEN 16 // Max. dictionary size is 2**DBITLEN
#define NBITS 8 // We deal with bytes, aren't we?

@@ -21,16 +26,16 @@ static t_dentry *ddict; // Pointer to decoding dictionary

static uint ndict; // Current number of words in dictionary
static uchar *bout; // Pointer to output buffer
static ulong nbout; // Size of output buffer
static ulong nout; // Actual number of output bytes
static uint32_t nbout; // Size of output buffer
static uint32_t nout; // Actual number of output bytes
static uchar *bin; // Pointer to input buffer
static ulong nbin; // Size of input buffer
static ulong nin; // Actual number of input bytes
static ulong wrvalue;
static ulong rdvalue;
static uint32_t nbin; // Size of input buffer
static uint32_t nin; // Actual number of input bytes
static uint32_t wrvalue;
static uint32_t rdvalue;
static uint wrbits;
static uint rdbits;
static ulong codelen; // Current number of bits in output code
static uint32_t codelen; // Current number of bits in output code


// Write codelen bits to the output buffer.
@@ -48,7 +53,7 @@ void Writecode(uint value) {
// Compress the input buffer of length nbufin into the output buffer of length
// nbufout. Function returns the length of the compressed data or -1 if some
// error was detected during compression.
int Compress(uchar *bufin,ulong nbufin,uchar *bufout,ulong nbufout) {
int Compress(uchar *bufin,uint32_t nbufin,uchar *bufout,uint32_t nbufout) {
t_centry *currnode,*newnode;
int i;
ushort symbol;
@@ -146,7 +151,7 @@ uint Readcode(void) {
// Decompress the input buffer of length nbufin into the output buffer of length
// nbufout. Function returns the length of the decompressed data or -1 if some
// error was detected during decompression.
int Decompress(uchar *bufin,ulong nbufin,uchar *bufout,ulong nbufout) {
int Decompress(uchar *bufin,uint32_t nbufin,uchar *bufout,uint32_t nbufout) {
uint i;
uint prevcode,currcode;
uint firstchar;

+ 32
- 23
src/Ecc.cpp View File

@@ -7,12 +7,17 @@
// //
////////////////////////////////////////////////////////////////////////////////

#include <stdint.h>
#include <string.h>

typedef unsigned char uchar;
typedef unsigned int uint;

uchar alpha[] = {




uchar rs_alpha[] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
0x87, 0x89, 0x95, 0xad, 0xdd, 0x3d, 0x7a, 0xf4,
0x6f, 0xde, 0x3b, 0x76, 0xec, 0x5f, 0xbe, 0xfb,
@@ -47,7 +52,7 @@ uchar alpha[] = {
0xee, 0x5b, 0xb6, 0xeb, 0x51, 0xa2, 0xc3, 0x00
};

uchar index[] = {
uchar rs_index[] = {
255, 0, 1, 99, 2, 198, 100, 106,
3, 205, 199, 188, 101, 126, 107, 42,
4, 141, 206, 78, 200, 212, 189, 225,
@@ -95,15 +100,15 @@ void Encode8(uchar *data,uchar *bb,int pad) {
uchar feedback;
memset(bb,0,32);
for (i=0; i<223-pad; i++) {
feedback=index[data[i]^bb[0]];
feedback=rs_index[data[i]^bb[0]];
if (feedback!=255) {
for (j=1; j<32; j++) {
bb[j]^=alpha[(feedback+poly[32-j])%255];
bb[j]^=rs_alpha[(feedback+poly[32-j])%255];
};
};
memmove(bb,bb+1,31);
if (feedback!=255)
bb[31]=alpha[(feedback+poly[0])%255];
bb[31]=rs_alpha[(feedback+poly[0])%255];
else
bb[31]=0;
;
@@ -123,39 +128,39 @@ int Decode8(uchar *data,int *eras_pos,int no_eras,int pad) {
if (s[i]==0)
s[i]=data[j];
else
s[i]=data[j]^alpha[(index[s[i]]+(112+i)*11)%255];
s[i]=data[j]^rs_alpha[(rs_index[s[i]]+(112+i)*11)%255];
;
};
};
syn_error=0;
for (i=0; i<32; i++) {
syn_error|=s[i];
s[i]=index[s[i]]; };
s[i]=rs_index[s[i]]; };
if (syn_error==0) {
count=0; goto finish; };
memset(lambda+1,0,32);
lambda[0]=1;
if (no_eras>0) {
lambda[1]=alpha[(11*(254-eras_pos[0]))%255];
lambda[1]=rs_alpha[(11*(254-eras_pos[0]))%255];
for (i=1; i<no_eras; i++) {
u=(uchar)((11*(254-eras_pos[i]))%255);
for (j=i+1; j>0; j--) {
tmp=index[lambda[j-1]];
if (tmp!=255) lambda[j]^=alpha[(u+tmp)%255];
tmp=rs_index[lambda[j-1]];
if (tmp!=255) lambda[j]^=rs_alpha[(u+tmp)%255];
};
};
};
for (i=0; i<33; i++)
b[i]=index[lambda[i]];
b[i]=rs_index[lambda[i]];
r=el=no_eras;
while (++r<=32) {
discr_r=0;
for (i=0; i<r; i++) {
if ((lambda[i]!=0) && (s[r-i-1]!=255)) {
discr_r^=alpha[(index[lambda[i]]+s[r-i-1])%255];
discr_r^=rs_alpha[(rs_index[lambda[i]]+s[r-i-1])%255];
};
};
discr_r=index[discr_r];
discr_r=rs_index[discr_r];
if (discr_r==255) {
memmove(b+1,b,32);
b[0]=255; }
@@ -163,7 +168,7 @@ int Decode8(uchar *data,int *eras_pos,int no_eras,int pad) {
t[0]=lambda[0];
for (i=0; i<32; i++) {
if (b[i]!=255)
t[i+1]=lambda[i+1]^alpha[(discr_r+b[i])%255];
t[i+1]=lambda[i+1]^rs_alpha[(discr_r+b[i])%255];
else
t[i+1]=lambda[i+1];
;
@@ -171,7 +176,7 @@ int Decode8(uchar *data,int *eras_pos,int no_eras,int pad) {
if (2*el<=r+no_eras-1) {
el=r+no_eras-el;
for (i=0; i<=32; i++)
b[i]=(uchar)(lambda[i]==0?255:(index[lambda[i]]-discr_r+255)%255);
b[i]=(uchar)(lambda[i]==0?255:(rs_index[lambda[i]]-discr_r+255)%255);
; }
else {
memmove(b+1,b,32);
@@ -181,7 +186,7 @@ int Decode8(uchar *data,int *eras_pos,int no_eras,int pad) {
};
deg_lambda=0;
for (i=0; i<33; i++) {
lambda[i]=index[lambda[i]];
lambda[i]=rs_index[lambda[i]];
if (lambda[i]!=255) deg_lambda=i; };
memcpy(reg+1,lambda+1,32);
count=0;
@@ -190,7 +195,7 @@ int Decode8(uchar *data,int *eras_pos,int no_eras,int pad) {
for (j=deg_lambda; j>0; j--) {
if (reg[j]!=255) {
reg[j]=(uchar)((reg[j]+j)%255);
q^=alpha[reg[j]];
q^=rs_alpha[reg[j]];
};
};
if (q!=0) continue;
@@ -206,27 +211,27 @@ int Decode8(uchar *data,int *eras_pos,int no_eras,int pad) {
tmp=0;
for (j=i; j>=0; j--) {
if ((s[i-j]!=255) && (lambda[j]!=255)) {
tmp^=alpha[(s[i-j]+lambda[j])%255];
tmp^=rs_alpha[(s[i-j]+lambda[j])%255];
};
};
omega[i]=index[tmp];
omega[i]=rs_index[tmp];
};
for (j=count-1; j>=0; j--) {
num1=0;
for (i=deg_omega; i>=0; i--) {
if (omega[i]!=255) {
num1^=alpha[(omega[i]+i*root[j])%255];
num1^=rs_alpha[(omega[i]+i*root[j])%255];
};
};
num2=alpha[(root[j]*111+255)%255];
num2=rs_alpha[(root[j]*111+255)%255];
den=0;
for (i=(deg_lambda<31?deg_lambda:31) & ~1; i>=0; i-=2) {
if (lambda[i+1]!=255) {
den^=alpha[(lambda[i+1]+i*root[j])%255];
den^=rs_alpha[(lambda[i+1]+i*root[j])%255];
};
};
if (num1!=0 && loc[j]>=pad) {
data[loc[j]-pad]^=alpha[(index[num1]+index[num2]+255-index[den])%255];
data[loc[j]-pad]^=rs_alpha[(rs_index[num1]+rs_index[num2]+255-rs_index[den])%255];
};
};
finish:
@@ -235,3 +240,7 @@ finish:
return count;
};






+ 75
- 42
src/Fileproc.cpp View File

@@ -95,11 +95,11 @@ int Startnextpage(t_superblock *superblock) {
memset(pf,0,sizeof(t_fproc));
// Allocate block and recovery tables.
pf->nblock=(superblock->datasize+NDATA-1)/NDATA;
pf->datavalid=(uchar *)GlobalAlloc(GPTR,pf->nblock);
pf->data=(uchar *)GlobalAlloc(GPTR,pf->nblock*NDATA);
pf->datavalid=(uchar *)calloc(pf->nblock);
pf->data=(uchar *)calloc(pf->nblock*NDATA);
if (pf->datavalid==NULL || pf->data==NULL) {
if (pf->datavalid!=NULL) GlobalFree((HGLOBAL)pf->datavalid);
if (pf->data!=NULL) GlobalFree((HGLOBAL)pf->data);
if (pf->datavalid!=NULL) free(pf->datavalid);
if (pf->data!=NULL) free(pf->data);
Reporterror("Low memory");
return -1; };
// Initialize remaining fields.
@@ -281,7 +281,8 @@ int Saverestoredfile(int slot,int force) {
uchar *bufout,*data,*tempdata;
t_fproc *pf;
aes_context ctx;
HANDLE hfile;
//HANDLE hfile;
FILE *hfile;
if (slot<0 || slot>=NFILE)
return -1; // Invalid index of file descriptor
pf=fproc+slot;
@@ -293,37 +294,44 @@ int Saverestoredfile(int slot,int force) {
// If data is encrypted, decrypt it to temporary buffer. Decryption in place
// is possible, but the whole data would be lost if password is incorrect.
if (pf->mode & PBM_ENCRYPTED) {
if (pf->datasize & 0x0000000F) {
Reporterror("Encrypted data is not aligned");
return -1; };
if (Getpassword()!=0)
return -1; // User cancelled decryption
tempdata=(uchar *)GlobalAlloc(GMEM_FIXED,pf->datasize);
if (tempdata==NULL) {
Reporterror("Low memory, can't decrypt data");
return -1; };
n=strlen(password);
while (n<PASSLEN) password[n++]=0;
memset(&ctx,0,sizeof(ctx));
aes_set_key(&ctx,(uchar *)password,256);
for (l=0; l<pf->datasize; l+=16)
aes_decrypt(&ctx,pf->data+l,tempdata+l);
filecrc=Crc16(tempdata,pf->datasize);
if (filecrc!=pf->filecrc) {
Reporterror("Invalid password, please try again");
GlobalFree((HGLOBAL)tempdata);
return -1; }
else {
GlobalFree((HGLOBAL)pf->data);
pf->data=tempdata;
pf->mode&=~PBM_ENCRYPTED;
};
//FIXME securely get password from user
Reporterror("Encryption/Decryption not supported yet");
return -1;
//if (pf->datasize & 0x0000000F) {
// Reporterror("Encrypted data is not aligned");
// return -1;
//};
//if (Getpassword()!=0)
// return -1; // User cancelled decryption
//tempdata=(uchar *)GlobalAlloc(GMEM_FIXED,pf->datasize);
//if (tempdata==NULL) {
// Reporterror("Low memory, can't decrypt data");
// return -1;
//};
//n=strlen(password);
//while (n<PASSLEN) password[n++]=0;
//memset(&ctx,0,sizeof(ctx));
//aes_set_key(&ctx,(uchar *)password,256);
//for (l=0; l<pf->datasize; l+=16)
// aes_decrypt(&ctx,pf->data+l,tempdata+l);
//filecrc=Crc16(tempdata,pf->datasize);
//if (filecrc!=pf->filecrc) {
// Reporterror("Invalid password, please try again");
// GlobalFree((HGLOBAL)tempdata);
// return -1;
//}
//else {
// GlobalFree((HGLOBAL)pf->data);
// pf->data=tempdata;
// pf->mode&=~PBM_ENCRYPTED;
//};
};
// If data is compressed, unpack it to temporary buffer.
if ((pf->mode & PBM_COMPRESSED)==0) {
// Data is not compressed.
data=pf->data; length=pf->origsize;
bufout=NULL; }
bufout=NULL;
}
else {
// Data is compressed. Create temporary buffer.
if (pf->origsize==0)
@@ -342,26 +350,51 @@ int Saverestoredfile(int slot,int force) {
return -1; };
data=bufout; };
// Ask user for file name.
if (Selectoutfile(pf->name)!=0) { // Cancelled by user
// FIXME selectoutfile must be initialized prior/by arg
if (pf->name!=NULL) {
if (bufout!=NULL) GlobalFree((HGLOBAL)bufout);
return -1; };
return -1;
};
// Open file and save data.
hfile=CreateFile(outfile,GENERIC_WRITE,0,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if (hfile==INVALID_HANDLE_VALUE) {
if (bufout!=NULL) GlobalFree((HGLOBAL)bufout);
//hfile=CreateFile(outfile,GENERIC_WRITE,0,NULL,
// CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
hfile = fopen (outfile, "wb");
if (hfile==NULL) {
if (bufout!=NULL)
free(bufout);
Reporterror("Unable to create file");
return -1; };
WriteFile(hfile,data,length,&l,NULL);
return -1;
};

//WriteFile(hfile,data,length,&l,NULL);
l = fwrite (data, sizeof(char), length, hfile);
// Restore old modification date and time.
SetFileTime(hfile,&pf->modified,&pf->modified,&pf->modified);
#ifdef _WIN32
// open HANDLE and set file time
handleFile=CreateFile(outfile,GENERIC_WRITE,0,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if (handleFile==INVALID_HANDLE_VALUE) {
if (bufout!=NULL)
free(bufout);
Reporterror("Unable to open handle to set file time");
return -1;
};
SetFileTime(handleFile,&pf->modified,&pf->modified,&pf->modified);
// Close file and restore old basic attributes.
CloseHandle(hfile);
SetFileAttributes(outfile,pf->attributes);
if (bufout!=NULL) GlobalFree((HGLOBAL)bufout);
if (bufout!=NULL)
free(bufout);
if (l!=length) {
Reporterror("I/O error");
return -1; };
return -1;
};
#elif __linux__
// Set file time
// FIXME left off here
// Restore mode

#endif
// Close file descriptor and report success.
Closefproc(slot);
Message("File saved",0);

+ 23
- 23
src/Printer.cpp View File

@@ -250,11 +250,11 @@ static void Preparefiletoprint(t_printdata *print)
Stopprinting(print);
return; };
// Set options.
print->compression=compression;
print->encryption=encryption;
print->printheader=printheader;
print->printborder=printborder;
print->redundancy=redundancy;
print->compression=pb_compression;
print->encryption=pb_encryption;
print->printheader=pb_printheader;
print->printborder=pb_printborder;
print->redundancy=pb_redundancy;
// Step finished.
print->step++;
};
@@ -400,22 +400,22 @@ static void Encryptdata(t_printdata *print) {
// Stopprinting(print);
// return; };
// Empty password means: leave data unencrypted.
if (password[0]=='\0') {
if (pb_password[0]=='\0') {
print->encryption=0;
print->step++;
return; };
// Encryption routine expects that password is exactly PASSLEN bytes long.
// Fill rest of the password with zeros.
n=strlen(password);
while (n<PASSLEN) password[n++]=0;
n=strlen(pb_password);
while (n<PASSLEN) pb_password[n++]=0;
// Initialize encryption.
memset(&ctx,0,sizeof(ctx));
aes_set_key(&ctx,(uchar *)password,256);
aes_set_key(&ctx,(uchar *)pb_password,256);
// Encrypt data. AES works with 16-byte data chunks.
for (l=0; l<print->alignedsize; l+=16)
aes_encrypt(&ctx,print->buf+l,print->buf+l);
// Clear password and encryption control block. We no longer need them.
memset(password,0,sizeof(password));
memset(pb_password,0,sizeof(pb_password));
memset(&ctx,0,sizeof(ctx));
// Step finished.
print->step++;
@@ -546,10 +546,10 @@ static void Initializeprinting(t_printdata *print) {
//print->dc=NULL;
print->frompage=0;
print->topage=9999;
if (resx==0 || resy==0) {
if (pb_resx==0 || pb_resy==0) {
print->ppix=300; print->ppiy=300; }
else {
print->ppix=resx; print->ppiy=resy;
print->ppix=pb_resx; print->ppiy=pb_resy;
};

//if (pagesetup.Flags & PSD_INTHOUSANDTHSOFINCHES) {
@@ -599,10 +599,10 @@ static void Initializeprinting(t_printdata *print) {
// Calculate data point raster (dx,dy) and size of the point (px,py) in the
// pixels of printer's resolution. Note that pixels, at least in theory, may
// be non-rectangular.
dx=std::max(print->ppix/dpi,2);
px=std::max((dx*dotpercent)/100,1);
dy=std::max(print->ppiy/dpi,2);
py=std::max((dy*dotpercent)/100,1);
dx=std::max(print->ppix/pb_dpi,2);
px=std::max((dx*pb_dotpercent)/100,1);
dy=std::max(print->ppiy/pb_dpi,2);
py=std::max((dy*pb_dotpercent)/100,1);
// Calculate width of the border around the data grid.
if (print->printborder)
print->border=dx*16;
@@ -719,7 +719,7 @@ static void Printnextpage(t_printdata *print) {
uint32_t u,size,pagesize,offset;
t_data block,cksum;
//HANDLE hbmpfile;
FILE * hbmpfile;
FILE *hbmpfile;
BITMAPFILEHEADER bmfh;
BITMAPINFO *pbmi;
// Calculate offset of this page in data.
@@ -993,16 +993,16 @@ void Nextdataprintingstep(t_printdata *print) {
};

// Sends specified file to printer (bmp=NULL) or to bitmap file.
void Printfile(char *path,char *bmp) {
void Printfile(const char *path, const char *bmp) {
// Stop printing of previous file, if any.
//Stopprinting(&printdata);
//Stopprinting(&pb_printdata);
// Prepare descriptor.
memset(&printdata,0,sizeof(printdata));
strncpy(printdata.infile,path,MAXPATH-1);
memset(&pb_printdata,0,sizeof(pb_printdata));
strncpy(pb_printdata.infile,path,MAXPATH-1);
if (bmp!=NULL)
strncpy(printdata.outbmp,bmp,MAXPATH-1);
strncpy(pb_printdata.outbmp,bmp,MAXPATH-1);
// Start printing.
printdata.step=1;
pb_printdata.step=1;
//Updatebuttons();
};


+ 47
- 18
src/main.cpp View File

@@ -30,6 +30,35 @@ using namespace std;



// Global forward declarations
int pb_resx, pb_resy; // Printer resolution, dpi (may be 0!)
t_printdata pb_printdata; // Print control structure
int pb_orientation; // Orientation of bitmap (-1: unknown)
t_procdata pb_procdata; // Descriptor of processed data
char pb_infile[MAXPATH]; // Last selected file to read
char pb_outbmp[MAXPATH]; // Last selected bitmap to save
char pb_inbmp[MAXPATH]; // Last selected bitmap to read
char pb_outfile[MAXPATH]; // Last selected data file to save
char pb_password[PASSLEN]; // Encryption password
int pb_dpi; // Dot raster, dots per inch
int pb_dotpercent; // Dot size, percent of dpi
int pb_compression; // 0: none, 1: fast, 2: maximal
int pb_redundancy; // Redundancy (NGROUPMIN..NGROUPMAX)
int pb_printheader; // Print header and footer
int pb_printborder; // Border around bitmap
int pb_autosave; // Autosave completed files
int pb_bestquality; // Determine best quality
int pb_encryption; // Encrypt data before printing
int pb_opentext; // Enter passwords in open text
int pb_marginunits; // 0:undef, 1:inches, 2:millimeters
int pb_marginleft; // Left printer page margin
int pb_marginright; // Right printer page margin
int pb_margintop; // Top printer page margin
int pb_marginbottom; // Bottom printer page margin



inline bool isSwitchValid(int value)
{
return ( value < 0 || value > 1 );
@@ -137,33 +166,33 @@ int main(int argc, char ** argv) {
try {
cxxopts::Options options = arguments(argc, argv);
// set arguments to extern (global) variables
dpi = options["dpi"].as<int>();
dotpercent = options["dotsize"].as<int>();
redundancy = options["redundancy"].as<int>();
printheader = ( ! options["no-header"].as<int>() );
printborder = options["border"].as<int>();
pb_dpi = options["dpi"].as<int>();
pb_dotpercent = options["dotsize"].as<int>();
pb_redundancy = options["redundancy"].as<int>();
pb_printheader = ( ! options["no-header"].as<int>() );
pb_printborder = options["border"].as<int>();
// decode = !encode
bool isEncode = options["mode"].as<string>().compare("encode") == 0;

// externs (also have matching values in printdata and/or procdata)
std::string infile = options["input"].as<string>();
std::string outfile = options["output"].as<string>();
strcpy (::pb_infile, infile.c_str());
strcpy (::pb_outbmp, outfile.c_str());

if( isEncode ) {
// begin the process to write the bitmap,
// if second arg is not NULL, writes a bmp to outfile
t_printdata printdata = Printfile( infile.c_str(), outfile.c_str() );
while (printdata.step != 0) {
Nextdataprintingstep (&printdata);
}
}
else {
if (Decodebitmap (infile.c_str()) == 0) {
while (procdata.step != 0) {
Nextdataprocessingstep (&procdata);
}
if (isEncode) {
// begin the process to write the bitmap
while (pb_printdata.step != 0) {
Nextdataprintingstep (&pb_printdata);
}
}
//else {
// if (Decodebitmap (infile.c_str()) == 0) {
// while (procdata.step != 0) {
// Nextdataprocessingstep (&procdata);
// }
// }
//}
}
catch (const cxxopts::OptionException& e) {
cerr << "error parsing options: " << e.what() << endl;

+ 31
- 33
src/paperbak.h View File

@@ -52,7 +52,7 @@
#define PASSLEN 33 // Maximal length of password, incl. 0

typedef unsigned char uchar;
typedef uint16_t ushort;
typedef uint16_t ushort;
typedef unsigned int uint;


@@ -201,15 +201,15 @@ typedef struct t_printdata { // Print control structure
} t_printdata;


int resx,resy; // Printer resolution, dpi (may be 0!)
t_printdata printdata; // Print control structure
extern int pb_resx, pb_resy; // Printer resolution, dpi (may be 0!)
extern t_printdata pb_printdata; // Print control structure

void Initializeprintsettings(void);
void Closeprintsettings(void);
void Setuppage(void);
void Stopprinting(t_printdata *print);
void Nextdataprintingstep(t_printdata *print);
void Printfile(char *path,char *bmp);
void Printfile(const char *path, const char *bmp);


////////////////////////////////////////////////////////////////////////////////
@@ -258,8 +258,8 @@ typedef struct t_procdata { // Descriptor of processed data
int nrestored; // Page statistics: restored bytes
} t_procdata;

int orientation; // Orientation of bitmap (-1: unknown)
t_procdata procdata; // Descriptor of processed data
extern int pb_orientation; // Orientation of bitmap (-1: unknown)
extern t_procdata pb_procdata; // Descriptor of processed data

void Nextdataprocessingstep(t_procdata *pdata);
void Freeprocdata(t_procdata *pdata);
@@ -307,7 +307,7 @@ typedef struct t_fproc { // Descriptor of processed file
int rempages[8]; // 1-based list of remaining pages
} t_fproc;

t_fproc fproc[NFILE]; // Processed files
extern t_fproc pb_fproc[NFILE]; // Processed files

void Closefproc(int slot);
int Startnextpage(t_superblock *superblock);
@@ -325,30 +325,30 @@ int Decodebitmap(char *path);
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// USER INTERFACE ////////////////////////////////

char infile[MAXPATH]; // Last selected file to read
char outbmp[MAXPATH]; // Last selected bitmap to save
char inbmp[MAXPATH]; // Last selected bitmap to read
char outfile[MAXPATH]; // Last selected data file to save
char password[PASSLEN]; // Encryption password
int dpi; // Dot raster, dots per inch
int dotpercent; // Dot size, percent of dpi
int compression; // 0: none, 1: fast, 2: maximal
int redundancy; // Redundancy (NGROUPMIN..NGROUPMAX)
int printheader; // Print header and footer
int printborder; // Border around bitmap
int autosave; // Autosave completed files
int bestquality; // Determine best quality
int encryption; // Encrypt data before printing
int opentext; // Enter passwords in open text
int marginunits; // 0:undef, 1:inches, 2:millimeters
int marginleft; // Left printer page margin
int marginright; // Right printer page margin
int margintop; // Top printer page margin
int marginbottom; // Bottom printer page margin
extern char pb_infile[MAXPATH]; // Last selected file to read
extern char pb_outbmp[MAXPATH]; // Last selected bitmap to save
extern char pb_inbmp[MAXPATH]; // Last selected bitmap to read
extern char pb_outfile[MAXPATH]; // Last selected data file to save
extern char pb_password[PASSLEN]; // Encryption password
extern int pb_dpi; // Dot raster, dots per inch
extern int pb_dotpercent; // Dot size, percent of dpi
extern int pb_compression; // 0: none, 1: fast, 2: maximal
extern int pb_redundancy; // Redundancy (NGROUPMIN..NGROUPMAX)
extern int pb_printheader; // Print header and footer
extern int pb_printborder; // Border around bitmap
extern int pb_autosave; // Autosave completed files
extern int pb_bestquality; // Determine best quality
extern int pb_encryption; // Encrypt data before printing
extern int pb_opentext; // Enter passwords in open text
extern int pb_marginunits; // 0:undef, 1:inches, 2:millimeters
extern int pb_marginleft; // Left printer page margin
extern int pb_marginright; // Right printer page margin
extern int pb_margintop; // Top printer page margin
extern int pb_marginbottom; // Bottom printer page margin
void Options(void);
int Confirmpassword();
int Getpassword(void);
@@ -506,7 +506,5 @@ inline int Filetimetotext(FILETIME *fttime,char *s,int n) {
return l;
};


#endif



Loading…
Cancel
Save