qrencode  4.1.1
About: libqrencode is a fast and compact library and command-line utility for encoding data in a QR Code symbol.
  Fossies Dox: qrencode-4.1.1.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

qrenc.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
#include "qrencode.h"
Include dependency graph for qrenc.c:

Go to the source code of this file.

Macros

#define INCHES_PER_METER   (100.0/2.54)
 qrencode - QR Code encoder More...
 
#define MAX_DATA_SIZE   (7090 * 2) /* timed by the safty factor 2 */
 

Enumerations

enum  imageType {
  PNG_TYPE , PNG32_TYPE , EPS_TYPE , SVG_TYPE ,
  XPM_TYPE , ANSI_TYPE , ANSI256_TYPE , ASCII_TYPE ,
  ASCIIi_TYPE , UTF8_TYPE , ANSIUTF8_TYPE , ANSI256UTF8_TYPE ,
  UTF8i_TYPE , ANSIUTF8i_TYPE
}
 

Functions

static void usage (int help, int longopt, int status)
 
static int color_set (unsigned char color[4], const char *value)
 
static unsigned char * readFile (FILE *fp, int *length)
 
static FILE * openFile (const char *outfile)
 
static int writePNG (const QRcode *qrcode, const char *outfile, enum imageType type)
 
static int writeEPS (const QRcode *qrcode, const char *outfile)
 
static void writeSVG_drawModules (FILE *fp, int x, int y, int width, const char *col, float opacity)
 
static int writeSVG (const QRcode *qrcode, const char *outfile)
 
static int writeXPM (const QRcode *qrcode, const char *outfile)
 
static void writeANSI_margin (FILE *fp, int realwidth, char *buffer, const char *white, int white_s)
 
static int writeANSI (const QRcode *qrcode, const char *outfile)
 
static void writeUTF8_margin (FILE *fp, int realwidth, const char *white, const char *reset, const char *full)
 
static int writeUTF8 (const QRcode *qrcode, const char *outfile, int use_ansi, int invert)
 
static void writeASCII_margin (FILE *fp, int realwidth, char *buffer, int invert)
 
static int writeASCII (const QRcode *qrcode, const char *outfile, int invert)
 
static QRcodeencode (const unsigned char *intext, int length)
 
static void qrencode (const unsigned char *intext, int length, const char *outfile)
 
static QRcode_ListencodeStructured (const unsigned char *intext, int length)
 
static void qrencodeStructured (const unsigned char *intext, int length, const char *outfile)
 
int main (int argc, char **argv)
 

Variables

static int casesensitive = 1
 
static int eightbit = 0
 
static int version = 0
 
static int size = 3
 
static int margin = -1
 
static int dpi = 72
 
static int structured = 0
 
static int rle = 0
 
static int svg_path = 0
 
static int micro = 0
 
static int inline_svg = 0
 
static int strict_versioning = 0
 
static QRecLevel level = QR_ECLEVEL_L
 
static QRencodeMode hint = QR_MODE_8
 
static unsigned char fg_color [4] = {0, 0, 0, 255}
 
static unsigned char bg_color [4] = {255, 255, 255, 255}
 
static int verbose = 0
 
static enum imageType image_type = PNG_TYPE
 
static const struct option options []
 
static char * optstring = "ho:r:l:s:v:m:d:t:Skci8MV"
 
static unsigned char data_buffer [(7090 *2)]
 

Macro Definition Documentation

◆ INCHES_PER_METER

#define INCHES_PER_METER   (100.0/2.54)

qrencode - QR Code encoder

QR Code encoding tool Copyright (C) 2006-2017 Kentaro Fukuchi kenta.nosp@m.ro@f.nosp@m.ukuch.nosp@m.i.or.nosp@m.g

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or any later version.

This library 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Definition at line 36 of file qrenc.c.

◆ MAX_DATA_SIZE

#define MAX_DATA_SIZE   (7090 * 2) /* timed by the safty factor 2 */

Definition at line 240 of file qrenc.c.

Enumeration Type Documentation

◆ imageType

enum imageType
Enumerator
PNG_TYPE 
PNG32_TYPE 
EPS_TYPE 
SVG_TYPE 
XPM_TYPE 
ANSI_TYPE 
ANSI256_TYPE 
ASCII_TYPE 
ASCIIi_TYPE 
UTF8_TYPE 
ANSIUTF8_TYPE 
ANSI256UTF8_TYPE 
UTF8i_TYPE 
ANSIUTF8i_TYPE 

