/
barcode.h
104 lines (88 loc) · 3.29 KB
/
barcode.h
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
/*
* barcode.h -- definitions for libbarcode
*
* Copyright (c) 1999 Alessandro Rubini (rubini@gnu.org)
* Copyright (c) 1999 Prosa Srl. (prosa@prosa.it)
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _BARCODE_H_
#define _BARCODE_H_
#include <stdio.h>
#define BARCODE_VERSION "0.95"
#define BARCODE_VERSION_INT 9500
/*
* The object
*/
struct Barcode_Item {
int flags; /* type of encoding and decoding */
char *ascii; /* malloced */
char *partial; /* malloced too */
char *textinfo; /* information about text positioning */
char *encoding; /* code name, filled by encoding engine */
int width, height; /* output units */
int xoff, yoff; /* output units */
int margin; /* output units */
double scalef; /* requested scaling for barcode */
int error; /* an errno-like value, in case of failure */
};
/*
* The flags field
*/
#define BARCODE_DEFAULT_FLAGS 0x00000000
#define BARCODE_ENCODING_MASK 0x000000ff /* 256 possibilites... */
#define BARCODE_NO_ASCII 0x00000100 /* avoid text in output */
#define BARCODE_NO_CHECKSUM 0x00000200 /* avoid checksum in output */
#define BARCODE_OUTPUT_MASK 0x000ff000 /* 256 output types */
#define BARCODE_OUT_EPS 0x00001000
#define BARCODE_OUT_PS 0x00002000
#define BARCODE_OUT_NOHEADERS 0x00100000 /* no header nor footer */
enum {
BARCODE_ANY = 0, /* choose best-fit */
BARCODE_EAN,
BARCODE_UPC, /* upc == 12-digit ean */
BARCODE_ISBN, /* isbn numbers (still EAN13) */
BARCODE_39, /* code 39 */
BARCODE_128, /* code 128 (a,b,c: autoselection) */
BARCODE_128C, /* code 128 (compact form for digits) */
BARCODE_128B, /* code 128, full printable ascii */
BARCODE_I25 /* interleaved 2 of 5 (only digits) */
};
#define BARCODE_DEFAULT_MARGIN 10
/*
* Create and destroy barcode structures
*/
extern struct Barcode_Item *Barcode_Create(char *text);
extern int Barcode_Delete(struct Barcode_Item *bc);
/*
* Encode and print
*/
extern int Barcode_Encode(struct Barcode_Item *bc, int flags);
extern int Barcode_Print(struct Barcode_Item *bc, FILE *f, int flags);
/*
* Choose the position
*/
extern int Barcode_Position(struct Barcode_Item *bc, int wid, int hei,
int xoff, int yoff, double scalef);
/*
* Do it all in one step
*/
extern int Barcode_Encode_and_Print(char *text, FILE *f, int wid, int hei,
int xoff, int yoff, int flags);
/*
* Return current version (integer and string)
*/
extern int Barcode_Version(char *versionname);
#endif /* _BARCODE_H_ */