Definition at line 57 of file qrenc.c.

Function Documentation

◆ color_set()

static int color_set ( unsigned char  color[4],
const char *  value 
)
static

Definition at line 212 of file qrenc.c.

Referenced by main().

◆ encode()

static QRcode * encode ( const unsigned char *  intext,
int  length 
)
static

◆ encodeStructured()

static QRcode_List * encodeStructured ( const unsigned char *  intext,
int  length 
)
static

◆ main()

◆ openFile()

static FILE * openFile ( const char *  outfile)
static

Definition at line 262 of file qrenc.c.

Referenced by writeANSI(), writeASCII(), writeEPS(), writeSVG(), writeUTF8(), and writeXPM().

◆ qrencode()

static void qrencode ( const unsigned char *  intext,
int  length,
const char *  outfile 
)
static

◆ qrencodeStructured()

static void qrencodeStructured ( const unsigned char *  intext,
int  length,
const char *  outfile 
)
static

◆ readFile()

static unsigned char * readFile ( FILE *  fp,
int *  length 
)
static

Definition at line 242 of file qrenc.c.

References data_buffer, and MAX_DATA_SIZE.

Referenced by main().

◆ usage()

static void usage ( int  help,
int  longopt,
int  status 
)
static

Definition at line 105 of file qrenc.c.

References QRcode_APIVersionString().

Referenced by main().

◆ writeANSI()

static int writeANSI ( const QRcode qrcode,
const char *  outfile 
)
static

Definition at line 749 of file qrenc.c.

References ANSI256_TYPE, QRcode::data, image_type, margin, openFile(), size, QRcode::width, and writeANSI_margin().

Referenced by qrencode(), and qrencodeStructured().

◆ writeANSI_margin()

static void writeANSI_margin ( FILE *  fp,
int  realwidth,
char *  buffer,
const char *  white,
int  white_s 
)
static

Definition at line 736 of file qrenc.c.

References margin.

Referenced by writeANSI().

◆ writeASCII()

static int writeASCII ( const QRcode qrcode,
const char *  outfile,
int  invert 
)
static

Definition at line 946 of file qrenc.c.

References QRcode::data, margin, openFile(), size, QRcode::width, and writeASCII_margin().

Referenced by qrencode(), and qrencodeStructured().

◆ writeASCII_margin()

static void writeASCII_margin ( FILE *  fp,
int  realwidth,
char *  buffer,
int  invert 
)
static

Definition at line 932 of file qrenc.c.

References margin.

Referenced by writeASCII().

◆ writeEPS()

static int writeEPS ( const QRcode qrcode,
const char *  outfile 
)
static

Definition at line 467 of file qrenc.c.

References bg_color, QRcode::data, fg_color, margin, openFile(), size, and QRcode::width.

Referenced by qrencode(), and qrencodeStructured().

◆ writePNG()

static int writePNG ( const QRcode qrcode,
const char *  outfile,
enum imageType  type 
)
static

Definition at line 292 of file qrenc.c.

References bg_color, QRcode::data, dpi, fg_color, INCHES_PER_METER, margin, PNG32_TYPE, PNG_TYPE, size, and QRcode::width.

Referenced by qrencode(), and qrencodeStructured().

◆ writeSVG()

static int writeSVG ( const QRcode qrcode,
const char *  outfile 
)
static

◆ writeSVG_drawModules()

static void writeSVG_drawModules ( FILE *  fp,
int  x,
int  y,
int  width,
const char *  col,
float  opacity 
)
static

Definition at line 523 of file qrenc.c.

References fg_color, and svg_path.

Referenced by writeSVG().

◆ writeUTF8()

static int writeUTF8 ( const QRcode qrcode,
const char *  outfile,
int  use_ansi,
int  invert 
)
static

Definition at line 847 of file qrenc.c.

References QRcode::data, margin, openFile(), QRcode::width, and writeUTF8_margin().

Referenced by qrencode(), and qrencodeStructured().

◆ writeUTF8_margin()

static void writeUTF8_margin ( FILE *  fp,
int  realwidth,
const char *  white,
const char *  reset,
const char *  full 
)
static

Definition at line 833 of file qrenc.c.

References margin.

Referenced by writeUTF8().

◆ writeXPM()

static int writeXPM ( const QRcode qrcode,
const char *  outfile 
)
static

Definition at line 656 of file qrenc.c.

References bg_color, QRcode::data, fg_color, margin, openFile(), size, and QRcode::width.

Referenced by qrencode(), and qrencodeStructured().

Variable Documentation

◆ bg_color

unsigned char bg_color[4] = {255, 255, 255, 255}
static

Definition at line 53 of file qrenc.c.

Referenced by main(), writeEPS(), writePNG(), writeSVG(), and writeXPM().

◆ casesensitive

◆ data_buffer

unsigned char data_buffer[(7090 *2)]
static

Definition at line 241 of file qrenc.c.

Referenced by readFile().

◆ dpi

int dpi = 72
static

Definition at line 43 of file qrenc.c.

Referenced by main(), writePNG(), and writeSVG().

◆ eightbit

int eightbit = 0
static

Definition at line 39 of file qrenc.c.

Referenced by encode(), encodeStructured(), main(), and QRcode_encodeDataStructuredReal().

◆ fg_color

unsigned char fg_color[4] = {0, 0, 0, 255}
static

Definition at line 52 of file qrenc.c.

Referenced by main(), writeEPS(), writePNG(), writeSVG(), writeSVG_drawModules(), and writeXPM().

◆ hint

◆ image_type

enum imageType image_type = PNG_TYPE
static

Definition at line 74 of file qrenc.c.

Referenced by main(), qrencode(), qrencodeStructured(), and writeANSI().

◆ inline_svg

int inline_svg = 0
static

Definition at line 48 of file qrenc.c.

Referenced by writeSVG().

◆ level

◆ margin

◆ micro

int micro = 0
static

Definition at line 47 of file qrenc.c.

Referenced by encode(), and main().

◆ options

const struct option options[]
static
Initial value:
= {
{"help" , no_argument , NULL, 'h'},
{"output" , required_argument, NULL, 'o'},
{"read-from" , required_argument, NULL, 'r'},
{"level" , required_argument, NULL, 'l'},
{"size" , required_argument, NULL, 's'},
{"symversion" , required_argument, NULL, 'v'},
{"margin" , required_argument, NULL, 'm'},
{"dpi" , required_argument, NULL, 'd'},
{"type" , required_argument, NULL, 't'},
{"structured" , no_argument , NULL, 'S'},
{"kanji" , no_argument , NULL, 'k'},
{"casesensitive" , no_argument , NULL, 'c'},
{"ignorecase" , no_argument , NULL, 'i'},
{"8bit" , no_argument , NULL, '8'},
{"micro" , no_argument , NULL, 'M'},
{"rle" , no_argument , &rle, 1},
{"svg-path" , no_argument , &svg_path, 1},
{"inline" , no_argument , &inline_svg, 1},
{"strict-version", no_argument , &strict_versioning, 1},
{"foreground" , required_argument, NULL, 'f'},
{"background" , required_argument, NULL, 'b'},
{"version" , no_argument , NULL, 'V'},
{"verbose" , no_argument , &verbose, 1},
{NULL, 0, NULL, 0}
}
static int verbose
Definition: qrenc.c:55
static int inline_svg
Definition: qrenc.c:48
static int svg_path
Definition: qrenc.c:46
static int strict_versioning
Definition: qrenc.c:49
static int rle
Definition: qrenc.c:45

Definition at line 76 of file qrenc.c.

Referenced by main().

◆ optstring

char* optstring = "ho:r:l:s:v:m:d:t:Skci8MV"
static

Definition at line 103 of file qrenc.c.

Referenced by main().

◆ rle

int rle = 0
static

Definition at line 45 of file qrenc.c.

Referenced by writeSVG().

◆ size

◆ strict_versioning

int strict_versioning = 0
static

Definition at line 49 of file qrenc.c.

Referenced by qrencode().

◆ structured

int structured = 0
static

Definition at line 44 of file qrenc.c.

Referenced by main().

◆ svg_path

int svg_path = 0
static

Definition at line 46 of file qrenc.c.

Referenced by writeSVG(), and writeSVG_drawModules().

◆ verbose

int verbose = 0
static

Definition at line 55 of file qrenc.c.

Referenced by qrencode(), and qrencodeStructured().

◆ version