| defs.h | | defs.h | |
| /* | | /* | |
|
| Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Robert Lipe, robertli
pe@usa.net | | Copyright (C) 2002-2014 Robert Lipe, robertlipe+source@gpsbabel.org | |
| | | | |
| This program is free software; you can redistribute it and/or modify | | 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 | | it under the terms of the GNU General Public License as published by | |
| the Free Software Foundation; either version 2 of the License, or | | the Free Software Foundation; either version 2 of the License, or | |
| (at your option) any later version. | | (at your option) any later version. | |
| | | | |
| This program is distributed in the hope that it will be useful, | | This program is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| GNU General Public License for more details. | | GNU General Public License for more details. | |
| | | | |
| You should have received a copy of the GNU General Public License | | You should have received a copy of the GNU General Public License | |
| along with this program; if not, write to the Free Software | | along with this program; if not, write to the Free Software | |
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA | | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA | |
| | | | |
| */ | | */ | |
| #ifndef gpsbabel_defs_h_included | | #ifndef gpsbabel_defs_h_included | |
| #define gpsbabel_defs_h_included | | #define gpsbabel_defs_h_included | |
|
| #include <time.h> | | | |
| #include <stdlib.h> | | #include <stdint.h> | |
| #include <math.h> | | | |
| #include <stdio.h> | | | |
| #include <string.h> | | | |
| #include <stdarg.h> | | | |
| #include <stddef.h> | | | |
| #if HAVE_CONFIG_H | | #if HAVE_CONFIG_H | |
| #include "config.h" | | #include "config.h" | |
| #endif | | #endif | |
| #include "queue.h" | | #include "queue.h" | |
|
| #include "gbtypes.h" | | | |
| #if HAVE_LIBZ | | #if HAVE_LIBZ | |
| #include <zlib.h> | | #include <zlib.h> | |
| #elif !ZLIB_INHIBITED | | #elif !ZLIB_INHIBITED | |
| #include "zlib/zlib.h" | | #include "zlib/zlib.h" | |
| #endif | | #endif | |
| #include "gbfile.h" | | #include "gbfile.h" | |
| #include "cet.h" | | #include "cet.h" | |
| #include "cet_util.h" | | #include "cet_util.h" | |
| #include "inifile.h" | | #include "inifile.h" | |
| #include "session.h" | | #include "session.h" | |
| | | | |
|
| // Turn on Unicode in expat? | | #include <QtCore/QString> | |
| #ifdef _UNICODE | | #include <QtCore/QDebug> | |
| # define XML_UNICODE | | #include <QtCore/QTextStream> | |
| #endif | | | |
| | | # include "src/core/datetime.h" | |
| | | | |
| | | #define CSTR(qstr) (qstr.toUtf8().constData()) | |
| | | | |
| /* | | /* | |
| * Amazingly, this constant is not specified in the standard... | | * Amazingly, this constant is not specified in the standard... | |
| */ | | */ | |
| #ifndef M_PI | | #ifndef M_PI | |
| # define M_PI 3.14159265358979323846 | | # define M_PI 3.14159265358979323846 | |
| #endif | | #endif | |
| | | | |
| #ifndef FALSE | | #ifndef FALSE | |
|
| # define FALSE 0 | | # define FALSE false | |
| #endif | | #endif | |
| | | | |
| #ifndef TRUE | | #ifndef TRUE | |
|
| # define TRUE !FALSE | | # define TRUE true | |
| #endif | | #endif | |
| | | | |
| #define FEET_TO_METERS(feetsies) ((feetsies) * 0.3048) | | #define FEET_TO_METERS(feetsies) ((feetsies) * 0.3048) | |
| #define METERS_TO_FEET(meetsies) ((meetsies) * 3.2808399) | | #define METERS_TO_FEET(meetsies) ((meetsies) * 3.2808399) | |
| | | | |
| #define NMILES_TO_METERS(a) ((a) * 1852.0) /* nautical miles */ | | #define NMILES_TO_METERS(a) ((a) * 1852.0) /* nautical miles */ | |
| #define METERS_TO_NMILES(a) ((a) / 1852.0) | | #define METERS_TO_NMILES(a) ((a) / 1852.0) | |
| | | | |
| #define MILES_TO_METERS(a) ((a) * 1609.344) | | #define MILES_TO_METERS(a) ((a) * 1609.344) | |
| #define METERS_TO_MILES(a) ((a) / 1609.344) | | #define METERS_TO_MILES(a) ((a) / 1609.344) | |
| | | | |
| skipping to change at line 156 | | skipping to change at line 154 | |
| # else | | # else | |
| # define va_copy(DEST,SRC) ((DEST) = (SRC)) | | # define va_copy(DEST,SRC) ((DEST) = (SRC)) | |
| # endif | | # endif | |
| # endif | | # endif | |
| #endif | | #endif | |
| | | | |
| /* | | /* | |
| * Common definitions. There should be no protocol or file-specific | | * Common definitions. There should be no protocol or file-specific | |
| * data in this file. | | * data in this file. | |
| */ | | */ | |
|
| | | | |
| #define BASE_STRUCT(memberp, struct_type, member_name) \ | | #define BASE_STRUCT(memberp, struct_type, member_name) \ | |
| ((struct_type *)((char *)(memberp) - offsetof(struct_type, member_name))
) | | ((struct_type *)((char *)(memberp) - offsetof(struct_type, member_name))
) | |
| | | | |
| typedef enum { | | typedef enum { | |
| fix_unknown=-1, | | fix_unknown=-1, | |
| fix_none=0, | | fix_none=0, | |
| fix_2d=1, | | fix_2d=1, | |
| fix_3d, | | fix_3d, | |
| fix_dgps, | | fix_dgps, | |
| fix_pps | | fix_pps | |
| | | | |
| skipping to change at line 218 | | skipping to change at line 217 | |
| cet_cs_vec_t* charset; | | cet_cs_vec_t* charset; | |
| char* charset_name; | | char* charset_name; | |
| inifile_t* inifile; | | inifile_t* inifile; | |
| } global_options; | | } global_options; | |
| | | | |
| extern global_options global_opts; | | extern global_options global_opts; | |
| extern const char gpsbabel_version[]; | | extern const char gpsbabel_version[]; | |
| extern time_t gpsbabel_now; /* gpsbabel startup-time; initialized in mai
n.c with time() */ | | extern time_t gpsbabel_now; /* gpsbabel startup-time; initialized in mai
n.c with time() */ | |
| extern time_t gpsbabel_time; /* gpsbabel startup-time; initialized in mai
n.c with current_time(), ! ZERO within testo ! */ | | extern time_t gpsbabel_time; /* gpsbabel startup-time; initialized in mai
n.c with current_time(), ! ZERO within testo ! */ | |
| extern int geocaches_present; | | extern int geocaches_present; | |
|
| | | extern QTextStream cerr; | |
| | | | |
| #define MILLI_TO_MICRO(t) (t * 1000) /* Milliseconds to Microseconds */ | | #define MILLI_TO_MICRO(t) (t * 1000) /* Milliseconds to Microseconds */ | |
| #define MICRO_TO_MILLI(t) (t / 1000) /* Microseconds to Milliseconds*/ | | #define MICRO_TO_MILLI(t) (t / 1000) /* Microseconds to Milliseconds*/ | |
| #define CENTI_TO_MICRO(t) (t * 10000) /* Centiseconds to Microseconds */ | | #define CENTI_TO_MICRO(t) (t * 10000) /* Centiseconds to Microseconds */ | |
| #define MICRO_TO_CENTI(t) (t / 10000) /* Centiseconds to Microseconds */ | | #define MICRO_TO_CENTI(t) (t / 10000) /* Centiseconds to Microseconds */ | |
| | | | |
| /* Short or Long XML Times */ | | /* Short or Long XML Times */ | |
| #define XML_SHORT_TIME 1 | | #define XML_SHORT_TIME 1 | |
| #define XML_LONG_TIME 2 | | #define XML_LONG_TIME 2 | |
| | | | |
| | | | |
| skipping to change at line 261 | | skipping to change at line 261 | |
| typedef enum { | | typedef enum { | |
| gc_unknown = 0, | | gc_unknown = 0, | |
| gc_micro, | | gc_micro, | |
| gc_other, | | gc_other, | |
| gc_regular, | | gc_regular, | |
| gc_large, | | gc_large, | |
| gc_virtual, | | gc_virtual, | |
| gc_small | | gc_small | |
| } geocache_container; | | } geocache_container; | |
| | | | |
|
| typedef struct { | | class utf_string | |
| int is_html; | | { | |
| char* utfstring; | | public: | |
| } utf_string; | | utf_string() : | |
| | | is_html(false) | |
| typedef struct { | | {}; | |
| | | bool is_html; | |
| | | QString utfstring; | |
| | | }; | |
| | | | |
| | | class geocache_data | |
| | | { | |
| | | public: | |
| | | geocache_data() : | |
| | | id(0), | |
| | | type(gt_unknown), | |
| | | container(gc_unknown), | |
| | | diff(0), | |
| | | terr(0), | |
| | | is_archived(status_unknown), | |
| | | is_available(status_unknown), | |
| | | is_memberonly(status_unknown), | |
| | | has_customcoords(status_unknown), | |
| | | placer_id(0), | |
| | | favorite_points(0) | |
| | | {} | |
| int id; /* The decimal cache number */ | | int id; /* The decimal cache number */ | |
| geocache_type type:5; | | geocache_type type:5; | |
| geocache_container container:4; | | geocache_container container:4; | |
| unsigned int diff:6; /* (multiplied by ten internally) */ | | unsigned int diff:6; /* (multiplied by ten internally) */ | |
| unsigned int terr:6; /* (likewise) */ | | unsigned int terr:6; /* (likewise) */ | |
| status_type is_archived:2; | | status_type is_archived:2; | |
| status_type is_available:2; | | status_type is_available:2; | |
| status_type is_memberonly:2; | | status_type is_memberonly:2; | |
| status_type has_customcoords:2; | | status_type has_customcoords:2; | |
|
| time_t exported; | | gpsbabel::DateTime exported; | |
| time_t last_found; | | gpsbabel::DateTime last_found; | |
| char* placer; /* Placer name */ | | QString placer; /* Placer name */ | |
| int placer_id; /* Placer id */ | | int placer_id; /* Placer id */ | |
|
| char* hint; /* all these UTF8, XML entities removed, May be not HTML. */ | | QString hint; /* all these UTF8, XML entities removed, May be not HTML. *
/ | |
| utf_string desc_short; | | utf_string desc_short; | |
| utf_string desc_long; | | utf_string desc_long; | |
| int favorite_points; | | int favorite_points; | |
|
| char* personal_note; | | QString personal_note; | |
| } geocache_data ; | | }; | |
| | | | |
| typedef struct xml_tag { | | | |
| char* tagname; | | | |
| char* cdata; | | | |
| int cdatalen; | | | |
| char* parentcdata; | | | |
| int parentcdatalen; | | | |
| char** attributes; | | | |
| struct xml_tag* parent; | | | |
| struct xml_tag* sibling; | | | |
| struct xml_tag* child; | | | |
| } xml_tag ; | | | |
| | | | |
| typedef void (*fs_destroy)(void*); | | typedef void (*fs_destroy)(void*); | |
| typedef void (*fs_copy)(void**, void*); | | typedef void (*fs_copy)(void**, void*); | |
| typedef void (*fs_convert)(void*); | | typedef void (*fs_convert)(void*); | |
| | | | |
| typedef struct format_specific_data { | | typedef struct format_specific_data { | |
| long type; | | long type; | |
| struct format_specific_data* next; | | struct format_specific_data* next; | |
| | | | |
| fs_destroy destroy; | | fs_destroy destroy; | |
| fs_copy copy; | | fs_copy copy; | |
| fs_convert convert; | | fs_convert convert; | |
| } format_specific_data; | | } format_specific_data; | |
| | | | |
|
| typedef struct { | | class gb_color | |
| | | { | |
| | | public: | |
| | | gb_color() : | |
| | | bbggrr(-1), | |
| | | opacity(255) {} | |
| int bbggrr; // 32 bit color: Blue/Green/Red. < 0 == unknown. | | int bbggrr; // 32 bit color: Blue/Green/Red. < 0 == unknown. | |
| unsigned char opacity; // 0 == transparent. 255 == opaque. | | unsigned char opacity; // 0 == transparent. 255 == opaque. | |
|
| } gb_color; | | }; | |
| | | | |
| format_specific_data* fs_chain_copy(format_specific_data* source); | | format_specific_data* fs_chain_copy(format_specific_data* source); | |
| void fs_chain_destroy(format_specific_data* chain); | | void fs_chain_destroy(format_specific_data* chain); | |
| format_specific_data* fs_chain_find(format_specific_data* chain, long type)
; | | format_specific_data* fs_chain_find(format_specific_data* chain, long type)
; | |
| void fs_chain_add(format_specific_data** chain, format_specific_data* data)
; | | void fs_chain_add(format_specific_data** chain, format_specific_data* data)
; | |
| | | | |
|
| typedef struct fs_xml { | | | |
| format_specific_data fs; | | | |
| xml_tag* tag; | | | |
| } fs_xml; | | | |
| | | | |
| fs_xml* fs_xml_alloc(long type); | | | |
| | | | |
| #define FS_GPX 0x67707800L | | #define FS_GPX 0x67707800L | |
| #define FS_AN1W 0x616e3177L | | #define FS_AN1W 0x616e3177L | |
| #define FS_AN1L 0x616e316cL | | #define FS_AN1L 0x616e316cL | |
| #define FS_AN1V 0x616e3176L | | #define FS_AN1V 0x616e3176L | |
| #define FS_OZI 0x6f7a6900L | | #define FS_OZI 0x6f7a6900L | |
| #define FS_GMSD 0x474d5344L /* GMSD = Garmin specific data */ | | #define FS_GMSD 0x474d5344L /* GMSD = Garmin specific data */ | |
| #define FS_LOWRANCEUSR4 0x615f234cL | | #define FS_LOWRANCEUSR4 0x615f234cL | |
| | | | |
| /* | | /* | |
| * Structures and functions for multiple URLs per waypoint. | | * Structures and functions for multiple URLs per waypoint. | |
| */ | | */ | |
|
| typedef struct url_link { | | | |
| struct url_link* url_next; | | class UrlLink | |
| char* url; | | { | |
| char* url_link_text; | | public: | |
| } url_link; | | UrlLink() { } | |
| | | UrlLink(const QString url) : | |
| | | url_(url) | |
| | | { } | |
| | | UrlLink(const char* url) : | |
| | | url_(url) | |
| | | { } | |
| | | UrlLink(const QString url, const QString url_link_text) : | |
| | | url_(url), | |
| | | url_link_text_(url_link_text) | |
| | | { } | |
| | | UrlLink(const QString url, const QString url_link_text, const QString url | |
| | | _link_type) : | |
| | | url_(url), | |
| | | url_link_text_(url_link_text), | |
| | | url_link_type_(url_link_type) | |
| | | { } | |
| | | QString url_; | |
| | | QString url_link_text_; | |
| | | QString url_link_type_; | |
| | | }; | |
| | | | |
| /* | | /* | |
| * Misc bitfields inside struct waypoint; | | * Misc bitfields inside struct waypoint; | |
| */ | | */ | |
|
| typedef struct { | | class wp_flags | |
| unsigned int icon_descr_is_dynamic:1; | | { | |
| | | public: | |
| | | wp_flags() : | |
| | | shortname_is_synthetic(0), | |
| | | cet_converted(0), | |
| | | fmt_use(0), | |
| | | temperature(0), | |
| | | proximity(0), | |
| | | course(0), | |
| | | speed(0), | |
| | | geoidheight(0), | |
| | | depth(0), | |
| | | is_split(0), | |
| | | new_trkseg(0) {} | |
| unsigned int shortname_is_synthetic:1; | | unsigned int shortname_is_synthetic:1; | |
| unsigned int cet_converted:1; /* strings are converted to
UTF8; interesting only for input */ | | unsigned int cet_converted:1; /* strings are converted to
UTF8; interesting only for input */ | |
|
| unsigned int fmt_use:1; /* lightweight "extra data"
*/ | | unsigned int fmt_use:2; /* lightweight "extra data"
*/ | |
| /* "flagged fields" */ | | /* "flagged fields" */ | |
| unsigned int temperature:1; /* temperature field is set */ | | unsigned int temperature:1; /* temperature field is set */ | |
| unsigned int proximity:1; /* proximity field is set */ | | unsigned int proximity:1; /* proximity field is set */ | |
| unsigned int course:1; /* course field is set */ | | unsigned int course:1; /* course field is set */ | |
| unsigned int speed:1; /* speed field is set */ | | unsigned int speed:1; /* speed field is set */ | |
|
| | | unsigned int geoidheight:1; /* geoidheight field is set */ | |
| unsigned int depth:1; /* depth field is set */ | | unsigned int depth:1; /* depth field is set */ | |
| /* !ToDo! | | /* !ToDo! | |
| unsigned int altitude:1; /+ altitude field is set +/ | | unsigned int altitude:1; /+ altitude field is set +/ | |
| ... and others | | ... and others | |
| */ | | */ | |
| unsigned int is_split:1; /* the waypoint represents a split *
/ | | unsigned int is_split:1; /* the waypoint represents a split *
/ | |
| unsigned int new_trkseg:1; /* True if first in new trkseg. */ | | unsigned int new_trkseg:1; /* True if first in new trkseg. */ | |
| | | | |
|
| } wp_flags; | | }; | |
| | | | |
| // These are dicey as they're collected on read. Subsequent filters may cha
nge | | // These are dicey as they're collected on read. Subsequent filters may cha
nge | |
| // things, though it's u nlikely to matter in practical terms. Don't use t
hese | | // things, though it's u nlikely to matter in practical terms. Don't use t
hese | |
| // if a false positive would be deleterious. | | // if a false positive would be deleterious. | |
|
| typedef struct { | | # | |
| | | class global_trait | |
| | | { | |
| | | public: | |
| | | global_trait() : | |
| | | trait_geocaches(0), | |
| | | trait_heartrate(0), | |
| | | trait_cadence(0), | |
| | | trait_power(0), | |
| | | trait_depth(0), | |
| | | trait_temperature(0) {} | |
| unsigned int trait_geocaches:1; | | unsigned int trait_geocaches:1; | |
| unsigned int trait_heartrate:1; | | unsigned int trait_heartrate:1; | |
| unsigned int trait_cadence:1; | | unsigned int trait_cadence:1; | |
| unsigned int trait_power:1; | | unsigned int trait_power:1; | |
| unsigned int trait_depth:1; | | unsigned int trait_depth:1; | |
| unsigned int trait_temperature:1; | | unsigned int trait_temperature:1; | |
|
| } global_trait; | | }; | |
| | | | |
| const global_trait* get_traits(); | | const global_trait* get_traits(); | |
| | | | |
| #define WAYPT_SET(wpt,member,val) { wpt->member = (val); wpt->wpt_flags.mem
ber = 1; } | | #define WAYPT_SET(wpt,member,val) { wpt->member = (val); wpt->wpt_flags.mem
ber = 1; } | |
| #define WAYPT_GET(wpt,member,def) ((wpt->wpt_flags.member) ? (wpt->member)
: (def)) | | #define WAYPT_GET(wpt,member,def) ((wpt->wpt_flags.member) ? (wpt->member)
: (def)) | |
| #define WAYPT_UNSET(wpt,member) wpt->wpt_flags.member = 0 | | #define WAYPT_UNSET(wpt,member) wpt->wpt_flags.member = 0 | |
| #define WAYPT_HAS(wpt,member) (wpt->wpt_flags.member) | | #define WAYPT_HAS(wpt,member) (wpt->wpt_flags.member) | |
|
| | | | |
| | | #define CSTRc(qstr) (qstr.toLatin1().constData()) | |
| | | // Maybe the XmlGeneric string callback really shouldn't have a type | |
| | | // of its own; this was a crutch during the move from char* to QString. | |
| | | // It's "just" a search and replace to make it go away, but it might | |
| | | // be convenient to overload some day. | |
| | | typedef const QString& xg_string; | |
| | | | |
| /* | | /* | |
| * This is a waypoint, as stored in the GPSR. It tries to not | | * This is a waypoint, as stored in the GPSR. It tries to not | |
| * cater to any specific model or protocol. Anything that needs to | | * cater to any specific model or protocol. Anything that needs to | |
| * be truncated, edited, or otherwise trimmed should be done on the | | * be truncated, edited, or otherwise trimmed should be done on the | |
| * way to the target. | | * way to the target. | |
| */ | | */ | |
|
| | | class Waypoint | |
| | | { | |
| | | private: | |
| | | static geocache_data empty_gc_data; | |
| | | | |
|
| typedef struct { | | public: | |
| queue Q; /* Master waypoint q. Not for use | | queue Q; /* Master waypoint q. Not for use | |
| by modules. */ | | by modules. */ | |
| | | | |
| double latitude; /* Degrees */ | | double latitude; /* Degrees */ | |
| double longitude; /* Degrees */ | | double longitude; /* Degrees */ | |
| double altitude; /* Meters. */ | | double altitude; /* Meters. */ | |
|
| | | double geoidheight; /* Height (in meters) of geoid (mean sea level) abov
e WGS84 earth ellipsoid. */ | |
| | | | |
| /* | | /* | |
| * The "thickness" of a waypoint; adds an element of 3D. Can be | | * The "thickness" of a waypoint; adds an element of 3D. Can be | |
| * used to construct rudimentary polygons for, say, airspace | | * used to construct rudimentary polygons for, say, airspace | |
| * definitions. The units are meters. | | * definitions. The units are meters. | |
| */ | | */ | |
| double depth; | | double depth; | |
| | | | |
| /* | | /* | |
| * An alarm trigger value that can be considered to be a circle | | * An alarm trigger value that can be considered to be a circle | |
| | | | |
| skipping to change at line 421 | | skipping to change at line 484 | |
| * The units are meters. | | * The units are meters. | |
| */ | | */ | |
| double proximity; | | double proximity; | |
| | | | |
| /* shortname is a waypoint name as stored in receiver. It should | | /* shortname is a waypoint name as stored in receiver. It should | |
| * strive to be, well, short, and unique. Enforcing length and | | * strive to be, well, short, and unique. Enforcing length and | |
| * character restrictions is the job of the output. A typical | | * character restrictions is the job of the output. A typical | |
| * minimum length for shortname is 6 characters for NMEA units, | | * minimum length for shortname is 6 characters for NMEA units, | |
| * 8 for Magellan and 10 for Vista. These are only guidelines. | | * 8 for Magellan and 10 for Vista. These are only guidelines. | |
| */ | | */ | |
|
| char* shortname; | | QString shortname; | |
| /* | | /* | |
| * description is typically a human readable description of the | | * description is typically a human readable description of the | |
| * waypoint. It may be used as a comment field in some receivers. | | * waypoint. It may be used as a comment field in some receivers. | |
| * These are probably under 40 bytes, but that's only a guideline. | | * These are probably under 40 bytes, but that's only a guideline. | |
| */ | | */ | |
|
| char* description; | | QString description; | |
| /* | | /* | |
| * notes are relatively long - over 100 characters - prose associated | | * notes are relatively long - over 100 characters - prose associated | |
| * with the above. Unlike shortname and description, these are never | | * with the above. Unlike shortname and description, these are never | |
| * used to compute anything else and are strictly "passed through". | | * used to compute anything else and are strictly "passed through". | |
| * Few formats support this. | | * Few formats support this. | |
| */ | | */ | |
|
| char* notes; | | QString notes; | |
| | | | |
|
| /* This is a bit icky. Multiple waypoint support is an | | /* TODO: UrlLink should probably move to a "real" class of its own. | |
| * afterthought and I don't want to change our data structures. | | | |
| * So we have the first in the waypoint itself and subsequent | | | |
| * ones in a linked list. | | | |
| * We also use an implicit anonymous union here, so these three | | | |
| * members must match struct url_link... | | | |
| */ | | */ | |
|
| struct url_link* url_next; | | QList<UrlLink> url_link_list_; | |
| char* url; | | | |
| char* url_link_text; | | | |
| | | | |
| wp_flags wpt_flags; | | wp_flags wpt_flags; | |
|
| const char* icon_descr; | | QString icon_descr; | |
| time_t creation_time; /* standardized in UTC/GMT */ | | | |
| int microseconds; /* Optional millionths of a second. */ | | gpsbabel::DateTime creation_time; | |
| | | | |
| /* | | /* | |
| * route priority is for use by the simplify filter. If we have | | * route priority is for use by the simplify filter. If we have | |
| * some reason to believe that the route point is more important, | | * some reason to believe that the route point is more important, | |
| * we can give it a higher (numerically; 0 is the lowest) priority. | | * we can give it a higher (numerically; 0 is the lowest) priority. | |
| * This causes it to be removed last. | | * This causes it to be removed last. | |
| * This is currently used by the saroute input filter to give named | | * This is currently used by the saroute input filter to give named | |
| * waypoints (representing turns) a higher priority. | | * waypoints (representing turns) a higher priority. | |
| * This is also used by the google input filter because they were | | * This is also used by the google input filter because they were | |
| * nice enough to use exactly the same priority scheme. | | * nice enough to use exactly the same priority scheme. | |
| | | | |
| skipping to change at line 480 | | skipping to change at line 536 | |
| float course; /* Optional: degrees true */ | | float course; /* Optional: degrees true */ | |
| float speed; /* Optional: meters per second. */ | | float speed; /* Optional: meters per second. */ | |
| fix_type fix; /* Optional: 3d, 2d, etc. */ | | fix_type fix; /* Optional: 3d, 2d, etc. */ | |
| int sat; /* Optional: number of sats used for fix */ | | int sat; /* Optional: number of sats used for fix */ | |
| | | | |
| unsigned char heartrate; /* Beats/min. likely to get moved to fs. */ | | unsigned char heartrate; /* Beats/min. likely to get moved to fs. */ | |
| unsigned char cadence; /* revolutions per minute */ | | unsigned char cadence; /* revolutions per minute */ | |
| float power; /* watts, as measured by cyclists */ | | float power; /* watts, as measured by cyclists */ | |
| float temperature; /* Degrees celsius */ | | float temperature; /* Degrees celsius */ | |
| float odometer_distance; /* Meters? */ | | float odometer_distance; /* Meters? */ | |
|
| const geocache_data* gc_data; | | geocache_data* gc_data; | |
| format_specific_data* fs; | | format_specific_data* fs; | |
| session_t* session; /* pointer to a session struct */ | | session_t* session; /* pointer to a session struct */ | |
| void* extra_data; /* Extra data added by, say, a filter. */ | | void* extra_data; /* Extra data added by, say, a filter. */ | |
|
| } waypoint; | | | |
| | | | |
|
| typedef struct { | | private: | |
| | | Waypoint& operator=(const Waypoint& other); | |
| | | | |
| | | public: | |
| | | Waypoint(); | |
| | | ~Waypoint(); | |
| | | Waypoint(const Waypoint& other); | |
| | | | |
| | | bool HasUrlLink() const; | |
| | | const UrlLink& GetUrlLink() const; | |
| | | const QList<UrlLink> GetUrlLinks() const; | |
| | | void AddUrlLink(const UrlLink l); | |
| | | QString CreationTimeXML() const; | |
| | | gpsbabel::DateTime GetCreationTime() const; | |
| | | void SetCreationTime(gpsbabel::DateTime t); | |
| | | void SetCreationTime(time_t t); | |
| | | void SetCreationTime(time_t t, int ms); | |
| | | geocache_data* AllocGCData(); | |
| | | int EmptyGCData() const; | |
| | | }; | |
| | | | |
| | | class route_head | |
| | | { | |
| | | public: | |
| queue Q; /* Link onto parent list. */ | | queue Q; /* Link onto parent list. */ | |
| queue waypoint_list; /* List of child waypoints */ | | queue waypoint_list; /* List of child waypoints */ | |
|
| char* rte_name; | | QString rte_name; | |
| char* rte_desc; | | QString rte_desc; | |
| char* rte_url; | | QString rte_url; | |
| int rte_num; | | int rte_num; | |
| int rte_waypt_ct; /* # waypoints in waypoint list */ | | int rte_waypt_ct; /* # waypoints in waypoint list */ | |
| format_specific_data* fs; | | format_specific_data* fs; | |
| unsigned short cet_converted; /* strings are converted to UTF8; in
teresting only for input */ | | unsigned short cet_converted; /* strings are converted to UTF8; in
teresting only for input */ | |
| gb_color line_color; /* Optional line color for rendering */ | | gb_color line_color; /* Optional line color for rendering */ | |
| int line_width; /* in pixels (sigh). < 0 is unknown. */ | | int line_width; /* in pixels (sigh). < 0 is unknown. */ | |
| session_t* session; /* pointer to a session struct */ | | session_t* session; /* pointer to a session struct */ | |
|
| } route_head; | | | |
| | | public: | |
| | | route_head(); | |
| | | ~route_head(); | |
| | | }; | |
| | | | |
| /* | | /* | |
| * Structure of recomputed track/roue data. | | * Structure of recomputed track/roue data. | |
| */ | | */ | |
| typedef struct { | | typedef struct { | |
| double distance_meters; | | double distance_meters; | |
| double max_alt; /* unknown_alt => invalid */ | | double max_alt; /* unknown_alt => invalid */ | |
| double min_alt; /* -unknown_alt => invalid */ | | double min_alt; /* -unknown_alt => invalid */ | |
| double max_spd; /* Meters/sec */ | | double max_spd; /* Meters/sec */ | |
| double min_spd; /* Meters/sec */ | | double min_spd; /* Meters/sec */ | |
| | | | |
| skipping to change at line 542 | | skipping to change at line 624 | |
| volatile int request_terminate; | | volatile int request_terminate; | |
| } posn_status; | | } posn_status; | |
| | | | |
| extern posn_status tracking_status; | | extern posn_status tracking_status; | |
| | | | |
| typedef void (*ff_init)(char const*); | | typedef void (*ff_init)(char const*); | |
| typedef void (*ff_deinit)(void); | | typedef void (*ff_deinit)(void); | |
| typedef void (*ff_read)(void); | | typedef void (*ff_read)(void); | |
| typedef void (*ff_write)(void); | | typedef void (*ff_write)(void); | |
| typedef void (*ff_exit)(void); | | typedef void (*ff_exit)(void); | |
|
| typedef void (*ff_writeposn)(waypoint*); | | typedef void (*ff_writeposn)(Waypoint*); | |
| typedef waypoint* (*ff_readposn)(posn_status*); | | typedef Waypoint* (*ff_readposn)(posn_status*); | |
| | | | |
| #ifndef DEBUG_MEM | | #ifndef DEBUG_MEM | |
| char* get_option(const char* iarglist, const char* argname); | | char* get_option(const char* iarglist, const char* argname); | |
| #else | | #else | |
| #define DEBUG_PARAMS const char *file, const int line | | #define DEBUG_PARAMS const char *file, const int line | |
| char* GET_OPTION(const char* iarglist, const char* argname, DEBUG_PARAMS); | | char* GET_OPTION(const char* iarglist, const char* argname, DEBUG_PARAMS); | |
| #define get_option(iarglist, argname) GET_OPTION(iarglist, argname, __FILE_
_, __LINE__) | | #define get_option(iarglist, argname) GET_OPTION(iarglist, argname, __FILE_
_, __LINE__) | |
| #endif | | #endif | |
| | | | |
| typedef void (*filter_init)(char const*); | | typedef void (*filter_init)(char const*); | |
| typedef void (*filter_process)(void); | | typedef void (*filter_process)(void); | |
| typedef void (*filter_deinit)(void); | | typedef void (*filter_deinit)(void); | |
| typedef void (*filter_exit)(void); | | typedef void (*filter_exit)(void); | |
| | | | |
|
| typedef void (*waypt_cb)(const waypoint*); | | typedef void (*waypt_cb)(const Waypoint*); | |
| typedef void (*route_hdr)(const route_head*); | | typedef void (*route_hdr)(const route_head*); | |
| typedef void (*route_trl)(const route_head*); | | typedef void (*route_trl)(const route_head*); | |
|
| void waypt_add(waypoint*); | | void waypt_add(Waypoint*); | |
| waypoint* waypt_dupe(const waypoint*); | | Waypoint* waypt_dupe(const Waypoint*); | |
| waypoint* waypt_new(void); | | Waypoint* waypt_new(void); | |
| void waypt_del(waypoint*); | | void waypt_del(Waypoint*); | |
| void waypt_free(waypoint*); | | void waypt_free(Waypoint*); | |
| void waypt_disp_all(waypt_cb); | | void waypt_disp_all(waypt_cb); | |
| void waypt_disp_session(const session_t* se, waypt_cb cb); | | void waypt_disp_session(const session_t* se, waypt_cb cb); | |
| void waypt_init_bounds(bounds* bounds); | | void waypt_init_bounds(bounds* bounds); | |
| int waypt_bounds_valid(bounds* bounds); | | int waypt_bounds_valid(bounds* bounds); | |
|
| void waypt_add_to_bounds(bounds* bounds, const waypoint* waypointp); | | void waypt_add_to_bounds(bounds* bounds, const Waypoint* waypointp); | |
| void waypt_compute_bounds(bounds*); | | void waypt_compute_bounds(bounds*); | |
| double gcgeodist(const double lat1, const double lon1, | | double gcgeodist(const double lat1, const double lon1, | |
| const double lat2, const double lon2); | | const double lat2, const double lon2); | |
| void waypt_flush(queue*); | | void waypt_flush(queue*); | |
| void waypt_flush_all(void); | | void waypt_flush_all(void); | |
| unsigned int waypt_count(void); | | unsigned int waypt_count(void); | |
| void set_waypt_count(unsigned int nc); | | void set_waypt_count(unsigned int nc); | |
|
| void waypt_add_url(waypoint* wpt, char* link, char* url_link_text); | | void waypt_add_url(Waypoint* wpt, const QString& link, | |
| void free_gpx_extras(xml_tag* tag); | | const QString& url_link_text); | |
| | | void waypt_add_url(Waypoint* wpt, const QString& link, | |
| | | const QString& url_link_text, | |
| | | const QString& url_link_type); | |
| void xcsv_setup_internal_style(const char* style_buf); | | void xcsv_setup_internal_style(const char* style_buf); | |
| void xcsv_read_internal_style(const char* style_buf); | | void xcsv_read_internal_style(const char* style_buf); | |
|
| waypoint* find_waypt_by_name(const char* name); | | Waypoint* find_waypt_by_name(const QString& name); | |
| void waypt_backup(signed int* count, queue** head_bak); | | void waypt_backup(signed int* count, queue** head_bak); | |
| void waypt_restore(signed int count, queue* head_bak); | | void waypt_restore(signed int count, queue* head_bak); | |
| | | | |
|
| geocache_data* waypt_alloc_gc_data(waypoint* wpt); | | geocache_data* waypt_alloc_gc_data(Waypoint* wpt); | |
| int waypt_empty_gc_data(const waypoint* wpt); | | int waypt_empty_gc_data(const Waypoint* wpt); | |
| geocache_type gs_mktype(const char* t); | | geocache_type gs_mktype(const QString& t); | |
| geocache_container gs_mkcont(const char* t); | | geocache_container gs_mkcont(const QString& t); | |
| | | | |
| route_head* route_head_alloc(void); | | route_head* route_head_alloc(void); | |
|
| void route_add(waypoint*); | | void route_add(Waypoint*); | |
| void route_add_wpt(route_head* rte, waypoint* wpt); | | void route_add_wpt(route_head* rte, Waypoint* wpt); | |
| void route_del_wpt(route_head* rte, waypoint* wpt); | | void route_add_wpt_named(route_head* rte, Waypoint* wpt, const QString& nam | |
| void track_add_wpt(route_head* rte, waypoint* wpt); | | epart, int number_digits); | |
| void track_del_wpt(route_head* rte, waypoint* wpt); | | void route_del_wpt(route_head* rte, Waypoint* wpt); | |
| | | void track_add_wpt(route_head* rte, Waypoint* wpt); | |
| | | void track_add_wpt_named(route_head* rte, Waypoint* wpt, const QString& nam | |
| | | epart, int number_digits); | |
| | | void track_del_wpt(route_head* rte, Waypoint* wpt); | |
| void route_add_head(route_head* rte); | | void route_add_head(route_head* rte); | |
| void route_del_head(route_head* rte); | | void route_del_head(route_head* rte); | |
| void route_reverse(const route_head* rte_hd); | | void route_reverse(const route_head* rte_hd); | |
|
| waypoint* route_find_waypt_by_name(route_head* rh, const char* name); | | Waypoint* route_find_waypt_by_name(route_head* rh, const char* name); | |
| void track_add_head(route_head* rte); | | void track_add_head(route_head* rte); | |
| void track_del_head(route_head* rte); | | void track_del_head(route_head* rte); | |
| void track_insert_head(route_head* rte, route_head* predecessor); | | void track_insert_head(route_head* rte, route_head* predecessor); | |
| void route_disp(const route_head* rte, waypt_cb); | | void route_disp(const route_head* rte, waypt_cb); | |
| void route_disp_all(route_hdr, route_trl, waypt_cb); | | void route_disp_all(route_hdr, route_trl, waypt_cb); | |
| void track_disp_all(route_hdr, route_trl, waypt_cb); | | void track_disp_all(route_hdr, route_trl, waypt_cb); | |
| void route_disp_session(const session_t* se, route_hdr rh, route_trl rt, wa
ypt_cb wc); | | void route_disp_session(const session_t* se, route_hdr rh, route_trl rt, wa
ypt_cb wc); | |
| void track_disp_session(const session_t* se, route_hdr rh, route_trl rt, wa
ypt_cb wc); | | void track_disp_session(const session_t* se, route_hdr rh, route_trl rt, wa
ypt_cb wc); | |
| void route_flush(queue*); | | void route_flush(queue*); | |
| void route_flush_all(void); | | void route_flush_all(void); | |
| | | | |
| skipping to change at line 653 | | skipping to change at line 740 | |
| unsigned int mustupper:1; | | unsigned int mustupper:1; | |
| unsigned int whitespaceok:1; | | unsigned int whitespaceok:1; | |
| unsigned int repeating_whitespaceok:1; | | unsigned int repeating_whitespaceok:1; | |
| unsigned int must_uniq:1; | | unsigned int must_uniq:1; | |
| unsigned int is_utf8:1; | | unsigned int is_utf8:1; | |
| } mkshort_handle_imp; | | } mkshort_handle_imp; | |
| typedef mkshort_handle_imp* short_handle; | | typedef mkshort_handle_imp* short_handle; | |
| | | | |
| #ifndef DEBUG_MEM | | #ifndef DEBUG_MEM | |
| char* mkshort(short_handle, const char*); | | char* mkshort(short_handle, const char*); | |
|
| | | QString mkshort(short_handle, const QString&); | |
| short_handle mkshort_new_handle(void); | | short_handle mkshort_new_handle(void); | |
| #else | | #else | |
| char* MKSHORT(short_handle, const char*, DEBUG_PARAMS); | | char* MKSHORT(short_handle, const char*, DEBUG_PARAMS); | |
| short_handle MKSHORT_NEW_HANDLE(DEBUG_PARAMS); | | short_handle MKSHORT_NEW_HANDLE(DEBUG_PARAMS); | |
| #define mkshort( a, b) MKSHORT(a,b,__FILE__, __LINE__) | | #define mkshort( a, b) MKSHORT(a,b,__FILE__, __LINE__) | |
| #define mkshort_new_handle() MKSHORT_NEW_HANDLE(__FILE__,__LINE__) | | #define mkshort_new_handle() MKSHORT_NEW_HANDLE(__FILE__,__LINE__) | |
| #endif | | #endif | |
|
| char* mkshort_from_wpt(short_handle h, const waypoint* wpt); | | QString mkshort_from_wpt(short_handle h, const Waypoint* wpt); | |
| void mkshort_del_handle(short_handle* h); | | void mkshort_del_handle(short_handle* h); | |
| void setshort_length(short_handle, int n); | | void setshort_length(short_handle, int n); | |
| void setshort_badchars(short_handle, const char*); | | void setshort_badchars(short_handle, const char*); | |
| void setshort_goodchars(short_handle, const char*); | | void setshort_goodchars(short_handle, const char*); | |
| void setshort_mustupper(short_handle, int n); | | void setshort_mustupper(short_handle, int n); | |
| void setshort_mustuniq(short_handle, int n); | | void setshort_mustuniq(short_handle, int n); | |
| void setshort_whitespace_ok(short_handle, int n); | | void setshort_whitespace_ok(short_handle, int n); | |
| void setshort_repeating_whitespace_ok(short_handle, int n); | | void setshort_repeating_whitespace_ok(short_handle, int n); | |
| void setshort_defname(short_handle, const char* s); | | void setshort_defname(short_handle, const char* s); | |
| void setshort_is_utf8(short_handle h, const int is_utf8); | | void setshort_is_utf8(short_handle h, const int is_utf8); | |
| | | | |
|
| /* | | | |
| * Vmem flags values. | | | |
| */ | | | |
| #define VMFL_NOZERO (1 << 0) | | | |
| typedef struct vmem { | | | |
| char* mem; /* visible memory object */ | | | |
| size_t size; /* allocated size of object */ | | | |
| } vmem_t; | | | |
| vmem_t vmem_alloc(size_t, int flags); | | | |
| void vmem_free(vmem_t*); | | | |
| void vmem_realloc(vmem_t*, size_t); | | | |
| | | | |
| #define ARGTYPE_UNKNOWN 0x00000000 | | #define ARGTYPE_UNKNOWN 0x00000000 | |
| #define ARGTYPE_INT 0x00000001 | | #define ARGTYPE_INT 0x00000001 | |
| #define ARGTYPE_FLOAT 0x00000002 | | #define ARGTYPE_FLOAT 0x00000002 | |
| #define ARGTYPE_STRING 0x00000003 | | #define ARGTYPE_STRING 0x00000003 | |
| #define ARGTYPE_BOOL 0x00000004 | | #define ARGTYPE_BOOL 0x00000004 | |
| #define ARGTYPE_FILE 0x00000005 | | #define ARGTYPE_FILE 0x00000005 | |
| #define ARGTYPE_OUTFILE 0x00000006 | | #define ARGTYPE_OUTFILE 0x00000006 | |
| | | | |
| /* REQUIRED means that the option is required to be set. | | /* REQUIRED means that the option is required to be set. | |
| * See also BEGIN/END_REQ */ | | * See also BEGIN/END_REQ */ | |
| | | | |
| skipping to change at line 719 | | skipping to change at line 795 | |
| * If exactly one must be set, use with BEGIN/END_EXCL | | * If exactly one must be set, use with BEGIN/END_EXCL | |
| * Both of these flags set is synonymous with REQUIRED, so use that instead | | * Both of these flags set is synonymous with REQUIRED, so use that instead | |
| * for "groups" of exactly one option. */ | | * for "groups" of exactly one option. */ | |
| #define ARGTYPE_BEGIN_REQ 0x04000000 | | #define ARGTYPE_BEGIN_REQ 0x04000000 | |
| #define ARGTYPE_END_REQ 0x02000000 | | #define ARGTYPE_END_REQ 0x02000000 | |
| | | | |
| #define ARGTYPE_TYPEMASK 0x00000fff | | #define ARGTYPE_TYPEMASK 0x00000fff | |
| #define ARGTYPE_FLAGMASK 0xfffff000 | | #define ARGTYPE_FLAGMASK 0xfffff000 | |
| | | | |
| #define ARG_NOMINMAX NULL, NULL | | #define ARG_NOMINMAX NULL, NULL | |
|
| #define ARG_TERMINATOR {0, 0, 0, 0, 0, ARG_NOMINMAX} | | #define ARG_TERMINATOR {0, 0, 0, 0, 0, ARG_NOMINMAX, NULL} | |
| | | | |
| typedef struct arglist { | | typedef struct arglist { | |
| const char* argstring; | | const char* argstring; | |
| char** argval; | | char** argval; | |
| const char* helpstring; | | const char* helpstring; | |
| const char* defaultvalue; | | const char* defaultvalue; | |
|
| const gbuint32 argtype; | | const uint32_t argtype; | |
| const char* minvalue; /* minimum value for numeric options
*/ | | const char* minvalue; /* minimum value for numeric options
*/ | |
| const char* maxvalue; /* maximum value for numeric options
*/ | | const char* maxvalue; /* maximum value for numeric options
*/ | |
| char* argvalptr; /* !!! internal helper. Not used in definitions !!!
*/ | | char* argvalptr; /* !!! internal helper. Not used in definitions !!!
*/ | |
| } arglist_t; | | } arglist_t; | |
| | | | |
| typedef enum { | | typedef enum { | |
| ff_type_file = 1, /* normal format: useful to a GUI. */ | | ff_type_file = 1, /* normal format: useful to a GUI. */ | |
| ff_type_internal, /* fmt not useful with default options */ | | ff_type_internal, /* fmt not useful with default options */ | |
| ff_type_serial /* format describes a serial protocol (GUI c
an display port names) */ | | ff_type_serial /* format describes a serial protocol (GUI c
an display port names) */ | |
| } ff_type; | | } ff_type; | |
| | | | |
| skipping to change at line 769 | | skipping to change at line 845 | |
| typedef struct position_ops { | | typedef struct position_ops { | |
| ff_init rd_init; | | ff_init rd_init; | |
| ff_readposn rd_position; | | ff_readposn rd_position; | |
| ff_deinit rd_deinit; | | ff_deinit rd_deinit; | |
| | | | |
| ff_init wr_init; | | ff_init wr_init; | |
| ff_writeposn wr_position; | | ff_writeposn wr_position; | |
| ff_deinit wr_deinit; | | ff_deinit wr_deinit; | |
| } position_ops_t; | | } position_ops_t; | |
| | | | |
|
| | | #define NULL_POS_OPS { 0, 0, 0, 0, 0, 0, } | |
| | | | |
| /* | | /* | |
| * Describe the file format to the caller. | | * Describe the file format to the caller. | |
| */ | | */ | |
| typedef struct ff_vecs { | | typedef struct ff_vecs { | |
| ff_type type; | | ff_type type; | |
| ff_cap cap[3]; | | ff_cap cap[3]; | |
| ff_init rd_init; | | ff_init rd_init; | |
| ff_init wr_init; | | ff_init wr_init; | |
| ff_deinit rd_deinit; | | ff_deinit rd_deinit; | |
| ff_deinit wr_deinit; | | ff_deinit wr_deinit; | |
| | | | |
| skipping to change at line 797 | | skipping to change at line 875 | |
| } ff_vecs_t; | | } ff_vecs_t; | |
| | | | |
| typedef struct style_vecs { | | typedef struct style_vecs { | |
| const char* name; | | const char* name; | |
| const char* style_buf; | | const char* style_buf; | |
| } style_vecs_t; | | } style_vecs_t; | |
| extern style_vecs_t style_list[]; | | extern style_vecs_t style_list[]; | |
| | | | |
| void waypt_init(void); | | void waypt_init(void); | |
| void route_init(void); | | void route_init(void); | |
|
| void waypt_disp(const waypoint*); | | void waypt_disp(const Waypoint*); | |
| void waypt_status_disp(int total_ct, int myct); | | void waypt_status_disp(int total_ct, int myct); | |
|
| double waypt_time(const waypoint* wpt); | | double waypt_time(const Waypoint* wpt); | |
| double waypt_speed(const waypoint* A, const waypoint* B); | | double waypt_speed(const Waypoint* A, const Waypoint* B); | |
| double waypt_speed_ex(const waypoint* A, const waypoint* B); | | double waypt_speed_ex(const Waypoint* A, const Waypoint* B); | |
| double waypt_course(const waypoint* A, const waypoint* B); | | double waypt_course(const Waypoint* A, const Waypoint* B); | |
| double waypt_distance(const waypoint* A, const waypoint* B); | | double waypt_distance(const Waypoint* A, const Waypoint* B); | |
| double waypt_distance_ex(const waypoint* A, const waypoint* B); | | double waypt_distance_ex(const Waypoint* A, const Waypoint* B); | |
| | | | |
| NORETURN fatal(const char*, ...) PRINTFLIKE(1, 2); | | NORETURN fatal(const char*, ...) PRINTFLIKE(1, 2); | |
| void is_fatal(const int condition, const char*, ...) PRINTFLIKE(2, 3); | | void is_fatal(const int condition, const char*, ...) PRINTFLIKE(2, 3); | |
| void warning(const char*, ...) PRINTFLIKE(1, 2); | | void warning(const char*, ...) PRINTFLIKE(1, 2); | |
| void debug_print(int level, const char* fmt, ...) PRINTFLIKE(2,3); | | void debug_print(int level, const char* fmt, ...) PRINTFLIKE(2,3); | |
| | | | |
|
| ff_vecs_t* find_vec(char* const, char**); | | ff_vecs_t* find_vec(const char*, const char**); | |
| void assign_option(const char* vecname, arglist_t* ap, const char* val); | | void assign_option(const char* vecname, arglist_t* ap, const char* val); | |
| void disp_vec_options(const char* vecname, arglist_t* ap); | | void disp_vec_options(const char* vecname, arglist_t* ap); | |
| void disp_vecs(void); | | void disp_vecs(void); | |
| void disp_vec(const char* vecname); | | void disp_vec(const char* vecname); | |
| void init_vecs(void); | | void init_vecs(void); | |
| void exit_vecs(void); | | void exit_vecs(void); | |
| void disp_formats(int version); | | void disp_formats(int version); | |
| const char* name_option(long type); | | const char* name_option(long type); | |
| void printposn(const double c, int is_lat); | | void printposn(const double c, int is_lat); | |
| | | | |
| #ifndef DEBUG_MEM | | #ifndef DEBUG_MEM | |
| void* xcalloc(size_t nmemb, size_t size); | | void* xcalloc(size_t nmemb, size_t size); | |
| void* xmalloc(size_t size); | | void* xmalloc(size_t size); | |
| void* xrealloc(void* p, size_t s); | | void* xrealloc(void* p, size_t s); | |
|
| void xfree(void* mem); | | void xfree(const void* mem); | |
| char* xstrdup(const char* s); | | char* xstrdup(const QString& s); | |
| char* xstrndup(const char* s, size_t n); | | char* xstrndup(const char* s, size_t n); | |
| char* xstrndupt(const char* s, size_t n); | | char* xstrndupt(const char* s, size_t n); | |
| char* xstrappend(char* src, const char* addon); | | char* xstrappend(char* src, const char* addon); | |
| #define xxcalloc(nmemb, size, file, line) xcalloc(nmemb, size) | | #define xxcalloc(nmemb, size, file, line) xcalloc(nmemb, size) | |
| #define xxmalloc(size, file, line) xmalloc(size) | | #define xxmalloc(size, file, line) xmalloc(size) | |
| #define xxrealloc(p, s, file, line) xrealloc(p,s) | | #define xxrealloc(p, s, file, line) xrealloc(p,s) | |
| #define xxfree(mem, file, line) xfree(mem) | | #define xxfree(mem, file, line) xfree(mem) | |
| #define xxstrdup(s, file, line) xstrdup(s) | | #define xxstrdup(s, file, line) xstrdup(s) | |
| #define xxstrappend(src, addon, file, line) xstrappend(src, addon) | | #define xxstrappend(src, addon, file, line) xstrappend(src, addon) | |
| #else /* DEBUG_MEM */ | | #else /* DEBUG_MEM */ | |
| | | | |
| skipping to change at line 867 | | skipping to change at line 945 | |
| #define xxcalloc XCALLOC | | #define xxcalloc XCALLOC | |
| #define xxmalloc XMALLOC | | #define xxmalloc XMALLOC | |
| #define xxrealloc XREALLOC | | #define xxrealloc XREALLOC | |
| #define xxfree XFREE | | #define xxfree XFREE | |
| #define xxstrdup XSTRDUP | | #define xxstrdup XSTRDUP | |
| #define xxstrndupt XSTRNDUPT | | #define xxstrndupt XSTRNDUPT | |
| #define xxstrappend XSTRAPPEND | | #define xxstrappend XSTRAPPEND | |
| #endif /* DEBUG_MEM */ | | #endif /* DEBUG_MEM */ | |
| | | | |
| FILE* xfopen(const char* fname, const char* type, const char* errtxt); | | FILE* xfopen(const char* fname, const char* type, const char* errtxt); | |
|
| void xfprintf(const char* errtxt, FILE* stream, const char* format, ...); | | | |
| void xfputs(const char* errtxt, const char* s, FILE* stream); | | | |
| | | | |
|
| int case_ignore_strcmp(const char* s1, const char* s2); | | // FIXME: case_ignore_strcmp() and case_ignore_strncmp() should probably | |
| int case_ignore_strncmp(const char* s1, const char* s2, int n); | | // just be replaced at the call sites. These shims are just here to make | |
| | | // them more accomidating of QString input. | |
| | | inline int | |
| | | case_ignore_strcmp(const QString& s1, const QString& s2) { | |
| | | return QString::compare(s1, s2, Qt::CaseInsensitive); | |
| | | } | |
| | | // In 95% of the callers, this could be s1.startsWith(s2)... | |
| | | inline int case_ignore_strncmp(const QString& s1, const QString& s2, int n) | |
| | | { | |
| | | return s1.left(n).compare(s2, Qt::CaseInsensitive); | |
| | | } | |
| | | | |
| int str_match(const char* str, const char* match); | | int str_match(const char* str, const char* match); | |
| int case_ignore_str_match(const char* str, const char* match); | | int case_ignore_str_match(const char* str, const char* match); | |
|
| char* strenquote(const char* str, const char quot_char); | | QString strenquote(const QString& str, const QChar quot_char); | |
| | | | |
| char* strsub(const char* s, const char* search, const char* replace); | | char* strsub(const char* s, const char* search, const char* replace); | |
| char* gstrsub(const char* s, const char* search, const char* replace); | | char* gstrsub(const char* s, const char* search, const char* replace); | |
|
| char* xstrrstr(const char* s1, const char* s2); | | const char* xstrrstr(const char* s1, const char* s2); | |
| void rtrim(char* s); | | void rtrim(char* s); | |
| char* lrtrim(char* s); | | char* lrtrim(char* s); | |
| int xasprintf(char** strp, const char* fmt, ...) PRINTFLIKE(2, 3); | | int xasprintf(char** strp, const char* fmt, ...) PRINTFLIKE(2, 3); | |
|
| | | int xasprintf(QString* strp, const char* fmt, ...) PRINTFLIKE(2, 3); | |
| int xvasprintf(char** strp, const char* fmt, va_list ap); | | int xvasprintf(char** strp, const char* fmt, va_list ap); | |
| char* strupper(char* src); | | char* strupper(char* src); | |
| char* strlower(char* src); | | char* strlower(char* src); | |
| signed int get_tz_offset(void); | | signed int get_tz_offset(void); | |
| time_t mklocaltime(struct tm* t); | | time_t mklocaltime(struct tm* t); | |
| time_t mkgmtime(struct tm* t); | | time_t mkgmtime(struct tm* t); | |
|
| time_t current_time(void); | | gpsbabel::DateTime current_time(void); | |
| void dotnet_time_to_time_t(double dotnet, time_t* t, int* ms); | | void dotnet_time_to_time_t(double dotnet, time_t* t, int* ms); | |
| signed int month_lookup(const char* m); | | signed int month_lookup(const char* m); | |
|
| const char* get_cache_icon(const waypoint* waypointp); | | const char* get_cache_icon(const Waypoint* waypointp); | |
| const char* gs_get_cachetype(geocache_type t); | | const char* gs_get_cachetype(geocache_type t); | |
| const char* gs_get_container(geocache_container t); | | const char* gs_get_container(geocache_container t); | |
| char* xml_entitize(const char* str); | | char* xml_entitize(const char* str); | |
|
| char* html_entitize(const char* str); | | char* html_entitize(const QString& str); | |
| char* strip_html(const utf_string*); | | char* strip_html(const utf_string*); | |
|
| char* strip_nastyhtml(const char* in); | | char* strip_nastyhtml(const QString& in); | |
| char* convert_human_date_format(const char* human_datef); /* "MM,YYYY,
DD" -> "%m,%Y,%d" */ | | char* convert_human_date_format(const char* human_datef); /* "MM,YYYY,
DD" -> "%m,%Y,%d" */ | |
| char* convert_human_time_format(const char* human_timef); /* "HH+mm+ss
" -> "%H+%M+%S" */ | | char* convert_human_time_format(const char* human_timef); /* "HH+mm+ss
" -> "%H+%M+%S" */ | |
| char* pretty_deg_format(double lat, double lon, char fmt, const char* sep,
int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */ | | char* pretty_deg_format(double lat, double lon, char fmt, const char* sep,
int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */ | |
| | | | |
|
| char* get_filename(const char* fname); /* extract t
he filename portion */ | | const char* get_filename(const char* fname); /* extract t
he filename portion */ | |
| | | | |
| /* | | /* | |
| * Character encoding transformations. | | * Character encoding transformations. | |
| */ | | */ | |
| | | | |
| #define CET_NOT_CONVERTABLE_DEFAULT '$' | | #define CET_NOT_CONVERTABLE_DEFAULT '$' | |
| #define CET_CHARSET_ASCII "US-ASCII" | | #define CET_CHARSET_ASCII "US-ASCII" | |
| #define CET_CHARSET_UTF8 "UTF-8" | | #define CET_CHARSET_UTF8 "UTF-8" | |
| #define CET_CHARSET_HEBREW "CP1255" | | #define CET_CHARSET_HEBREW "CP1255" | |
| #define CET_CHARSET_MS_ANSI "MS-ANSI" | | #define CET_CHARSET_MS_ANSI "MS-ANSI" | |
| #define CET_CHARSET_LATIN1 "ISO-8859-1" | | #define CET_CHARSET_LATIN1 "ISO-8859-1" | |
| | | | |
| #define str_utf8_to_cp1252(str) cet_str_utf8_to_cp1252((str)) | | #define str_utf8_to_cp1252(str) cet_str_utf8_to_cp1252((str)) | |
| #define str_cp1252_to_utf8(str) cet_str_cp1252_to_utf8((str)) | | #define str_cp1252_to_utf8(str) cet_str_cp1252_to_utf8((str)) | |
| | | | |
| #define str_utf8_to_iso8859_1(str) cet_str_utf8_to_iso8859_1((str)) | | #define str_utf8_to_iso8859_1(str) cet_str_utf8_to_iso8859_1((str)) | |
| #define str_iso8859_1_to_utf8(str) cet_str_iso8859_1_to_utf8((str)) | | #define str_iso8859_1_to_utf8(str) cet_str_iso8859_1_to_utf8((str)) | |
| | | | |
| /* this lives in gpx.c */ | | /* this lives in gpx.c */ | |
|
| time_t xml_parse_time(const char* cdatastr, int* microsecs); | | gpsbabel::DateTime xml_parse_time(const QString& cdatastr); | |
| | | | |
|
| xml_tag* xml_findfirst(xml_tag* root, const char* tagname); | | char* rot13(const QString& str); | |
| xml_tag* xml_findnext(xml_tag* root, xml_tag* cur, const char* tagname); | | | |
| char* xml_attribute(xml_tag* tag, const char* attrname); | | | |
| | | | |
| char* rot13(const char* str); | | | |
| | | | |
| /* | | /* | |
| * PalmOS records like fixed-point numbers, which should be rounded | | * PalmOS records like fixed-point numbers, which should be rounded | |
| * to deal with possible floating-point representation errors. | | * to deal with possible floating-point representation errors. | |
| */ | | */ | |
| | | | |
| signed int si_round(double d); | | signed int si_round(double d); | |
| | | | |
|
| | | #if _MSC_VER | |
| | | //These functions are not included in the MS pre C99 implementation, use in | |
| | | ternal implementation | |
| | | //This asssumes that non-_MSC_VER includes math.h (all should include defs. | |
| | | h) | |
| | | #define round si_round | |
| | | #define lround si_round | |
| | | #endif | |
| | | | |
| /* | | /* | |
| * Data types for Palm/OS files. | | * Data types for Palm/OS files. | |
| */ | | */ | |
| typedef struct { | | typedef struct { | |
| unsigned char data[4]; | | unsigned char data[4]; | |
| } pdb_32; | | } pdb_32; | |
| | | | |
| typedef struct { | | typedef struct { | |
| unsigned char data[2]; | | unsigned char data[2]; | |
| } pdb_16; | | } pdb_16; | |
| | | | |
| skipping to change at line 1018 | | skipping to change at line 1108 | |
| } grid_type; | | } grid_type; | |
| | | | |
| #define GRID_INDEX_MIN grid_lat_lon_ddd | | #define GRID_INDEX_MIN grid_lat_lon_ddd | |
| #define GRID_INDEX_MAX grid_swiss | | #define GRID_INDEX_MAX grid_swiss | |
| | | | |
| #define DATUM_OSGB36 86 | | #define DATUM_OSGB36 86 | |
| #define DATUM_WGS84 118 | | #define DATUM_WGS84 118 | |
| | | | |
| /* bit manipulation functions (util.c) */ | | /* bit manipulation functions (util.c) */ | |
| | | | |
|
| char gb_getbit(const void* buf, const gbuint32 nr); | | char gb_getbit(const void* buf, const uint32_t nr); | |
| void gb_setbit(void* buf, const gbuint32 nr); | | void gb_setbit(void* buf, const uint32_t nr); | |
| | | | |
| void* gb_int2ptr(const int i); | | void* gb_int2ptr(const int i); | |
| int gb_ptr2int(const void* p); | | int gb_ptr2int(const void* p); | |
| | | | |
| /* | | /* | |
| * From parse.c | | * From parse.c | |
| */ | | */ | |
| int parse_coordinates(const char* str, int datum, const grid_type grid, | | int parse_coordinates(const char* str, int datum, const grid_type grid, | |
| double* latitude, double* longitude, const char* modu
le); | | double* latitude, double* longitude, const char* modu
le); | |
| int parse_distance(const char* str, double* val, double scale, const char*
module); | | int parse_distance(const char* str, double* val, double scale, const char*
module); | |
| | | | |
| skipping to change at line 1051 | | skipping to change at line 1141 | |
| */ | | */ | |
| typedef enum { | | typedef enum { | |
| units_unknown = 0, | | units_unknown = 0, | |
| units_statute = 1, | | units_statute = 1, | |
| units_metric = 2, | | units_metric = 2, | |
| units_nautical =3, | | units_nautical =3, | |
| units_aviation =4 | | units_aviation =4 | |
| } fmt_units; | | } fmt_units; | |
| | | | |
| int fmt_setunits(fmt_units); | | int fmt_setunits(fmt_units); | |
|
| double fmt_distance(const double, char** tag); | | double fmt_distance(const double, const char** tag); | |
| double fmt_altitude(const double, char** tag); | | double fmt_altitude(const double, const char** tag); | |
| double fmt_speed(const double, char** tag); | | double fmt_speed(const double, const char** tag); | |
| | | | |
| /* | | /* | |
| * From gbsleep.c | | * From gbsleep.c | |
| */ | | */ | |
| void gb_sleep(unsigned long microseconds); | | void gb_sleep(unsigned long microseconds); | |
| | | | |
| /* | | /* | |
| * From nmea.c | | * From nmea.c | |
| */ | | */ | |
| int nmea_cksum(const char* const buf); | | int nmea_cksum(const char* const buf); | |
| | | | |
| skipping to change at line 1077 | | skipping to change at line 1167 | |
| */ | | */ | |
| int color_to_bbggrr(const char* cname); | | int color_to_bbggrr(const char* cname); | |
| | | | |
| /* | | /* | |
| * A constant for unknown altitude. It's tempting to just use zero | | * A constant for unknown altitude. It's tempting to just use zero | |
| * but that's not very nice for the folks near sea level. | | * but that's not very nice for the folks near sea level. | |
| */ | | */ | |
| #define unknown_alt -99999999.0 | | #define unknown_alt -99999999.0 | |
| #define unknown_color -1 | | #define unknown_color -1 | |
| | | | |
|
| | | // TODO: this is a (probably temporary) shim for the C->QString conversion. | |
| | | // It's here instead of gps to avoid C/C++ linkage issues. | |
| | | int32_t GPS_Lookup_Datum_Index(const QString& n); | |
| | | | |
| #endif /* gpsbabel_defs_h_included */ | | #endif /* gpsbabel_defs_h_included */ | |
| | | | |
End of changes. 72 change blocks. |
| 151 lines changed or deleted | | 251 lines changed or added | |
|
| garmin_device_xml.h | | garmin_device_xml.h | |
| /* | | /* | |
| Parse 'GarminDevice.xml' on a Garmin mass storage device (e.g. Zumo, | | Parse 'GarminDevice.xml' on a Garmin mass storage device (e.g. Zumo, | |
| Nuvi, Colorado, etc. and return key device info. | | Nuvi, Colorado, etc. and return key device info. | |
| | | | |
|
| Copyright (C) 2008 Robert Lipe, robertlipe@gpsbabel.org | | Copyright (C) 2008-2014 Robert Lipe | |
| | | | |
| This program is free software; you can redistribute it and/or modify | | 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 | | it under the terms of the GNU General Public License as published by | |
| the Free Software Foundation; either version 2 of the License, or | | the Free Software Foundation; either version 2 of the License, or | |
| (at your option) any later version. | | (at your option) any later version. | |
| | | | |
| This program is distributed in the hope that it will be useful, | | This program is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| GNU General Public License for more details. | | GNU General Public License for more details. | |
| | | | |
| skipping to change at line 56 | | skipping to change at line 56 | |
| const gdx_info* gdx_get_info(void); | | const gdx_info* gdx_get_info(void); | |
| const gdx_info* gdx_find_file(char** dirlist); | | const gdx_info* gdx_find_file(char** dirlist); | |
| | | | |
| // This is so gross. By the time we know it's not a USB device | | // This is so gross. By the time we know it's not a USB device | |
| // and could be one of our devices, we're so deep into the callstack | | // and could be one of our devices, we're so deep into the callstack | |
| // that can't back out tracefully without bludgeoning most of the | | // that can't back out tracefully without bludgeoning most of the | |
| // (Mac|Lin|Win) x (USB|Serial) matrix. Since we don't *really* want | | // (Mac|Lin|Win) x (USB|Serial) matrix. Since we don't *really* want | |
| // to progress any further, we just longjump back to the caller... | | // to progress any further, we just longjump back to the caller... | |
| #include <setjmp.h> | | #include <setjmp.h> | |
| extern jmp_buf gdx_jmp_buf; | | extern jmp_buf gdx_jmp_buf; | |
|
| | | | |
| #if 0 | | | |
| | | | |
| /* | | | |
| * The file-level information. | | | |
| */ | | | |
| static | | | |
| struct gpx_global { | | | |
| gpx_global_entry name; | | | |
| gpx_global_entry desc; | | | |
| gpx_global_entry author; | | | |
| gpx_global_entry email; | | | |
| gpx_global_entry url; | | | |
| gpx_global_entry urlname; | | | |
| gpx_global_entry keywords; | | | |
| /* time and bounds aren't here; they're recomputed. */ | | | |
| }* gpx_global ; | | | |
| | | | |
| static void | | | |
| gpx_add_to_global(gpx_global_entry* ge, char* cdata) | | | |
| { | | | |
| queue* elem, *tmp; | | | |
| gpx_global_entry* gep; | | | |
| | | | |
| QUEUE_FOR_EACH(&ge->queue, elem, tmp) { | | | |
| gep = BASE_STRUCT(elem, gpx_global_entry, queue); | | | |
| if (0 == strcmp(cdata, gep->tagdata)) { | | | |
| return; | | | |
| } | | | |
| } | | | |
| | | | |
| gep = xcalloc(sizeof(*gep), 1); | | | |
| QUEUE_INIT(&gep->queue); | | | |
| gep->tagdata = xstrdup(cdata); | | | |
| ENQUEUE_TAIL(&ge->queue, &gep->queue); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_rm_from_global(gpx_global_entry* ge) | | | |
| { | | | |
| queue* elem, *tmp; | | | |
| | | | |
| QUEUE_FOR_EACH(&ge->queue, elem, tmp) { | | | |
| gpx_global_entry* g = (gpx_global_entry*) dequeue(elem); | | | |
| xfree(g->tagdata); | | | |
| xfree(g); | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_write_gdata(gpx_global_entry* ge, char* tag) | | | |
| { | | | |
| queue* elem, *tmp; | | | |
| gpx_global_entry* gep; | | | |
| | | | |
| if (!gpx_global || QUEUE_EMPTY(&ge->queue)) { | | | |
| return; | | | |
| } | | | |
| | | | |
| gbfprintf(ofd, "<%s>", tag); | | | |
| QUEUE_FOR_EACH(&ge->queue, elem, tmp) { | | | |
| gep = BASE_STRUCT(elem, gpx_global_entry, queue); | | | |
| gbfprintf(ofd, "%s", gep->tagdata); | | | |
| /* Some tags we just output once. */ | | | |
| if ((0 == strcmp(tag, "url")) || | | | |
| (0 == strcmp(tag, "email"))) { | | | |
| break; | | | |
| } | | | |
| gbfprintf(ofd, " "); | | | |
| } | | | |
| gbfprintf(ofd, "</%s>\n", tag); | | | |
| } | | | |
| | | | |
| typedef struct tag_mapping { | | | |
| tag_type tag_type; /* enum from above for this tag */ | | | |
| int tag_passthrough; /* true if we don't generate this */ | | | |
| const char* tag_name; /* xpath-ish tag name */ | | | |
| unsigned long crc; /* Crc32 of tag_name */ | | | |
| } tag_mapping; | | | |
| | | | |
| /* | | | |
| * xpath(ish) mappings between full tag paths and internal identifers. | | | |
| * These appear in the order they appear in the GPX specification. | | | |
| * If it's not a tag we explictly handle, it doesn't go here. | | | |
| */ | | | |
| | | | |
| tag_mapping tag_path_map[] = { | | | |
| { tt_gpx, 0, "/gpx", 0UL }, | | | |
| { tt_name, 0, "/gpx/name", 0UL }, | | | |
| { tt_desc, 0, "/gpx/desc", 0UL }, | | | |
| { tt_author, 0, "/gpx/author", 0UL }, | | | |
| { tt_email, 0, "/gpx/email", 0UL }, | | | |
| { tt_url, 0, "/gpx/url", 0UL }, | | | |
| { tt_urlname, 0, "/gpx/urlname", 0UL }, | | | |
| { tt_keywords, 0, "/gpx/keywords", 0UL }, | | | |
| | | | |
| { tt_wpt, 0, "/gpx/wpt", 0UL }, | | | |
| { tt_wpt_ele, 0, "/gpx/wpt/ele", 0UL }, | | | |
| { tt_wpt_time, 0, "/gpx/wpt/time", 0UL }, | | | |
| { tt_wpt_name, 0, "/gpx/wpt/name", 0UL }, | | | |
| { tt_wpt_cmt, 0, "/gpx/wpt/cmt", 0UL }, | | | |
| { tt_wpt_desc, 0, "/gpx/wpt/desc", 0UL }, | | | |
| { tt_wpt_url, 0, "/gpx/wpt/url", 0UL }, | | | |
| { tt_wpt_urlname, 0, "/gpx/wpt/urlname", 0UL }, | | | |
| { tt_wpt_link, 0, "/gpx/wpt/link", 0UL }, /* GPX 1.1 * | | | |
| / | | | |
| { tt_wpt_link_text, 0, "/gpx/wpt/link/text", 0UL }, /* GPX 1.1 * | | | |
| / | | | |
| { tt_wpt_sym, 0, "/gpx/wpt/sym", 0UL }, | | | |
| { tt_wpt_type, 1, "/gpx/wpt/type", 0UL }, | | | |
| | | | |
| /* Double up the GPX 1.0 and GPX 1.1 styles */ | | | |
| #define GEOTAG(type,name) \ | | | |
| {type, 1, "/gpx/wpt/groundspeak:cache/groundspeak:" name, 0UL }, \ | | | |
| {type, 1, "/gpx/wpt/extensions/cache/" name, 0UL }, \ | | | |
| {type, 1, "/gpx/wpt/geocache/" name, 0UL } /* opencaching.de */ | | | |
| | | | |
| #define GARMIN_WPT_EXT "/gpx/wpt/extensions/gpxx:WaypointExtension" | | | |
| | | | |
| // GEOTAG( tt_cache, "cache"), | | | |
| { tt_cache, 1, "/gpx/wpt/groundspeak:cache" }, | | | |
| | | | |
| GEOTAG(tt_cache_name, "name"), | | | |
| GEOTAG(tt_cache_container, "container"), | | | |
| GEOTAG(tt_cache_type, "type"), | | | |
| GEOTAG(tt_cache_difficulty, "difficulty"), | | | |
| GEOTAG(tt_cache_terrain, "terrain"), | | | |
| GEOTAG(tt_cache_hint, "encoded_hints"), | | | |
| GEOTAG(tt_cache_hint, "hints"), /* opencaching.de */ | | | |
| GEOTAG(tt_cache_desc_short, "short_description"), | | | |
| GEOTAG(tt_cache_desc_long, "long_description"), | | | |
| GEOTAG(tt_cache_placer, "owner"), | | | |
| { tt_cache_log_wpt, 1, "/gpx/wpt/groundspeak:cache/groundspeak:logs/groun | | | |
| dspeak:log/groundspeak:log_wpt"}, | | | |
| { tt_cache_log_wpt, 1, "/gpx/wpt/extensions/cache/logs/log/log_wpt"}, | | | |
| { tt_cache_log_type, 1, "/gpx/wpt/groundspeak:cache/groundspeak:logs/grou | | | |
| ndspeak:log/groundspeak:type"}, | | | |
| { tt_cache_log_type, 1, "/gpx/wpt/extensions/cache/logs/log/type"}, | | | |
| { tt_cache_log_date, 1, "/gpx/wpt/groundspeak:cache/groundspeak:logs/grou | | | |
| ndspeak:log/groundspeak:date"}, | | | |
| { tt_cache_log_date, 1, "/gpx/wpt/extensions/cache/logs/log/date"}, | | | |
| | | | |
| { tt_wpt_extensions, 0, "/gpx/wpt/extensions", 0UL }, | | | |
| | | | |
| { tt_garmin_wpt_extensions, 0, GARMIN_WPT_EXT, 0UL }, | | | |
| { tt_garmin_wpt_proximity, 0, GARMIN_WPT_EXT "/gpxx:Proximity", 0UL }, | | | |
| { tt_garmin_wpt_temperature, 0, GARMIN_WPT_EXT "/gpxx:Temperature", 0UL } | | | |
| , | | | |
| { tt_garmin_wpt_depth, 0, GARMIN_WPT_EXT "/gpxx:Depth", 0UL }, | | | |
| { tt_garmin_wpt_display_mode, 0, GARMIN_WPT_EXT "/gpxx:DisplayMode", 0UL | | | |
| }, | | | |
| { tt_garmin_wpt_categories, 0, GARMIN_WPT_EXT "/gpxx:Categories", 0UL }, | | | |
| { tt_garmin_wpt_category, 0, GARMIN_WPT_EXT "/gpxx:Categories/gpxx:Catego | | | |
| ry", 0UL }, | | | |
| { tt_garmin_wpt_addr, 0, GARMIN_WPT_EXT "/gpxx:Address/gpxx:StreetAddress | | | |
| ", 0UL }, | | | |
| { tt_garmin_wpt_city, 0, GARMIN_WPT_EXT "/gpxx:Address/gpxx:City", 0UL }, | | | |
| { tt_garmin_wpt_state, 0, GARMIN_WPT_EXT "/gpxx:Address/gpxx:State", 0UL | | | |
| }, | | | |
| { tt_garmin_wpt_country, 0, GARMIN_WPT_EXT "/gpxx:Address/gpxx:Country", | | | |
| 0UL }, | | | |
| { tt_garmin_wpt_postal_code, 0, GARMIN_WPT_EXT "/gpxx:Address/gpxx:Postal | | | |
| Code", 0UL }, | | | |
| { tt_garmin_wpt_phone_nr, 0, GARMIN_WPT_EXT "/gpxx:PhoneNumber", 0UL }, | | | |
| | | | |
| { tt_rte, 0, "/gpx/rte", 0UL }, | | | |
| { tt_rte_name, 0, "/gpx/rte/name", 0UL }, | | | |
| { tt_rte_desc, 0, "/gpx/rte/desc", 0UL }, | | | |
| { tt_rte_number, 0, "/gpx/rte/number", 0UL }, | | | |
| { tt_rte_rtept, 0, "/gpx/rte/rtept", 0UL }, | | | |
| { tt_rte_rtept_ele, 0, "/gpx/rte/rtept/ele", 0UL }, | | | |
| { tt_rte_rtept_time, 0, "/gpx/rte/rtept/time", 0UL }, | | | |
| { tt_rte_rtept_name, 0, "/gpx/rte/rtept/name", 0UL }, | | | |
| { tt_rte_rtept_cmt, 0, "/gpx/rte/rtept/cmt", 0UL }, | | | |
| { tt_rte_rtept_desc, 0, "/gpx/rte/rtept/desc", 0UL }, | | | |
| { tt_rte_rtept_url, 0, "/gpx/rte/rtept/url", 0UL }, | | | |
| { tt_rte_rtept_urlname, 0, "/gpx/rte/rtept/urlname", 0UL }, | | | |
| { tt_rte_rtept_sym, 0, "/gpx/rte/rtept/sym", 0UL }, | | | |
| | | | |
| { tt_trk, 0, "/gpx/trk", 0UL }, | | | |
| { tt_trk_name, 0, "/gpx/trk/name", 0UL }, | | | |
| { tt_trk_desc, 0, "/gpx/trk/desc", 0UL }, | | | |
| { tt_trk_trkseg, 0, "/gpx/trk/trkseg", 0UL }, | | | |
| { tt_trk_number, 0, "/gpx/trk/number", 0UL }, | | | |
| { tt_trk_trkseg_trkpt, 0, "/gpx/trk/trkseg/trkpt", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_ele, 0, "/gpx/trk/trkseg/trkpt/ele", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_time, 0, "/gpx/trk/trkseg/trkpt/time", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_name, 0, "/gpx/trk/trkseg/trkpt/name", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_cmt, 0, "/gpx/trk/trkseg/trkpt/cmt", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_desc, 0, "/gpx/trk/trkseg/trkpt/desc", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_url, 0, "/gpx/trk/trkseg/trkpt/url", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_urlname, 0, "/gpx/trk/trkseg/trkpt/urlname", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_sym, 0, "/gpx/trk/trkseg/trkpt/sym", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_course, 0, "/gpx/trk/trkseg/trkpt/course", 0UL }, | | | |
| { tt_trk_trkseg_trkpt_speed, 0, "/gpx/trk/trkseg/trkpt/speed", 0UL }, | | | |
| | | | |
| /* Common to tracks, routes, and waypts */ | | | |
| { tt_fix, 0, "/gpx/wpt/fix", 0UL }, | | | |
| { tt_fix, 0, "/gpx/trk/trkseg/trkpt/fix", 0UL }, | | | |
| { tt_fix, 0, "/gpx/rte/rtept/fix", 0UL }, | | | |
| { tt_sat, 0, "/gpx/wpt/sat", 0UL }, | | | |
| { tt_sat, 0, "/gpx/trk/trkseg/trkpt/sat", 0UL }, | | | |
| { tt_sat, 0, "/gpx/rte/rtept/sat", 0UL }, | | | |
| { tt_pdop, 0, "/gpx/wpt/pdop", 0UL }, | | | |
| { tt_pdop, 0, "/gpx/trk/trkseg/trkpt/pdop", 0UL }, | | | |
| { tt_pdop, 0, "/gpx/rte/rtept/pdop", 0UL }, | | | |
| { tt_hdop, 0, "/gpx/wpt/hdop", 0UL }, | | | |
| { tt_hdop, 0, "/gpx/trk/trkseg/trkpt/hdop", 0UL }, | | | |
| { tt_hdop, 0, "/gpx/rte/rtept/hdop", 0UL }, | | | |
| { tt_vdop, 0, "/gpx/wpt/vdop", 0UL }, | | | |
| { tt_vdop, 0, "/gpx/trk/trkseg/trkpt/vdop", 0UL }, | | | |
| { tt_vdop, 0, "/gpx/rte/rtept/hdop", 0UL }, | | | |
| {0, 0, NULL, 0UL} | | | |
| }; | | | |
| | | | |
| static tag_type | | | |
| get_tag(const char* t, int* passthrough) | | | |
| { | | | |
| tag_mapping* tm; | | | |
| unsigned long tcrc = get_crc32_s(t); | | | |
| | | | |
| for (tm = tag_path_map; tm->tag_type != 0; tm++) { | | | |
| if ((tcrc == tm->crc) && (0 == strcmp(tm->tag_name, t))) { | | | |
| *passthrough = tm->tag_passthrough; | | | |
| return tm->tag_type; | | | |
| } | | | |
| } | | | |
| *passthrough = 1; | | | |
| return tt_unknown; | | | |
| } | | | |
| | | | |
| static void | | | |
| prescan_tags(void) | | | |
| { | | | |
| tag_mapping* tm; | | | |
| for (tm = tag_path_map; tm->tag_type != 0; tm++) { | | | |
| tm->crc = get_crc32_s(tm->tag_name); | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| tag_gpx(const char** attrv) | | | |
| { | | | |
| const char** avp; | | | |
| for (avp = &attrv[0]; *avp; avp += 2) { | | | |
| if (strcmp(avp[0], "version") == 0) { | | | |
| gpx_version = avp[1]; | | | |
| } else if (strcmp(avp[0], "src") == 0) { | | | |
| gpx_creator = avp[1]; | | | |
| } | | | |
| /* | | | |
| * Our handling of schemaLocation really is weird. | | | |
| * If we see we have a "normal" GPX 1.1 header, on read, | | | |
| * flip our default on write to use that and don't append | | | |
| * it to the rest... | | | |
| */ | | | |
| else if (strcmp(avp[0], "xsi:schemaLocation") == 0) { | | | |
| if (0 == strcmp(avp[1], DEFAULT_XSI_SCHEMA_LOC_11)) { | | | |
| if (0 == strcmp(xsi_schema_loc, DEFAULT_XSI_SCHEMA_LOC)) { | | | |
| xfree(xsi_schema_loc); | | | |
| } | | | |
| xsi_schema_loc = xstrdup(DEFAULT_XSI_SCHEMA_LOC_11); | | | |
| continue; | | | |
| } | | | |
| if (0 == strstr(xsi_schema_loc, avp[1])) { | | | |
| xsi_schema_loc = xstrappend(xsi_schema_loc, " "); | | | |
| xsi_schema_loc = xstrappend(xsi_schema_loc, avp[1]); | | | |
| } | | | |
| } | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| tag_wpt(const char** attrv) | | | |
| { | | | |
| const char** avp = &attrv[0]; | | | |
| | | | |
| wpt_tmp = waypt_new(); | | | |
| | | | |
| cur_tag = NULL; | | | |
| while (*avp) { | | | |
| if (strcmp(avp[0], "lat") == 0) { | | | |
| sscanf(avp[1], "%lf", | | | |
| &wpt_tmp->latitude); | | | |
| } else if (strcmp(avp[0], "lon") == 0) { | | | |
| sscanf(avp[1], "%lf", | | | |
| &wpt_tmp->longitude); | | | |
| } | | | |
| avp+=2; | | | |
| } | | | |
| fs_ptr = &wpt_tmp->fs; | | | |
| } | | | |
| | | | |
| static void | | | |
| tag_cache_desc(const char** attrv) | | | |
| { | | | |
| const char** avp; | | | |
| | | | |
| cache_descr_is_html = 0; | | | |
| for (avp = &attrv[0]; *avp; avp+=2) { | | | |
| if (strcmp(avp[0], "html") == 0) { | | | |
| if (strcmp(avp[1], "True") == 0) { | | | |
| cache_descr_is_html = 1; | | | |
| } | | | |
| } | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| tag_gs_cache(const char** attrv) | | | |
| { | | | |
| const char** avp; | | | |
| | | | |
| for (avp = &attrv[0]; *avp; avp+=2) { | | | |
| if (strcmp(avp[0], "id") == 0) { | | | |
| wpt_tmp->gc_data.id = atoi(avp[1]); | | | |
| } else if (strcmp(avp[0], "available") == 0) { | | | |
| if (case_ignore_strcmp(avp[1], "True") == 0) { | | | |
| wpt_tmp->gc_data.is_available = status_true; | | | |
| } else if (case_ignore_strcmp(avp[1], "False") == 0) { | | | |
| wpt_tmp->gc_data.is_available = status_false; | | | |
| } | | | |
| } else if (strcmp(avp[0], "archived") == 0) { | | | |
| if (case_ignore_strcmp(avp[1], "True") == 0) { | | | |
| wpt_tmp->gc_data.is_archived = status_true; | | | |
| } else if (case_ignore_strcmp(avp[1], "False") == 0) { | | | |
| wpt_tmp->gc_data.is_archived = status_false; | | | |
| } | | | |
| } | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| start_something_else(const char* el, const char** attrv) | | | |
| { | | | |
| const char** avp = attrv; | | | |
| char** avcp = NULL; | | | |
| int attr_count = 0; | | | |
| xml_tag* new_tag; | | | |
| fs_xml* fs_gpx; | | | |
| | | | |
| if (!fs_ptr) { | | | |
| return; | | | |
| } | | | |
| | | | |
| new_tag = (xml_tag*)xcalloc(sizeof(xml_tag),1); | | | |
| new_tag->tagname = xstrdup(el); | | | |
| | | | |
| /* count attributes */ | | | |
| while (*avp) { | | | |
| attr_count++; | | | |
| avp++; | | | |
| } | | | |
| | | | |
| /* copy attributes */ | | | |
| avp = attrv; | | | |
| new_tag->attributes = (char**)xcalloc(sizeof(char*),attr_count+1); | | | |
| avcp = new_tag->attributes; | | | |
| while (*avp) { | | | |
| *avcp = xstrdup(*avp); | | | |
| avcp++; | | | |
| avp++; | | | |
| } | | | |
| *avcp = NULL; | | | |
| | | | |
| if (cur_tag) { | | | |
| if (cur_tag->child) { | | | |
| cur_tag = cur_tag->child; | | | |
| while (cur_tag->sibling) { | | | |
| cur_tag = cur_tag->sibling; | | | |
| } | | | |
| cur_tag->sibling = new_tag; | | | |
| new_tag->parent = cur_tag->parent; | | | |
| } else { | | | |
| cur_tag->child = new_tag; | | | |
| new_tag->parent = cur_tag; | | | |
| } | | | |
| } else { | | | |
| fs_gpx = (fs_xml*)fs_chain_find(*fs_ptr, FS_GPX); | | | |
| | | | |
| if (fs_gpx && fs_gpx->tag) { | | | |
| cur_tag = fs_gpx->tag; | | | |
| while (cur_tag->sibling) { | | | |
| cur_tag = cur_tag->sibling; | | | |
| } | | | |
| cur_tag->sibling = new_tag; | | | |
| new_tag->parent = NULL; | | | |
| } else { | | | |
| fs_gpx = fs_xml_alloc(FS_GPX); | | | |
| fs_gpx->tag = new_tag; | | | |
| fs_chain_add(fs_ptr, (format_specific_data*)fs_gpx); | | | |
| new_tag->parent = NULL; | | | |
| } | | | |
| } | | | |
| cur_tag = new_tag; | | | |
| } | | | |
| | | | |
| static void | | | |
| end_something_else() | | | |
| { | | | |
| if (cur_tag) { | | | |
| cur_tag = cur_tag->parent; | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| tag_log_wpt(const char** attrv) | | | |
| { | | | |
| waypoint* lwp_tmp; | | | |
| const char** avp = &attrv[0]; | | | |
| | | | |
| /* create a new waypoint */ | | | |
| lwp_tmp = waypt_new(); | | | |
| | | | |
| /* extract the lat/lon attributes */ | | | |
| while (*avp) { | | | |
| if (strcmp(avp[0], "lat") == 0) { | | | |
| sscanf(avp[1], "%lf", | | | |
| &lwp_tmp->latitude); | | | |
| } else if (strcmp(avp[0], "lon") == 0) { | | | |
| sscanf(avp[1], "%lf", | | | |
| &lwp_tmp->longitude); | | | |
| } | | | |
| avp+=2; | | | |
| } | | | |
| /* Make a new shortname. Since this is a groundspeak extension, | | | |
| we assume that GCBLAH is the current shortname format and that | | | |
| wpt_tmp refers to the currently parsed waypoint. Unfortunatley, | | | |
| we need to keep track of log_wpt counts so we don't collide with | | | |
| dupe shortnames. | | | |
| */ | | | |
| | | | |
| if ((wpt_tmp->shortname) && (strlen(wpt_tmp->shortname) > 2)) { | | | |
| /* copy of the shortname */ | | | |
| lwp_tmp->shortname = xcalloc(7, 1); | | | |
| sprintf(lwp_tmp->shortname, "%-4.4s%02d", | | | |
| &wpt_tmp->shortname[2], logpoint_ct++); | | | |
| | | | |
| waypt_add(lwp_tmp); | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_start(void* data, const XML_Char* xml_el, const XML_Char** xml_attr) | | | |
| { | | | |
| char* e; | | | |
| char* ep; | | | |
| int passthrough; | | | |
| const char* el = xml_convert_to_char_string(xml_el); | | | |
| const char** attr = xml_convert_attrs_to_char_string(xml_attr); | | | |
| | | | |
| vmem_realloc(¤t_tag, strlen(current_tag.mem) + 2 + strlen(el)); | | | |
| e = current_tag.mem; | | | |
| ep = e + strlen(e); | | | |
| *ep++ = '/'; | | | |
| strcpy(ep, el); | | | |
| | | | |
| /* | | | |
| * FIXME: Find out why a cdatastr[0] doesn't adequately reset the | | | |
| * cdata handler. | | | |
| */ | | | |
| memset(cdatastr.mem, 0, cdatastr.size); | | | |
| | | | |
| switch (get_tag(current_tag.mem, &passthrough)) { | | | |
| case tt_gpx: | | | |
| tag_gpx(attr); | | | |
| break; | | | |
| case tt_wpt: | | | |
| tag_wpt(attr); | | | |
| break; | | | |
| case tt_wpt_link: | | | |
| if (0 == strcmp(attr[0], "href")) { | | | |
| link_url = attr[1]; | | | |
| } | | | |
| break; | | | |
| case tt_wpt_link_text: | | | |
| link_text = cdatastr.mem; | | | |
| break; | | | |
| case tt_rte: | | | |
| rte_head = route_head_alloc(); | | | |
| route_add_head(rte_head); | | | |
| fs_ptr = &rte_head->fs; | | | |
| break; | | | |
| case tt_rte_rtept: | | | |
| tag_wpt(attr); | | | |
| break; | | | |
| case tt_trk: | | | |
| trk_head = route_head_alloc(); | | | |
| track_add_head(trk_head); | | | |
| fs_ptr = &trk_head->fs; | | | |
| break; | | | |
| case tt_trk_trkseg_trkpt: | | | |
| tag_wpt(attr); | | | |
| break; | | | |
| case tt_unknown: | | | |
| start_something_else(el, attr); | | | |
| return; | | | |
| case tt_cache: | | | |
| tag_gs_cache(attr); | | | |
| break; | | | |
| case tt_cache_log_wpt: | | | |
| if (opt_logpoint) { | | | |
| tag_log_wpt(attr); | | | |
| } | | | |
| break; | | | |
| case tt_cache_desc_long: | | | |
| case tt_cache_desc_short: | | | |
| tag_cache_desc(attr); | | | |
| break; | | | |
| case tt_cache_placer: | | | |
| if (*attr && (0 == strcmp(attr[0], "id"))) { | | | |
| wpt_tmp->gc_data.placer_id = atoi(attr[1]); | | | |
| } | | | |
| default: | | | |
| break; | | | |
| } | | | |
| if (passthrough) { | | | |
| start_something_else(el, attr); | | | |
| } | | | |
| xml_free_converted_string(el); | | | |
| xml_free_converted_attrs(attr); | | | |
| } | | | |
| | | | |
| struct | | | |
| gs_type_mapping { | | | |
| geocache_type type; | | | |
| const char* name; | | | |
| } gs_type_map[] = { | | | |
| { gt_traditional, "Traditional Cache" }, | | | |
| { gt_traditional, "Traditional" }, /* opencaching.de */ | | | |
| { gt_multi, "Multi-cache" }, | | | |
| { gt_multi, "Multi" }, /* opencaching.de */ | | | |
| { gt_virtual, "Virtual Cache" }, | | | |
| { gt_virtual, "Virtual" }, /* opencaching.de */ | | | |
| { gt_event, "Event Cache" }, | | | |
| { gt_event, "Event" }, /* opencaching.de */ | | | |
| { gt_webcam, "Webcam Cache" }, | | | |
| { gt_webcam, "Webcam" }, /* opencaching.de */ | | | |
| { gt_suprise, "Unknown Cache" }, | | | |
| { gt_earth, "Earthcache" }, | | | |
| { gt_earth, "Earth" }, /* opencaching.de */ | | | |
| { gt_cito, "Cache In Trash Out Event" }, | | | |
| { gt_letterbox, "Letterbox Hybrid" }, | | | |
| { gt_locationless, "Locationless (Reverse) Cache" }, | | | |
| { gt_ape, "Project APE Cache" }, | | | |
| { gt_mega, "Mega-Event Cache" }, | | | |
| | | | |
| { gt_benchmark, "Benchmark" }, /* Not Groundspeak; for GSAK */ | | | |
| }; | | | |
| | | | |
| struct | | | |
| gs_container_mapping { | | | |
| geocache_container type; | | | |
| const char* name; | | | |
| } gs_container_map[] = { | | | |
| { gc_other, "Unknown" }, | | | |
| { gc_other, "Other" }, /* Synonym on read. */ | | | |
| { gc_micro, "Micro" }, | | | |
| { gc_regular, "Regular" }, | | | |
| { gc_large, "Large" }, | | | |
| { gc_small, "Small" }, | | | |
| { gc_virtual, "Virtual" } | | | |
| }; | | | |
| | | | |
| geocache_type | | | |
| gs_mktype(const char* t) | | | |
| { | | | |
| int i; | | | |
| int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]); | | | |
| | | | |
| for (i = 0; i < sz; i++) { | | | |
| if (0 == case_ignore_strcmp(t, gs_type_map[i].name)) { | | | |
| return gs_type_map[i].type; | | | |
| } | | | |
| } | | | |
| return gt_unknown; | | | |
| } | | | |
| | | | |
| const char* | | | |
| gs_get_cachetype(geocache_type t) | | | |
| { | | | |
| int i; | | | |
| int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]); | | | |
| | | | |
| for (i = 0; i < sz; i++) { | | | |
| if (t == gs_type_map[i].type) { | | | |
| return gs_type_map[i].name; | | | |
| } | | | |
| } | | | |
| return "Unknown"; | | | |
| } | | | |
| | | | |
| geocache_container | | | |
| gs_mkcont(const char* t) | | | |
| { | | | |
| int i; | | | |
| int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]); | | | |
| | | | |
| for (i = 0; i < sz; i++) { | | | |
| if (0 == case_ignore_strcmp(t, gs_container_map[i].name)) { | | | |
| return gs_container_map[i].type; | | | |
| } | | | |
| } | | | |
| return gc_unknown; | | | |
| } | | | |
| | | | |
| const char* | | | |
| gs_get_container(geocache_container t) | | | |
| { | | | |
| int i; | | | |
| int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]); | | | |
| | | | |
| for (i = 0; i < sz; i++) { | | | |
| if (t == gs_container_map[i].type) { | | | |
| return gs_container_map[i].name; | | | |
| } | | | |
| } | | | |
| return "Unknown"; | | | |
| } | | | |
| | | | |
| time_t | | | |
| xml_parse_time(const char* cdatastr, int* microsecs) | | | |
| { | | | |
| int off_hr = 0; | | | |
| int off_min = 0; | | | |
| int off_sign = 1; | | | |
| char* offsetstr = NULL; | | | |
| char* pointstr = NULL; | | | |
| struct tm tm; | | | |
| time_t rv = 0; | | | |
| char* timestr = xstrdup(cdatastr); | | | |
| | | | |
| memset(&tm, 0, sizeof(tm)); | | | |
| | | | |
| offsetstr = strchr(timestr, 'Z'); | | | |
| if (offsetstr) { | | | |
| /* zulu time; offsets stay at defaults */ | | | |
| *offsetstr = '\0'; | | | |
| } else { | | | |
| offsetstr = strchr(timestr, '+'); | | | |
| if (offsetstr) { | | | |
| /* positive offset; parse it */ | | | |
| *offsetstr = '\0'; | | | |
| sscanf(offsetstr+1, "%d:%d", &off_hr, &off_min); | | | |
| } else { | | | |
| offsetstr = strchr(timestr, 'T'); | | | |
| if (offsetstr) { | | | |
| offsetstr = strchr(offsetstr, '-'); | | | |
| if (offsetstr) { | | | |
| /* negative offset; parse it */ | | | |
| *offsetstr = '\0'; | | | |
| sscanf(offsetstr+1, "%d:%d", | | | |
| &off_hr, &off_min); | | | |
| off_sign = -1; | | | |
| } | | | |
| } | | | |
| } | | | |
| } | | | |
| | | | |
| pointstr = strchr(timestr, '.'); | | | |
| if (pointstr) { | | | |
| if (microsecs) { | | | |
| double fsec; | | | |
| sscanf(pointstr, "%le", &fsec); | | | |
| /* Round to avoid FP jitter */ | | | |
| *microsecs = .5 + (fsec * 1000000.0) ; | | | |
| } | | | |
| *pointstr = '\0'; | | | |
| } | | | |
| | | | |
| sscanf(timestr, "%d-%d-%dT%d:%d:%d", | | | |
| &tm.tm_year, | | | |
| &tm.tm_mon, | | | |
| &tm.tm_mday, | | | |
| &tm.tm_hour, | | | |
| &tm.tm_min, | | | |
| &tm.tm_sec); | | | |
| tm.tm_mon -= 1; | | | |
| tm.tm_year -= 1900; | | | |
| tm.tm_isdst = 0; | | | |
| | | | |
| rv = mkgmtime(&tm) - off_sign*off_hr*3600 - off_sign*off_min*60; | | | |
| | | | |
| xfree(timestr); | | | |
| | | | |
| return rv; | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_end(void* data, const XML_Char* xml_el) | | | |
| { | | | |
| const char* el = xml_convert_to_char_string(xml_el); | | | |
| char* s = strrchr(current_tag.mem, '/'); | | | |
| float x; | | | |
| char* cdatastrp = cdatastr.mem; | | | |
| int passthrough; | | | |
| static time_t gc_log_date; | | | |
| tag_type tag; | | | |
| | | | |
| if (strcmp(s + 1, el)) { | | | |
| fprintf(stderr, "Mismatched tag %s\n", el); | | | |
| } | | | |
| | | | |
| tag = get_tag(current_tag.mem, &passthrough); | | | |
| switch (tag) { | | | |
| /* | | | |
| * First, the tags that are file-global. | | | |
| */ | | | |
| case tt_name: | | | |
| gpx_add_to_global(&gpx_global->name, cdatastrp); | | | |
| break; | | | |
| case tt_desc: | | | |
| gpx_add_to_global(&gpx_global->desc, cdatastrp); | | | |
| break; | | | |
| case tt_author: | | | |
| gpx_add_to_global(&gpx_global->author, cdatastrp); | | | |
| break; | | | |
| case tt_email: | | | |
| gpx_add_to_global(&gpx_global->email, cdatastrp); | | | |
| if (gpx_email == NULL) { | | | |
| gpx_email = xstrdup(cdatastrp); | | | |
| } | | | |
| break; | | | |
| case tt_url: | | | |
| gpx_add_to_global(&gpx_global->url, cdatastrp); | | | |
| break; | | | |
| case tt_urlname: | | | |
| gpx_add_to_global(&gpx_global->urlname, cdatastrp); | | | |
| break; | | | |
| case tt_keywords: | | | |
| gpx_add_to_global(&gpx_global->keywords, cdatastrp); | | | |
| break; | | | |
| | | | |
| /* | | | |
| * Waypoint-specific tags. | | | |
| */ | | | |
| case tt_wpt: | | | |
| waypt_add(wpt_tmp); | | | |
| logpoint_ct = 0; | | | |
| cur_tag = NULL; | | | |
| wpt_tmp = NULL; | | | |
| break; | | | |
| case tt_cache_name: | | | |
| if (wpt_tmp->notes != NULL) { | | | |
| xfree(wpt_tmp->notes); | | | |
| } | | | |
| wpt_tmp->notes = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_cache_container: | | | |
| wpt_tmp->gc_data.container = gs_mkcont(cdatastrp); | | | |
| break; | | | |
| case tt_cache_type: | | | |
| wpt_tmp->gc_data.type = gs_mktype(cdatastrp); | | | |
| break; | | | |
| case tt_cache_difficulty: | | | |
| sscanf(cdatastrp, "%f", &x); | | | |
| wpt_tmp->gc_data.diff = x * 10; | | | |
| break; | | | |
| case tt_cache_hint: | | | |
| rtrim(cdatastrp); | | | |
| if (cdatastrp[0]) { | | | |
| wpt_tmp->gc_data.hint = xstrdup(cdatastrp); | | | |
| } | | | |
| break; | | | |
| case tt_cache_desc_long: | | | |
| rtrim(cdatastrp); | | | |
| if (cdatastrp[0]) { | | | |
| wpt_tmp->gc_data.desc_long.is_html = cache_descr_is_html; | | | |
| wpt_tmp->gc_data.desc_long.utfstring = xstrdup(cdatastrp); | | | |
| } | | | |
| break; | | | |
| case tt_cache_desc_short: | | | |
| rtrim(cdatastrp); | | | |
| if (cdatastrp[0]) { | | | |
| wpt_tmp->gc_data.desc_short.is_html = cache_descr_is_html; | | | |
| wpt_tmp->gc_data.desc_short.utfstring = xstrdup(cdatastrp); | | | |
| } | | | |
| break; | | | |
| case tt_cache_terrain: | | | |
| sscanf(cdatastrp, "%f", &x); | | | |
| wpt_tmp->gc_data.terr = x * 10; | | | |
| break; | | | |
| case tt_cache_placer: | | | |
| wpt_tmp->gc_data.placer = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_cache_log_date: | | | |
| gc_log_date = xml_parse_time(cdatastrp, NULL); | | | |
| break; | | | |
| /* | | | |
| * "Found it" logs follow the date according to the schema, | | | |
| * if this is the first "found it" for this waypt, just use the | | | |
| * last date we saw in this log. | | | |
| */ | | | |
| case tt_cache_log_type: | | | |
| if ((0 == strcmp(cdatastrp, "Found it")) && | | | |
| (0 == wpt_tmp->gc_data.last_found)) { | | | |
| wpt_tmp->gc_data.last_found = gc_log_date; | | | |
| } | | | |
| gc_log_date = 0; | | | |
| break; | | | |
| | | | |
| /* | | | |
| * Garmin-waypoint-specific tags. | | | |
| */ | | | |
| case tt_garmin_wpt_proximity: | | | |
| case tt_garmin_wpt_temperature: | | | |
| case tt_garmin_wpt_depth: | | | |
| case tt_garmin_wpt_display_mode: | | | |
| case tt_garmin_wpt_category: | | | |
| case tt_garmin_wpt_addr: | | | |
| case tt_garmin_wpt_city: | | | |
| case tt_garmin_wpt_state: | | | |
| case tt_garmin_wpt_country: | | | |
| case tt_garmin_wpt_postal_code: | | | |
| case tt_garmin_wpt_phone_nr: | | | |
| garmin_fs_xml_convert(tt_garmin_wpt_extensions, tag, cdatastrp, wpt_tmp | | | |
| ); | | | |
| break; | | | |
| | | | |
| /* | | | |
| * Route-specific tags. | | | |
| */ | | | |
| case tt_rte_name: | | | |
| rte_head->rte_name = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_rte: | | | |
| break; | | | |
| case tt_rte_rtept: | | | |
| route_add_wpt(rte_head, wpt_tmp); | | | |
| wpt_tmp = NULL; | | | |
| break; | | | |
| case tt_rte_desc: | | | |
| rte_head->rte_desc = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_rte_number: | | | |
| rte_head->rte_num = atoi(cdatastrp); | | | |
| break; | | | |
| /* | | | |
| * Track-specific tags. | | | |
| */ | | | |
| case tt_trk_name: | | | |
| trk_head->rte_name = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_trk: | | | |
| break; | | | |
| case tt_trk_trkseg_trkpt: | | | |
| track_add_wpt(trk_head, wpt_tmp); | | | |
| wpt_tmp = NULL; | | | |
| break; | | | |
| case tt_trk_desc: | | | |
| trk_head->rte_desc = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_trk_number: | | | |
| trk_head->rte_num = atoi(cdatastrp); | | | |
| break; | | | |
| case tt_trk_trkseg_trkpt_course: | | | |
| WAYPT_SET(wpt_tmp, course, atof(cdatastrp)); | | | |
| break; | | | |
| case tt_trk_trkseg_trkpt_speed: | | | |
| WAYPT_SET(wpt_tmp, speed, atof(cdatastrp)); | | | |
| break; | | | |
| | | | |
| /* | | | |
| * Items that are actually in multiple categories. | | | |
| */ | | | |
| case tt_wpt_ele: | | | |
| case tt_rte_rtept_ele: | | | |
| case tt_trk_trkseg_trkpt_ele: | | | |
| sscanf(cdatastrp, "%lf", &wpt_tmp->altitude); | | | |
| break; | | | |
| case tt_wpt_name: | | | |
| case tt_rte_rtept_name: | | | |
| case tt_trk_trkseg_trkpt_name: | | | |
| wpt_tmp->shortname = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_wpt_sym: | | | |
| case tt_rte_rtept_sym: | | | |
| case tt_trk_trkseg_trkpt_sym: | | | |
| wpt_tmp->icon_descr = xstrdup(cdatastrp); | | | |
| wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1; | | | |
| break; | | | |
| case tt_wpt_time: | | | |
| case tt_trk_trkseg_trkpt_time: | | | |
| case tt_rte_rtept_time: | | | |
| wpt_tmp->creation_time = xml_parse_time(cdatastrp, &wpt_tmp->microsecon | | | |
| ds); | | | |
| break; | | | |
| case tt_wpt_cmt: | | | |
| case tt_rte_rtept_cmt: | | | |
| case tt_trk_trkseg_trkpt_cmt: | | | |
| wpt_tmp->description = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_wpt_desc: | | | |
| case tt_trk_trkseg_trkpt_desc: | | | |
| case tt_rte_rtept_desc: | | | |
| if (wpt_tmp->notes != NULL) { | | | |
| xfree(wpt_tmp->notes); | | | |
| } | | | |
| wpt_tmp->notes = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_pdop: | | | |
| wpt_tmp->pdop = atof(cdatastrp); | | | |
| break; | | | |
| case tt_hdop: | | | |
| wpt_tmp->hdop = atof(cdatastrp); | | | |
| break; | | | |
| case tt_vdop: | | | |
| wpt_tmp->vdop = atof(cdatastrp); | | | |
| break; | | | |
| case tt_sat: | | | |
| wpt_tmp->sat = atof(cdatastrp); | | | |
| break; | | | |
| case tt_fix: | | | |
| wpt_tmp->fix = atoi(cdatastrp)-1; | | | |
| if (wpt_tmp->fix < fix_2d) { | | | |
| if (!case_ignore_strcmp(cdatastrp, "none")) { | | | |
| wpt_tmp->fix = fix_none; | | | |
| } else if (!case_ignore_strcmp(cdatastrp, "dgps")) { | | | |
| wpt_tmp->fix = fix_dgps; | | | |
| } else if (!case_ignore_strcmp(cdatastrp, "pps")) { | | | |
| wpt_tmp->fix = fix_pps; | | | |
| } else { | | | |
| wpt_tmp->fix = fix_unknown; | | | |
| } | | | |
| } | | | |
| break; | | | |
| case tt_wpt_url: | | | |
| case tt_trk_trkseg_trkpt_url: | | | |
| case tt_rte_rtept_url: | | | |
| wpt_tmp->url = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_wpt_urlname: | | | |
| case tt_trk_trkseg_trkpt_urlname: | | | |
| case tt_rte_rtept_urlname: | | | |
| wpt_tmp->url_link_text = xstrdup(cdatastrp); | | | |
| break; | | | |
| case tt_wpt_link: | | | |
| //TODO: implement GPX 1.1 case tt_trk_trkseg_trkpt_link: | | | |
| //TODO: implement GPX 1.1 case tt_rte_rtept_link: | | | |
| { | | | |
| char* lt = link_text; | | | |
| if (lt) { | | | |
| lt = xstrdup(lrtrim(link_text)); | | | |
| } | | | |
| | | | |
| waypt_add_url(wpt_tmp, xstrdup(link_url), lt); | | | |
| link_text = NULL; | | | |
| } | | | |
| break; | | | |
| case tt_unknown: | | | |
| end_something_else(); | | | |
| *s = 0; | | | |
| return; | | | |
| default: | | | |
| break; | | | |
| } | | | |
| | | | |
| if (passthrough) { | | | |
| end_something_else(); | | | |
| } | | | |
| | | | |
| *s = 0; | | | |
| xml_free_converted_string(el); | | | |
| } | | | |
| | | | |
| #if ! HAVE_LIBEXPAT | | | |
| static void | | | |
| gpx_rd_init(const char* fname) | | | |
| { | | | |
| fatal(MYNAME ": This build excluded GPX support because expat was not ins | | | |
| talled.\n"); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_rd_deinit(void) | | | |
| { | | | |
| } | | | |
| | | | |
| #else /* NO_EXPAT */ | | | |
| | | | |
| static void | | | |
| gpx_cdata(void* dta, const XML_Char* xml_el, int len) | | | |
| { | | | |
| char* estr; | | | |
| int* cdatalen; | | | |
| char** cdata; | | | |
| xml_tag* tmp_tag; | | | |
| size_t slen = strlen(cdatastr.mem); | | | |
| const char* s = xml_convert_to_char_string_n(xml_el, &len); | | | |
| | | | |
| vmem_realloc(&cdatastr, 1 + len + slen); | | | |
| estr = ((char*) cdatastr.mem) + slen; | | | |
| memcpy(estr, s, len); | | | |
| estr[len] = 0; | | | |
| | | | |
| if (!cur_tag) { | | | |
| return; | | | |
| } | | | |
| | | | |
| if (cur_tag->child) { | | | |
| tmp_tag = cur_tag->child; | | | |
| while (tmp_tag->sibling) { | | | |
| tmp_tag = tmp_tag->sibling; | | | |
| } | | | |
| cdata = &(tmp_tag->parentcdata); | | | |
| cdatalen = &(tmp_tag->parentcdatalen); | | | |
| } else { | | | |
| cdata = &(cur_tag->cdata); | | | |
| cdatalen = &(cur_tag->cdatalen); | | | |
| } | | | |
| estr = *cdata; | | | |
| *cdata = xcalloc(*cdatalen + len + 1, 1); | | | |
| if (estr) { | | | |
| memcpy(*cdata, estr, *cdatalen); | | | |
| xfree(estr); | | | |
| } | | | |
| estr = *cdata + *cdatalen; | | | |
| memcpy(estr, s, len); | | | |
| *(estr+len) = '\0'; | | | |
| *cdatalen += len; | | | |
| | | | |
| xml_free_converted_string(s); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_rd_init(const char* fname) | | | |
| { | | | |
| if (fname[0]) { | | | |
| fd = gbfopen(fname, "r", MYNAME); | | | |
| input_fname = fname; | | | |
| } else { | | | |
| fd = NULL; | | | |
| input_string = fname+1; | | | |
| input_string_len = strlen(input_string); | | | |
| input_fname = NULL; | | | |
| } | | | |
| | | | |
| file_time = 0; | | | |
| current_tag = vmem_alloc(1, 0); | | | |
| *((char*)current_tag.mem) = '\0'; | | | |
| | | | |
| prescan_tags(); | | | |
| | | | |
| psr = XML_ParserCreate(NULL); | | | |
| if (!psr) { | | | |
| fatal(MYNAME ": Cannot create XML Parser\n"); | | | |
| } | | | |
| XML_SetUnknownEncodingHandler(psr, cet_lib_expat_UnknownEncodingHandler, | | | |
| NULL); | | | |
| | | | |
| cdatastr = vmem_alloc(1, 0); | | | |
| *((char*)cdatastr.mem) = '\0'; | | | |
| | | | |
| if (!xsi_schema_loc) { | | | |
| xsi_schema_loc = xstrdup(DEFAULT_XSI_SCHEMA_LOC); | | | |
| } | | | |
| if (!xsi_schema_loc) { | | | |
| fatal("gpx: Unable to allocate %ld bytes of memory.\n", | | | |
| (unsigned long) strlen(DEFAULT_XSI_SCHEMA_LOC) + 1); | | | |
| } | | | |
| | | | |
| if (NULL == gpx_global) { | | | |
| gpx_global = xcalloc(sizeof(*gpx_global), 1); | | | |
| QUEUE_INIT(&gpx_global->name.queue); | | | |
| QUEUE_INIT(&gpx_global->desc.queue); | | | |
| QUEUE_INIT(&gpx_global->author.queue); | | | |
| QUEUE_INIT(&gpx_global->email.queue); | | | |
| QUEUE_INIT(&gpx_global->url.queue); | | | |
| QUEUE_INIT(&gpx_global->urlname.queue); | | | |
| QUEUE_INIT(&gpx_global->keywords.queue); | | | |
| } | | | |
| | | | |
| XML_SetElementHandler(psr, gpx_start, gpx_end); | | | |
| XML_SetCharacterDataHandler(psr, gpx_cdata); | | | |
| fs_ptr = NULL; | | | |
| } | | | |
| | | | |
| static | | | |
| void | | | |
| gpx_rd_deinit(void) | | | |
| { | | | |
| vmem_free(¤t_tag); | | | |
| vmem_free(&cdatastr); | | | |
| /* | | | |
| * Don't free schema_loc. It really is important that we preserve | | | |
| * this across reads or else merges/copies of files with different | | | |
| * schemas won't retain the headers. | | | |
| * | | | |
| * moved to gpx_exit | | | |
| | | | |
| if ( xsi_schema_loc ) { | | | |
| xfree(xsi_schema_loc); | | | |
| xsi_schema_loc = NULL; | | | |
| } | | | |
| */ | | | |
| | | | |
| if (gpx_email) { | | | |
| xfree(gpx_email); | | | |
| gpx_email = NULL; | | | |
| } | | | |
| if (gpx_author) { | | | |
| xfree(gpx_author); | | | |
| gpx_author = NULL; | | | |
| } | | | |
| if (fd) { | | | |
| gbfclose(fd); | | | |
| } | | | |
| XML_ParserFree(psr); | | | |
| psr = NULL; | | | |
| wpt_tmp = NULL; | | | |
| cur_tag = NULL; | | | |
| input_fname = NULL; | | | |
| } | | | |
| #endif | | | |
| | | | |
| static void | | | |
| gpx_wr_init(const char* fname) | | | |
| { | | | |
| mkshort_handle = mkshort_new_handle(); | | | |
| | | | |
| ofd = gbfopen(fname, "w", MYNAME); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_wr_deinit(void) | | | |
| { | | | |
| gbfclose(ofd); | | | |
| mkshort_del_handle(&mkshort_handle); | | | |
| } | | | |
| | | | |
| void | | | |
| gpx_read(void) | | | |
| { | | | |
| #if HAVE_LIBEXPAT | | | |
| int len; | | | |
| int done = 0; | | | |
| char* buf = xmalloc(MY_CBUF_SZ); | | | |
| int result = 0; | | | |
| int extra; | | | |
| | | | |
| while (!done) { | | | |
| if (fd) { | | | |
| /* | | | |
| * The majority of this block (in fact, all but the | | | |
| * call to XML_Parse) are a disgusting hack to | | | |
| * correct defective GPX files that Geocaching.com | | | |
| * issues as pocket queries. They contain escape | | | |
| * characters as entities (�-) which makes | | | |
| * them not validate which croaks expat and torments | | | |
| * users. | | | |
| * | | | |
| * Look for '&' in the last maxentlength chars. If | | | |
| * we find it, strip it, then read byte-at-a-time | | | |
| * until we find a non-entity. | | | |
| */ | | | |
| char* badchar; | | | |
| char* semi; | | | |
| int maxentlength = 8; | | | |
| len = gbfread(buf, 1, MY_CBUF_SZ - maxentlength, fd); | | | |
| done = gbfeof(fd) || !len; | | | |
| buf[len] = '\0'; | | | |
| if (len < maxentlength) { | | | |
| maxentlength = len; | | | |
| } | | | |
| badchar = buf+len-maxentlength; | | | |
| badchar = strchr(badchar, '&'); | | | |
| extra = maxentlength - 1; /* for terminator */ | | | |
| while (badchar && len < MY_CBUF_SZ-1) { | | | |
| semi = strchr(badchar, ';'); | | | |
| while (extra && !semi) { | | | |
| len += gbfread(buf+len, 1, 1, fd); | | | |
| buf[len]='\0'; | | | |
| extra--; | | | |
| if (buf[len-1] == ';') { | | | |
| semi= buf+len-1; | | | |
| } | | | |
| } | | | |
| badchar = strchr(badchar+1, '&'); | | | |
| } | | | |
| { | | | |
| char* hex="0123456789abcdef"; | | | |
| badchar = strstr(buf, "&#x"); | | | |
| while (badchar) { | | | |
| int val = 0; | | | |
| char* hexit = badchar+3; | | | |
| semi = strchr(badchar, ';'); | | | |
| if (semi) { | | | |
| while (*hexit && *hexit != ';') { | | | |
| char hc = isalpha(*hexit) ? tolower(*hexit) : *hexit; | | | |
| val *= 16; | | | |
| val += strchr(hex, hc)-hex; | | | |
| hexit++; | | | |
| } | | | |
| | | | |
| if (val < 32) { | | | |
| warning(MYNAME ": Ignoring illegal character %s;\n\tConsider | | | |
| emailing %s at <%s>\n\tabout illegal characters in their GPX files.\n", bad | | | |
| char, gpx_author?gpx_author:"(unknown author)", gpx_email?gpx_email:"(unkno | | | |
| wn email address)"); | | | |
| memmove(badchar, semi+1, strlen(semi+1)+1); | | | |
| len -= (semi-badchar)+1; | | | |
| badchar--; | | | |
| } | | | |
| } | | | |
| badchar = strstr(badchar+1, "&#x"); | | | |
| } | | | |
| } | | | |
| result = XML_Parse(psr, buf, len, done); | | | |
| } else if (input_string) { | | | |
| done = 0; | | | |
| result = XML_Parse(psr, input_string, | | | |
| input_string_len, done); | | | |
| done = 1; | | | |
| } else { | | | |
| done = 1; | | | |
| result = -1; | | | |
| } | | | |
| if (!result) { | | | |
| fatal(MYNAME ": XML parse error at line %d of '%s' : %s\n", | | | |
| (int) XML_GetCurrentLineNumber(psr), | | | |
| input_fname ? input_fname : "unknown file", | | | |
| XML_ErrorString(XML_GetErrorCode(psr))); | | | |
| } | | | |
| } | | | |
| xfree(buf); | | | |
| #endif /* HAVE_LIBEXPAT */ | | | |
| } | | | |
| | | | |
| static void | | | |
| fprint_tag_and_attrs(char* prefix, char* suffix, xml_tag* tag) | | | |
| { | | | |
| char** pa; | | | |
| gbfprintf(ofd, "%s%s", prefix, tag->tagname); | | | |
| pa = tag->attributes; | | | |
| if (pa) { | | | |
| while (*pa) { | | | |
| gbfprintf(ofd, " %s=\"%s\"", pa[0], pa[1]); | | | |
| pa += 2; | | | |
| } | | | |
| } | | | |
| gbfprintf(ofd, "%s", suffix); | | | |
| } | | | |
| | | | |
| static void | | | |
| fprint_xml_chain(xml_tag* tag, const waypoint* wpt) | | | |
| { | | | |
| char* tmp_ent; | | | |
| while (tag) { | | | |
| if (!tag->cdata && !tag->child) { | | | |
| fprint_tag_and_attrs("<", " />", tag); | | | |
| } else { | | | |
| fprint_tag_and_attrs("<", ">", tag); | | | |
| | | | |
| if (tag->cdata) { | | | |
| tmp_ent = xml_entitize(tag->cdata); | | | |
| gbfprintf(ofd, "%s", tmp_ent); | | | |
| xfree(tmp_ent); | | | |
| } | | | |
| if (tag->child) { | | | |
| fprint_xml_chain(tag->child, wpt); | | | |
| } | | | |
| if (wpt && wpt->gc_data.exported && | | | |
| strcmp(tag->tagname, "groundspeak:cache") == 0) { | | | |
| xml_write_time(ofd, wpt->gc_data.exported, 0, | | | |
| "groundspeak:exported"); | | | |
| } | | | |
| gbfprintf(ofd, "</%s>\n", tag->tagname); | | | |
| } | | | |
| if (tag->parentcdata) { | | | |
| tmp_ent = xml_entitize(tag->parentcdata); | | | |
| gbfprintf(ofd, "%s", tmp_ent); | | | |
| xfree(tmp_ent); | | | |
| } | | | |
| tag = tag->sibling; | | | |
| } | | | |
| } | | | |
| | | | |
| void free_gpx_extras(xml_tag* tag) | | | |
| { | | | |
| xml_tag* next = NULL; | | | |
| char** ap; | | | |
| | | | |
| while (tag) { | | | |
| if (tag->cdata) { | | | |
| xfree(tag->cdata); | | | |
| } | | | |
| if (tag->child) { | | | |
| free_gpx_extras(tag->child); | | | |
| } | | | |
| if (tag->parentcdata) { | | | |
| xfree(tag->parentcdata); | | | |
| } | | | |
| if (tag->tagname) { | | | |
| xfree(tag->tagname); | | | |
| } | | | |
| if (tag->attributes) { | | | |
| ap = tag->attributes; | | | |
| | | | |
| while (*ap) { | | | |
| xfree(*ap++); | | | |
| } | | | |
| | | | |
| xfree(tag->attributes); | | | |
| } | | | |
| | | | |
| next = tag->sibling; | | | |
| xfree(tag); | | | |
| tag = next; | | | |
| } | | | |
| } | | | |
| | | | |
| /* | | | |
| * Handle the grossness of GPX 1.0 vs. 1.1 handling of linky links. | | | |
| */ | | | |
| static void | | | |
| write_gpx_url(const waypoint* waypointp) | | | |
| { | | | |
| char* tmp_ent; | | | |
| | | | |
| if (waypointp->url == NULL) { | | | |
| return; | | | |
| } | | | |
| | | | |
| if (gpx_wversion_num > 10) { | | | |
| url_link* tail; | | | |
| for (tail = (url_link*)&waypointp->url_next; tail; tail = tail->url_nex | | | |
| t) { | | | |
| tmp_ent = xml_entitize(tail->url); | | | |
| gbfprintf(ofd, " <link href=\"%s%s\">\n", | | | |
| urlbase ? urlbase : "", tmp_ent); | | | |
| write_optional_xml_entity(ofd, " ", "text", | | | |
| tail->url_link_text); | | | |
| gbfprintf(ofd, " </link>\n"); | | | |
| xfree(tmp_ent); | | | |
| } | | | |
| } else { | | | |
| tmp_ent = xml_entitize(waypointp->url); | | | |
| gbfprintf(ofd, " <url>%s%s</url>\n", | | | |
| urlbase ? urlbase : "", tmp_ent); | | | |
| write_optional_xml_entity(ofd, " ", "urlname", | | | |
| waypointp->url_link_text); | | | |
| xfree(tmp_ent); | | | |
| } | | | |
| } | | | |
| | | | |
| /* | | | |
| * Write optional accuracy information for a given (way|track|route)point | | | |
| * to the output stream. Done in one place since it's common for all three | | | |
| . | | | |
| * Order counts. | | | |
| */ | | | |
| static void | | | |
| gpx_write_common_acc(const waypoint* waypointp, const char* indent) | | | |
| { | | | |
| char* fix = NULL; | | | |
| | | | |
| switch (waypointp->fix) { | | | |
| case fix_2d: | | | |
| fix = "2d"; | | | |
| break; | | | |
| case fix_3d: | | | |
| fix = "3d"; | | | |
| break; | | | |
| case fix_dgps: | | | |
| fix = "dgps"; | | | |
| break; | | | |
| case fix_pps: | | | |
| fix = "pps"; | | | |
| break; | | | |
| case fix_none: | | | |
| fix = "none"; | | | |
| break; | | | |
| /* GPX spec says omit if we don't know. */ | | | |
| case fix_unknown: | | | |
| default: | | | |
| break; | | | |
| } | | | |
| if (fix) { | | | |
| gbfprintf(ofd, "%s<fix>%s</fix>\n", indent, fix); | | | |
| } | | | |
| if (waypointp->sat > 0) { | | | |
| gbfprintf(ofd, "%s<sat>%d</sat>\n", indent, waypointp->sat); | | | |
| } | | | |
| if (waypointp->hdop) { | | | |
| gbfprintf(ofd, "%s<hdop>%f</hdop>\n", indent, waypointp->hdop); | | | |
| } | | | |
| if (waypointp->vdop) { | | | |
| gbfprintf(ofd, "%s<vdop>%f</vdop>\n", indent, waypointp->vdop); | | | |
| } | | | |
| if (waypointp->pdop) { | | | |
| gbfprintf(ofd, "%s<pdop>%f</pdop>\n", indent, waypointp->pdop); | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_write_common_position(const waypoint* waypointp, const char* indent) | | | |
| { | | | |
| if (waypointp->altitude != unknown_alt) { | | | |
| gbfprintf(ofd, "%s<ele>%f</ele>\n", | | | |
| indent, waypointp->altitude); | | | |
| } | | | |
| if (waypointp->creation_time) { | | | |
| xml_write_time(ofd, waypointp->creation_time, waypointp->microseconds, | | | |
| "time"); | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_write_common_description(const waypoint* waypointp, const char* indent, | | | |
| const char* oname) | | | |
| { | | | |
| write_optional_xml_entity(ofd, indent, "name", oname); | | | |
| write_optional_xml_entity(ofd, indent, "cmt", waypointp->description); | | | |
| if (waypointp->notes && waypointp->notes[0]) { | | | |
| write_xml_entity(ofd, indent, "desc", waypointp->notes); | | | |
| } else { | | | |
| write_optional_xml_entity(ofd, indent, "desc", waypointp->description); | | | |
| } | | | |
| write_gpx_url(waypointp); | | | |
| write_optional_xml_entity(ofd, indent , "sym", waypointp->icon_descr); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_waypt_pr(const waypoint* waypointp) | | | |
| { | | | |
| const char* oname; | | | |
| char* odesc; | | | |
| fs_xml* fs_gpx; | | | |
| garmin_fs_t* gmsd; /* gARmIN sPECIAL dATA */ | | | |
| | | | |
| /* | | | |
| * Desparation time, try very hard to get a good shortname | | | |
| */ | | | |
| odesc = waypointp->notes; | | | |
| if (!odesc) { | | | |
| odesc = waypointp->description; | | | |
| } | | | |
| if (!odesc) { | | | |
| odesc = waypointp->shortname; | | | |
| } | | | |
| | | | |
| oname = global_opts.synthesize_shortnames ? | | | |
| mkshort(mkshort_handle, odesc) : | | | |
| waypointp->shortname; | | | |
| | | | |
| gbfprintf(ofd, "<wpt lat=\"" FLT_FMT "\" lon=\"" FLT_FMT "\">\n", | | | |
| waypointp->latitude, | | | |
| waypointp->longitude); | | | |
| | | | |
| gpx_write_common_position(waypointp, " "); | | | |
| gpx_write_common_description(waypointp, " ", oname); | | | |
| gpx_write_common_acc(waypointp, " "); | | | |
| | | | |
| fs_gpx = (fs_xml*)fs_chain_find(waypointp->fs, FS_GPX); | | | |
| gmsd = GMSD_FIND(waypointp); | | | |
| if (fs_gpx) { | | | |
| if (! gmsd) { | | | |
| fprint_xml_chain(fs_gpx->tag, waypointp); | | | |
| } | | | |
| } | | | |
| if (gmsd && (gpx_wversion_num > 10)) { | | | |
| /* MapSource doesn't accepts extensions from 1.0 */ | | | |
| garmin_fs_xml_fprint(ofd, waypointp); | | | |
| } | | | |
| gbfprintf(ofd, "</wpt>\n"); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_track_hdr(const route_head* rte) | | | |
| { | | | |
| fs_xml* fs_gpx; | | | |
| | | | |
| gbfprintf(ofd, "<trk>\n"); | | | |
| write_optional_xml_entity(ofd, " ", "name", rte->rte_name); | | | |
| write_optional_xml_entity(ofd, " ", "desc", rte->rte_desc); | | | |
| if (rte->rte_num) { | | | |
| gbfprintf(ofd, "<number>%d</number>\n", rte->rte_num); | | | |
| } | | | |
| gbfprintf(ofd, "<trkseg>\n"); | | | |
| | | | |
| fs_gpx = (fs_xml*)fs_chain_find(rte->fs, FS_GPX); | | | |
| if (fs_gpx) { | | | |
| fprint_xml_chain(fs_gpx->tag, NULL); | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_track_disp(const waypoint* waypointp) | | | |
| { | | | |
| fs_xml* fs_gpx; | | | |
| | | | |
| gbfprintf(ofd, "<trkpt lat=\"" FLT_FMT_T "\" lon=\"" FLT_FMT_T "\">\n", | | | |
| waypointp->latitude, | | | |
| waypointp->longitude); | | | |
| | | | |
| gpx_write_common_position(waypointp, " "); | | | |
| | | | |
| /* These were accidentally removed from 1.1 */ | | | |
| if (gpx_wversion_num == 10) { | | | |
| if WAYPT_HAS(waypointp, course) { | | | |
| gbfprintf(ofd, " <course>%f</course>\n", | | | |
| waypointp->course); | | | |
| } | | | |
| if WAYPT_HAS(waypointp, speed) { | | | |
| gbfprintf(ofd, " <speed>%f</speed>\n", | | | |
| waypointp->speed); | | | |
| } | | | |
| } | | | |
| | | | |
| /* GPX doesn't require a name on output, so if we made one up | | | |
| * on input, we might as well say nothing. | | | |
| */ | | | |
| gpx_write_common_description(waypointp, " ", | | | |
| waypointp->wpt_flags.shortname_is_synthetic | | | |
| ? | | | |
| NULL : waypointp->shortname); | | | |
| gpx_write_common_acc(waypointp, " "); | | | |
| | | | |
| fs_gpx = (fs_xml*)fs_chain_find(waypointp->fs, FS_GPX); | | | |
| if (fs_gpx) { | | | |
| fprint_xml_chain(fs_gpx->tag, waypointp); | | | |
| } | | | |
| | | | |
| gbfprintf(ofd, "</trkpt>\n"); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_track_tlr(const route_head* rte) | | | |
| { | | | |
| gbfprintf(ofd, "</trkseg>\n"); | | | |
| gbfprintf(ofd, "</trk>\n"); | | | |
| } | | | |
| | | | |
| static | | | |
| void gpx_track_pr() | | | |
| { | | | |
| track_disp_all(gpx_track_hdr, gpx_track_tlr, gpx_track_disp); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_route_hdr(const route_head* rte) | | | |
| { | | | |
| fs_xml* fs_gpx; | | | |
| | | | |
| gbfprintf(ofd, "<rte>\n"); | | | |
| write_optional_xml_entity(ofd, " ", "name", rte->rte_name); | | | |
| write_optional_xml_entity(ofd, " ", "desc", rte->rte_desc); | | | |
| if (rte->rte_num) { | | | |
| gbfprintf(ofd, " <number>%d</number>\n", rte->rte_num); | | | |
| } | | | |
| | | | |
| fs_gpx = (fs_xml*)fs_chain_find(rte->fs, FS_GPX); | | | |
| if (fs_gpx) { | | | |
| fprint_xml_chain(fs_gpx->tag, NULL); | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_route_disp(const waypoint* waypointp) | | | |
| { | | | |
| fs_xml* fs_gpx; | | | |
| | | | |
| gbfprintf(ofd, " <rtept lat=\"" FLT_FMT_R "\" lon=\"" FLT_FMT_R "\">\n", | | | |
| waypointp->latitude, | | | |
| waypointp->longitude); | | | |
| | | | |
| gpx_write_common_position(waypointp, " "); | | | |
| gpx_write_common_description(waypointp, " ", waypointp->shortname); | | | |
| gpx_write_common_acc(waypointp, " "); | | | |
| | | | |
| fs_gpx = (fs_xml*)fs_chain_find(waypointp->fs, FS_GPX); | | | |
| if (fs_gpx) { | | | |
| fprint_xml_chain(fs_gpx->tag, waypointp); | | | |
| } | | | |
| | | | |
| gbfprintf(ofd, " </rtept>\n"); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_route_tlr(const route_head* rte) | | | |
| { | | | |
| gbfprintf(ofd, "</rte>\n"); | | | |
| } | | | |
| | | | |
| static | | | |
| void gpx_route_pr() | | | |
| { | | | |
| /* output routes */ | | | |
| route_disp_all(gpx_route_hdr, gpx_route_tlr, gpx_route_disp); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_waypt_bound_calc(const waypoint* waypointp) | | | |
| { | | | |
| waypt_add_to_bounds(&all_bounds, waypointp); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_write_bounds(void) | | | |
| { | | | |
| waypt_init_bounds(&all_bounds); | | | |
| | | | |
| waypt_disp_all(gpx_waypt_bound_calc); | | | |
| route_disp_all(NULL, NULL, gpx_waypt_bound_calc); | | | |
| track_disp_all(NULL, NULL, gpx_waypt_bound_calc); | | | |
| | | | |
| if (waypt_bounds_valid(&all_bounds)) { | | | |
| gbfprintf(ofd, "<bounds minlat=\"%0.9f\" minlon=\"%0.9f\" " | | | |
| "maxlat=\"%0.9f\" maxlon=\"%0.9f\"/>\n", | | | |
| all_bounds.min_lat, all_bounds.min_lon, | | | |
| all_bounds.max_lat, all_bounds.max_lon); | | | |
| } | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_write(void) | | | |
| { | | | |
| time_t now = 0; | | | |
| int short_length; | | | |
| | | | |
| gpx_wversion_num = strtod(gpx_wversion, NULL) * 10; | | | |
| | | | |
| if (gpx_wversion_num <= 0) { | | | |
| fatal(MYNAME ": gpx version number of '%s' not valid.\n", gpx_wversion) | | | |
| ; | | | |
| } | | | |
| | | | |
| now = current_time(); | | | |
| | | | |
| short_length = atoi(snlen); | | | |
| | | | |
| if (suppresswhite) { | | | |
| setshort_whitespace_ok(mkshort_handle, 0); | | | |
| } | | | |
| | | | |
| setshort_length(mkshort_handle, short_length); | | | |
| | | | |
| gbfprintf(ofd, "<?xml version=\"1.0\" encoding=\"%s\"?>\n", global_opts.c | | | |
| harset_name); | | | |
| gbfprintf(ofd, "<gpx\n version=\"%s\"\n", gpx_wversion); | | | |
| gbfprintf(ofd, "creator=\"" CREATOR_NAME_URL "\"\n"); | | | |
| gbfprintf(ofd, "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n | | | |
| "); | | | |
| gbfprintf(ofd, "xmlns=\"http://www.topografix.com/GPX/%c/%c\"\n", gpx_wve | | | |
| rsion[0], gpx_wversion[2]); | | | |
| if (xsi_schema_loc) { | | | |
| gbfprintf(ofd, "xsi:schemaLocation=\"%s\">\n", xsi_schema_loc); | | | |
| } else { | | | |
| gbfprintf(ofd, | | | |
| "xsi:schemaLocation=" DEFAULT_XSI_SCHEMA_LOC_FMT">\n", | | | |
| gpx_wversion[0], gpx_wversion[2], | | | |
| gpx_wversion[0], gpx_wversion[2]); | | | |
| } | | | |
| | | | |
| if (gpx_wversion_num > 10) { | | | |
| gbfprintf(ofd, "<metadata>\n"); | | | |
| } | | | |
| gpx_write_gdata(&gpx_global->name, "name"); | | | |
| gpx_write_gdata(&gpx_global->desc, "desc"); | | | |
| /* In GPX 1.1, author changed from a string to a PersonType. | | | |
| * since it's optional, we just drop it instead of rewriting it. | | | |
| */ | | | |
| if (gpx_wversion_num < 11) { | | | |
| gpx_write_gdata(&gpx_global->author, "author"); | | | |
| } | | | |
| gpx_write_gdata(&gpx_global->email, "email"); | | | |
| gpx_write_gdata(&gpx_global->url, "url"); | | | |
| gpx_write_gdata(&gpx_global->urlname, "urlname"); | | | |
| xml_write_time(ofd, now, 0, "time"); | | | |
| gpx_write_gdata(&gpx_global->keywords, "keywords"); | | | |
| | | | |
| gpx_write_bounds(); | | | |
| | | | |
| if (gpx_wversion_num > 10) { | | | |
| gbfprintf(ofd, "</metadata>\n"); | | | |
| } | | | |
| | | | |
| waypt_disp_all(gpx_waypt_pr); | | | |
| gpx_route_pr(); | | | |
| gpx_track_pr(); | | | |
| | | | |
| gbfprintf(ofd, "</gpx>\n"); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_free_gpx_global(void) | | | |
| { | | | |
| gpx_rm_from_global(&gpx_global->name); | | | |
| gpx_rm_from_global(&gpx_global->desc); | | | |
| gpx_rm_from_global(&gpx_global->author); | | | |
| gpx_rm_from_global(&gpx_global->email); | | | |
| gpx_rm_from_global(&gpx_global->url); | | | |
| gpx_rm_from_global(&gpx_global->urlname); | | | |
| gpx_rm_from_global(&gpx_global->keywords); | | | |
| xfree(gpx_global); | | | |
| } | | | |
| | | | |
| static void | | | |
| gpx_exit(void) | | | |
| { | | | |
| if (xsi_schema_loc) { | | | |
| xfree(xsi_schema_loc); | | | |
| xsi_schema_loc = NULL; | | | |
| } | | | |
| | | | |
| if (gpx_global) { | | | |
| gpx_free_gpx_global(); | | | |
| gpx_global = NULL; | | | |
| } | | | |
| } | | | |
| | | | |
| static | | | |
| arglist_t gpx_args[] = { | | | |
| { | | | |
| "snlen", &snlen, "Length of generated shortnames", | | | |
| "32", ARGTYPE_INT, "1", NULL | | | |
| }, | | | |
| { | | | |
| "suppresswhite", &suppresswhite, | | | |
| "No whitespace in generated shortnames", | | | |
| NULL, ARGTYPE_BOOL, ARG_NOMINMAX | | | |
| }, | | | |
| { | | | |
| "logpoint", &opt_logpoint, | | | |
| "Create waypoints from geocache log entries", | | | |
| NULL, ARGTYPE_BOOL, ARG_NOMINMAX | | | |
| }, | | | |
| { | | | |
| "urlbase", &urlbase, "Base URL for link tag in output", | | | |
| NULL, ARGTYPE_STRING, ARG_NOMINMAX | | | |
| }, | | | |
| { | | | |
| "gpxver", &gpx_wversion, "Target GPX version for output", | | | |
| "1.0", ARGTYPE_STRING, ARG_NOMINMAX | | | |
| }, | | | |
| ARG_TERMINATOR | | | |
| }; | | | |
| | | | |
| ff_vecs_t gpx_vecs = { | | | |
| ff_type_file, | | | |
| FF_CAP_RW_ALL, | | | |
| gpx_rd_init, | | | |
| gpx_wr_init, | | | |
| gpx_rd_deinit, | | | |
| gpx_wr_deinit, | | | |
| gpx_read, | | | |
| gpx_write, | | | |
| gpx_exit, | | | |
| gpx_args, | | | |
| CET_CHARSET_UTF8, 0 /* non-fixed to create non UTF-8 XML's for testing | | | | |
| CET-REVIEW */ | | | |
| }; | | | |
| #endif | | | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| trees.h | | trees.h | |
| | | | |
| skipping to change at line 73 | | skipping to change at line 73 | |
| | | | |
| local const ct_data static_dtree[D_CODES] = { | | local const ct_data static_dtree[D_CODES] = { | |
| {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, | | {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, | |
| {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, | | {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, | |
| {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, | | {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, | |
| {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, | | {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, | |
| {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, | | {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, | |
| {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} | | {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} | |
| }; | | }; | |
| | | | |
|
| const uch _dist_code[DIST_CODE_LEN] = { | | const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { | |
| 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8,
8, | | 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8,
8, | |
| 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10,
10, | | 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10,
10, | |
| 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, | | 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, | |
| 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, | | 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, | |
| 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13,
13, | | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13,
13, | |
| 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, | | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, | |
| 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, | | 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, | |
| 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, | | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, | |
| 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, | | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, | |
| 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15,
15, | | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15,
15, | |
| | | | |
| skipping to change at line 102 | | skipping to change at line 102 | |
| 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, | | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, | |
| 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, | | 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, | |
| 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, | | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, | |
| 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, | | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, | |
| 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, | | 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, | |
| 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, | | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, | |
| 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, | | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, | |
| 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 | | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 | |
| }; | | }; | |
| | | | |
|
| const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { | | const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { | |
| 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12,
12, | | 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12,
12, | |
| 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16,
16, | | 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16,
16, | |
| 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, | | 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, | |
| 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, | | 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, | |
| 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22,
22, | | 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22,
22, | |
| 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23,
23, | | 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23,
23, | |
| 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, | | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, | |
| 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, | | 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, | |
| 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, | | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, | |
| 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26,
26, | | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26,
26, | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| zlib.h | | zlib.h | |
| /* zlib.h -- interface of the 'zlib' general purpose compression library | | /* zlib.h -- interface of the 'zlib' general purpose compression library | |
|
| version 1.2.3, July 18th, 2005 | | version 1.2.8, April 28th, 2013 | |
| | | | |
|
| Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler | | Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler | |
| | | | |
| This software is provided 'as-is', without any express or implied | | This software is provided 'as-is', without any express or implied | |
| warranty. In no event will the authors be held liable for any damages | | warranty. In no event will the authors be held liable for any damages | |
| arising from the use of this software. | | arising from the use of this software. | |
| | | | |
| Permission is granted to anyone to use this software for any purpose, | | Permission is granted to anyone to use this software for any purpose, | |
| including commercial applications, and to alter it and redistribute it | | including commercial applications, and to alter it and redistribute it | |
| freely, subject to the following restrictions: | | freely, subject to the following restrictions: | |
| | | | |
| 1. The origin of this software must not be misrepresented; you must not | | 1. The origin of this software must not be misrepresented; you must not | |
| | | | |
| skipping to change at line 26 | | skipping to change at line 26 | |
| in a product, an acknowledgment in the product documentation would be | | in a product, an acknowledgment in the product documentation would be | |
| appreciated but is not required. | | appreciated but is not required. | |
| 2. Altered source versions must be plainly marked as such, and must not b
e | | 2. Altered source versions must be plainly marked as such, and must not b
e | |
| misrepresented as being the original software. | | misrepresented as being the original software. | |
| 3. This notice may not be removed or altered from any source distribution
. | | 3. This notice may not be removed or altered from any source distribution
. | |
| | | | |
| Jean-loup Gailly Mark Adler | | Jean-loup Gailly Mark Adler | |
| jloup@gzip.org madler@alumni.caltech.edu | | jloup@gzip.org madler@alumni.caltech.edu | |
| | | | |
| The data format used by the zlib library is described by RFCs (Request fo
r | | The data format used by the zlib library is described by RFCs (Request fo
r | |
|
| Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt | | Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 | |
| (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format) | | (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). | |
| . | | | |
| */ | | */ | |
| | | | |
| #ifndef ZLIB_H | | #ifndef ZLIB_H | |
| #define ZLIB_H | | #define ZLIB_H | |
| | | | |
| #include "zconf.h" | | #include "zconf.h" | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| #define ZLIB_VERSION "1.2.3.f-GPSBabel" | | #define ZLIB_VERSION "1.2.8" | |
| #define ZLIB_VERNUM 0x123f | | #define ZLIB_VERNUM 0x1280 | |
| | | #define ZLIB_VER_MAJOR 1 | |
| /* | | #define ZLIB_VER_MINOR 2 | |
| The 'zlib' compression library provides in-memory compression and | | #define ZLIB_VER_REVISION 8 | |
| decompression functions, including integrity checks of the uncompressed | | #define ZLIB_VER_SUBREVISION 0 | |
| data. This version of the library supports only one compression method | | | |
| (deflation) but other algorithms will be added later and will have the sa | | /* | |
| me | | The 'zlib' compression library provides in-memory compression and | |
| stream interface. | | decompression functions, including integrity checks of the uncompressed d | |
| | | ata. | |
| Compression can be done in a single step if the buffers are large | | This version of the library supports only one compression method (deflati | |
| enough (for example if an input file is mmap'ed), or can be done by | | on) | |
| repeated calls of the compression function. In the latter case, the | | but other algorithms will be added later and will have the same stream | |
| application must provide more input and/or consume the output | | interface. | |
| | | | |
| | | Compression can be done in a single step if the buffers are large enoug | |
| | | h, | |
| | | or can be done by repeated calls of the compression function. In the lat | |
| | | ter | |
| | | case, the application must provide more input and/or consume the output | |
| (providing more output space) before each call. | | (providing more output space) before each call. | |
| | | | |
|
| The compressed data format used by default by the in-memory functions
is | | The compressed data format used by default by the in-memory functions i
s | |
| the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped | | the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped | |
| around a deflate stream, which is itself documented in RFC 1951. | | around a deflate stream, which is itself documented in RFC 1951. | |
| | | | |
|
| The library also supports reading and writing files in gzip (.gz) form
at | | The library also supports reading and writing files in gzip (.gz) forma
t | |
| with an interface similar to that of stdio using the functions that start | | with an interface similar to that of stdio using the functions that start | |
| with "gz". The gzip format is different from the zlib format. gzip is a | | with "gz". The gzip format is different from the zlib format. gzip is a | |
| gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. | | gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. | |
| | | | |
|
| This library can optionally read and write gzip streams in memory as w
ell. | | This library can optionally read and write gzip streams in memory as we
ll. | |
| | | | |
|
| The zlib format was designed to be compact and fast for use in memory | | The zlib format was designed to be compact and fast for use in memory | |
| and on communications channels. The gzip format was designed for single- | | and on communications channels. The gzip format was designed for single- | |
| file compression on file systems, has a larger header than zlib to mainta
in | | file compression on file systems, has a larger header than zlib to mainta
in | |
| directory information, and uses a different, slower check method than zli
b. | | directory information, and uses a different, slower check method than zli
b. | |
| | | | |
|
| The library does not install any signal handler. The decoder checks | | The library does not install any signal handler. The decoder checks | |
| the consistency of the compressed data, so the library should never | | the consistency of the compressed data, so the library should never crash | |
| crash even in case of corrupted input. | | even in case of corrupted input. | |
| */ | | */ | |
| | | | |
| typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); | | typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); | |
| typedef void (*free_func) OF((voidpf opaque, voidpf address)); | | typedef void (*free_func) OF((voidpf opaque, voidpf address)); | |
| | | | |
| struct internal_state; | | struct internal_state; | |
| | | | |
| typedef struct z_stream_s { | | typedef struct z_stream_s { | |
|
| Bytef *next_in; /* next input byte */ | | z_const Bytef *next_in; /* next input byte */ | |
| uInt avail_in; /* number of bytes available at next_in */ | | uInt avail_in; /* number of bytes available at next_in */ | |
|
| uLong total_in; /* total nb of input bytes read so far */ | | uLong total_in; /* total number of input bytes read so far */ | |
| | | | |
| Bytef *next_out; /* next output byte should be put there */ | | Bytef *next_out; /* next output byte should be put there */ | |
| uInt avail_out; /* remaining free space at next_out */ | | uInt avail_out; /* remaining free space at next_out */ | |
|
| uLong total_out; /* total nb of bytes output so far */ | | uLong total_out; /* total number of bytes output so far */ | |
| | | | |
|
| char *msg; /* last error message, NULL if no error */ | | z_const char *msg; /* last error message, NULL if no error */ | |
| struct internal_state FAR *state; /* not visible by applications */ | | struct internal_state FAR *state; /* not visible by applications */ | |
| | | | |
| alloc_func zalloc; /* used to allocate the internal state */ | | alloc_func zalloc; /* used to allocate the internal state */ | |
| free_func zfree; /* used to free the internal state */ | | free_func zfree; /* used to free the internal state */ | |
| voidpf opaque; /* private data object passed to zalloc and zfree *
/ | | voidpf opaque; /* private data object passed to zalloc and zfree *
/ | |
| | | | |
| int data_type; /* best guess about the data type: binary or text *
/ | | int data_type; /* best guess about the data type: binary or text *
/ | |
| uLong adler; /* adler32 value of the uncompressed data */ | | uLong adler; /* adler32 value of the uncompressed data */ | |
| uLong reserved; /* reserved for future use */ | | uLong reserved; /* reserved for future use */ | |
| } z_stream; | | } z_stream; | |
| | | | |
| skipping to change at line 128 | | skipping to change at line 131 | |
| Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ | | Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ | |
| uInt comm_max; /* space at comment (only when reading header) */ | | uInt comm_max; /* space at comment (only when reading header) */ | |
| int hcrc; /* true if there was or will be a header crc */ | | int hcrc; /* true if there was or will be a header crc */ | |
| int done; /* true when done reading gzip header (not used | | int done; /* true when done reading gzip header (not used | |
| when writing a gzip file) */ | | when writing a gzip file) */ | |
| } gz_header; | | } gz_header; | |
| | | | |
| typedef gz_header FAR *gz_headerp; | | typedef gz_header FAR *gz_headerp; | |
| | | | |
| /* | | /* | |
|
| The application must update next_in and avail_in when avail_in has | | The application must update next_in and avail_in when avail_in has dro | |
| dropped to zero. It must update next_out and avail_out when avail_out | | pped | |
| has dropped to zero. The application must initialize zalloc, zfree and | | to zero. It must update next_out and avail_out when avail_out has dropp | |
| opaque before calling the init function. All other fields are set by the | | ed | |
| compression library and must not be updated by the application. | | to zero. The application must initialize zalloc, zfree and opaque befor | |
| | | e | |
| The opaque value provided by the application will be passed as the first | | calling the init function. All other fields are set by the compression | |
| parameter for calls of zalloc and zfree. This can be useful for custom | | library and must not be updated by the application. | |
| memory management. The compression library attaches no meaning to the | | | |
| | | The opaque value provided by the application will be passed as the fir | |
| | | st | |
| | | parameter for calls of zalloc and zfree. This can be useful for custom | |
| | | memory management. The compression library attaches no meaning to the | |
| opaque value. | | opaque value. | |
| | | | |
|
| zalloc must return Z_NULL if there is not enough memory for the object. | | zalloc must return Z_NULL if there is not enough memory for the object
. | |
| If zlib is used in a multi-threaded application, zalloc and zfree must b
e | | If zlib is used in a multi-threaded application, zalloc and zfree must b
e | |
| thread safe. | | thread safe. | |
| | | | |
|
| On 16-bit systems, the functions zalloc and zfree must be able to alloca | | On 16-bit systems, the functions zalloc and zfree must be able to allo | |
| te | | cate | |
| exactly 65536 bytes, but will not be required to allocate more than this | | exactly 65536 bytes, but will not be required to allocate more than this | |
| if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, | | if | |
| pointers returned by zalloc for objects of exactly 65536 bytes *must* | | the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, poin | |
| have their offset normalized to zero. The default allocation function | | ters | |
| provided by this library ensures this (see zutil.c). To reduce memory | | returned by zalloc for objects of exactly 65536 bytes *must* have their | |
| requirements and avoid any allocation of 64K objects, at the expense of | | offset normalized to zero. The default allocation function provided by | |
| compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h) | | this | |
| . | | library ensures this (see zutil.c). To reduce memory requirements and a | |
| | | void | |
| The fields total_in and total_out can be used for statistics or | | any allocation of 64K objects, at the expense of compression ratio, comp | |
| progress reports. After compression, total_in holds the total size of | | ile | |
| the uncompressed data and may be saved for use in the decompressor | | the library with -DMAX_WBITS=14 (see zconf.h). | |
| (particularly if the decompressor wants to decompress everything in | | | |
| a single step). | | The fields total_in and total_out can be used for statistics or progre | |
| | | ss | |
| | | reports. After compression, total_in holds the total size of the | |
| | | uncompressed data and may be saved for use in the decompressor (particul | |
| | | arly | |
| | | if the decompressor wants to decompress everything in a single step). | |
| */ | | */ | |
| | | | |
| /* constants */ | | /* constants */ | |
| | | | |
| #define Z_NO_FLUSH 0 | | #define Z_NO_FLUSH 0 | |
|
| #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ | | #define Z_PARTIAL_FLUSH 1 | |
| #define Z_SYNC_FLUSH 2 | | #define Z_SYNC_FLUSH 2 | |
| #define Z_FULL_FLUSH 3 | | #define Z_FULL_FLUSH 3 | |
| #define Z_FINISH 4 | | #define Z_FINISH 4 | |
| #define Z_BLOCK 5 | | #define Z_BLOCK 5 | |
|
| | | #define Z_TREES 6 | |
| /* Allowed flush values; see deflate() and inflate() below for details */ | | /* Allowed flush values; see deflate() and inflate() below for details */ | |
| | | | |
| #define Z_OK 0 | | #define Z_OK 0 | |
| #define Z_STREAM_END 1 | | #define Z_STREAM_END 1 | |
| #define Z_NEED_DICT 2 | | #define Z_NEED_DICT 2 | |
| #define Z_ERRNO (-1) | | #define Z_ERRNO (-1) | |
| #define Z_STREAM_ERROR (-2) | | #define Z_STREAM_ERROR (-2) | |
| #define Z_DATA_ERROR (-3) | | #define Z_DATA_ERROR (-3) | |
| #define Z_MEM_ERROR (-4) | | #define Z_MEM_ERROR (-4) | |
| #define Z_BUF_ERROR (-5) | | #define Z_BUF_ERROR (-5) | |
| #define Z_VERSION_ERROR (-6) | | #define Z_VERSION_ERROR (-6) | |
|
| /* Return codes for the compression/decompression functions. Negative | | /* Return codes for the compression/decompression functions. Negative value | |
| * values are errors, positive values are used for special but normal event | | s | |
| s. | | * are errors, positive values are used for special but normal events. | |
| */ | | */ | |
| | | | |
| #define Z_NO_COMPRESSION 0 | | #define Z_NO_COMPRESSION 0 | |
| #define Z_BEST_SPEED 1 | | #define Z_BEST_SPEED 1 | |
| #define Z_BEST_COMPRESSION 9 | | #define Z_BEST_COMPRESSION 9 | |
| #define Z_DEFAULT_COMPRESSION (-1) | | #define Z_DEFAULT_COMPRESSION (-1) | |
| /* compression levels */ | | /* compression levels */ | |
| | | | |
| #define Z_FILTERED 1 | | #define Z_FILTERED 1 | |
| #define Z_HUFFMAN_ONLY 2 | | #define Z_HUFFMAN_ONLY 2 | |
| | | | |
| skipping to change at line 213 | | skipping to change at line 216 | |
| | | | |
| #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ | | #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ | |
| | | | |
| #define zlib_version zlibVersion() | | #define zlib_version zlibVersion() | |
| /* for compatibility with versions < 1.0.2 */ | | /* for compatibility with versions < 1.0.2 */ | |
| | | | |
| /* basic functions */ | | /* basic functions */ | |
| | | | |
| ZEXTERN const char * ZEXPORT zlibVersion OF((void)); | | ZEXTERN const char * ZEXPORT zlibVersion OF((void)); | |
| /* The application can compare zlibVersion and ZLIB_VERSION for consistency
. | | /* The application can compare zlibVersion and ZLIB_VERSION for consistency
. | |
|
| If the first character differs, the library code actually used is | | If the first character differs, the library code actually used is not | |
| not compatible with the zlib.h header file used by the application. | | compatible with the zlib.h header file used by the application. This ch | |
| This check is automatically made by deflateInit and inflateInit. | | eck | |
| | | is automatically made by deflateInit and inflateInit. | |
| */ | | */ | |
| | | | |
| /* | | /* | |
| ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); | | ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); | |
| | | | |
|
| Initializes the internal stream state for compression. The fields | | Initializes the internal stream state for compression. The fields | |
| zalloc, zfree and opaque must be initialized before by the caller. | | zalloc, zfree and opaque must be initialized before by the caller. If | |
| If zalloc and zfree are set to Z_NULL, deflateInit updates them to | | zalloc and zfree are set to Z_NULL, deflateInit updates them to use defa | |
| use default allocation functions. | | ult | |
| | | allocation functions. | |
| | | | |
| The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and
9: | | The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and
9: | |
|
| 1 gives best speed, 9 gives best compression, 0 gives no compression at | | 1 gives best speed, 9 gives best compression, 0 gives no compression at | |
| all (the input data is simply copied a block at a time). | | all | |
| Z_DEFAULT_COMPRESSION requests a default compromise between speed and | | (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESS | |
| compression (currently equivalent to level 6). | | ION | |
| | | requests a default compromise between speed and compression (currently | |
| | | equivalent to level 6). | |
| | | | |
|
| deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not | | deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enou | |
| enough memory, Z_STREAM_ERROR if level is not a valid compression level, | | gh | |
| | | memory, Z_STREAM_ERROR if level is not a valid compression level, or | |
| Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatib
le | | Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatib
le | |
|
| with the version assumed by the caller (ZLIB_VERSION). | | with the version assumed by the caller (ZLIB_VERSION). msg is set to nu | |
| msg is set to null if there is no error message. deflateInit does not | | ll | |
| perform any compression: this will be done by deflate(). | | if there is no error message. deflateInit does not perform any compress | |
| | | ion: | |
| | | this will be done by deflate(). | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); | | ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); | |
| /* | | /* | |
| deflate compresses as much data as possible, and stops when the input | | deflate compresses as much data as possible, and stops when the input | |
|
| buffer becomes empty or the output buffer becomes full. It may introduce | | buffer becomes empty or the output buffer becomes full. It may introduce | |
| some | | some output latency (reading input without producing any output) except w | |
| output latency (reading input without producing any output) except when | | hen | |
| forced to flush. | | forced to flush. | |
| | | | |
|
| The detailed semantics are as follows. deflate performs one or both of
the | | The detailed semantics are as follows. deflate performs one or both of
the | |
| following actions: | | following actions: | |
| | | | |
| - Compress more input starting at next_in and update next_in and avail_in | | - Compress more input starting at next_in and update next_in and avail_in | |
|
| accordingly. If not all input can be processed (because there is not | | accordingly. If not all input can be processed (because there is not | |
| enough room in the output buffer), next_in and avail_in are updated and | | enough room in the output buffer), next_in and avail_in are updated and | |
| processing will resume at this point for the next call of deflate(). | | processing will resume at this point for the next call of deflate(). | |
| | | | |
| - Provide more output starting at next_out and update next_out and avail_
out | | - Provide more output starting at next_out and update next_out and avail_
out | |
|
| accordingly. This action is forced if the parameter flush is non zero. | | accordingly. This action is forced if the parameter flush is non zero. | |
| Forcing flush frequently degrades the compression ratio, so this parame
ter | | Forcing flush frequently degrades the compression ratio, so this parame
ter | |
|
| should be set only when necessary (in interactive applications). | | should be set only when necessary (in interactive applications). Some | |
| Some output may be provided even if flush is not set. | | output may be provided even if flush is not set. | |
| | | | |
|
| Before the call of deflate(), the application should ensure that at least | | Before the call of deflate(), the application should ensure that at lea | |
| one of the actions is possible, by providing more input and/or consuming | | st | |
| more output, and updating avail_in or avail_out accordingly; avail_out | | one of the actions is possible, by providing more input and/or consuming | |
| should never be zero before the call. The application can consume the | | more | |
| compressed output when it wants, for example when the output buffer is fu | | output, and updating avail_in or avail_out accordingly; avail_out should | |
| ll | | never be zero before the call. The application can consume the compresse | |
| (avail_out == 0), or after each call of deflate(). If deflate returns Z_O | | d | |
| K | | output when it wants, for example when the output buffer is full (avail_o | |
| and with zero avail_out, it must be called again after making room in the | | ut | |
| output buffer because there might be more output pending. | | == 0), or after each call of deflate(). If deflate returns Z_OK and with | |
| | | zero avail_out, it must be called again after making room in the output | |
| | | buffer because there might be more output pending. | |
| | | | |
| Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate
to | | Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate
to | |
|
| decide how much data to accumualte before producing output, in order to | | decide how much data to accumulate before producing output, in order to | |
| maximize compression. | | maximize compression. | |
| | | | |
| If the parameter flush is set to Z_SYNC_FLUSH, all pending output is | | If the parameter flush is set to Z_SYNC_FLUSH, all pending output is | |
| flushed to the output buffer and the output is aligned on a byte boundary
, so | | flushed to the output buffer and the output is aligned on a byte boundary
, so | |
|
| that the decompressor can get all input data available so far. (In partic | | that the decompressor can get all input data available so far. (In | |
| ular | | particular avail_in is zero after the call if enough output space has bee | |
| avail_in is zero after the call if enough output space has been provided | | n | |
| before the call.) Flushing may degrade compression for some compression | | provided before the call.) Flushing may degrade compression for some | |
| algorithms and so it should be used only when necessary. | | compression algorithms and so it should be used only when necessary. Thi | |
| | | s | |
| | | completes the current deflate block and follows it with an empty stored b | |
| | | lock | |
| | | that is three bits plus filler bits to the next byte, followed by four by | |
| | | tes | |
| | | (00 00 ff ff). | |
| | | | |
| | | If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to th | |
| | | e | |
| | | output buffer, but the output is not aligned to a byte boundary. All of | |
| | | the | |
| | | input data so far will be available to the decompressor, as for Z_SYNC_FL | |
| | | USH. | |
| | | This completes the current deflate block and follows it with an empty fix | |
| | | ed | |
| | | codes block that is 10 bits long. This assures that enough bytes are out | |
| | | put | |
| | | in order for the decompressor to finish the block before the empty fixed | |
| | | code | |
| | | block. | |
| | | | |
| | | If flush is set to Z_BLOCK, a deflate block is completed and emitted, a | |
| | | s | |
| | | for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and u | |
| | | p to | |
| | | seven bits of the current block are held to be written as the next byte a | |
| | | fter | |
| | | the next deflate block is completed. In this case, the decompressor may | |
| | | not | |
| | | be provided enough bits at this point in order to complete decompression | |
| | | of | |
| | | the data provided so far to the compressor. It may need to wait for the | |
| | | next | |
| | | block to be emitted. This is for advanced applications that need to cont | |
| | | rol | |
| | | the emission of deflate blocks. | |
| | | | |
| If flush is set to Z_FULL_FLUSH, all output is flushed as with | | If flush is set to Z_FULL_FLUSH, all output is flushed as with | |
| Z_SYNC_FLUSH, and the compression state is reset so that decompression ca
n | | Z_SYNC_FLUSH, and the compression state is reset so that decompression ca
n | |
| restart from this point if previous compressed data has been damaged or i
f | | restart from this point if previous compressed data has been damaged or i
f | |
|
| random access is desired. Using Z_FULL_FLUSH too often can seriously degr
ade | | random access is desired. Using Z_FULL_FLUSH too often can seriously deg
rade | |
| compression. | | compression. | |
| | | | |
| If deflate returns with avail_out == 0, this function must be called ag
ain | | If deflate returns with avail_out == 0, this function must be called ag
ain | |
| with the same value of the flush parameter and more output space (updated | | with the same value of the flush parameter and more output space (updated | |
| avail_out), until the flush is complete (deflate returns with non-zero | | avail_out), until the flush is complete (deflate returns with non-zero | |
|
| avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that | | avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure tha
t | |
| avail_out is greater than six to avoid repeated flush markers due to | | avail_out is greater than six to avoid repeated flush markers due to | |
| avail_out == 0 on return. | | avail_out == 0 on return. | |
| | | | |
| If the parameter flush is set to Z_FINISH, pending input is processed, | | If the parameter flush is set to Z_FINISH, pending input is processed, | |
|
| pending output is flushed and deflate returns with Z_STREAM_END if there | | pending output is flushed and deflate returns with Z_STREAM_END if there | |
| was enough output space; if deflate returns with Z_OK, this function must | | was | |
| be | | enough output space; if deflate returns with Z_OK, this function must be | |
| called again with Z_FINISH and more output space (updated avail_out) but
no | | called again with Z_FINISH and more output space (updated avail_out) but
no | |
|
| more input data, until it returns with Z_STREAM_END or an error. After | | more input data, until it returns with Z_STREAM_END or an error. After | |
| deflate has returned Z_STREAM_END, the only possible operations on the | | deflate has returned Z_STREAM_END, the only possible operations on the st | |
| stream are deflateReset or deflateEnd. | | ream | |
| | | are deflateReset or deflateEnd. | |
| | | | |
| Z_FINISH can be used immediately after deflateInit if all the compressi
on | | Z_FINISH can be used immediately after deflateInit if all the compressi
on | |
|
| is to be done in a single step. In this case, avail_out must be at least | | is to be done in a single step. In this case, avail_out must be at least | |
| the value returned by deflateBound (see below). If deflate does not retur | | the | |
| n | | value returned by deflateBound (see below). Then deflate is guaranteed t | |
| Z_STREAM_END, then it must be called again as described above. | | o | |
| | | return Z_STREAM_END. If not enough output space is provided, deflate wil | |
| | | l | |
| | | not return Z_STREAM_END, and it must be called again as described above. | |
| | | | |
| deflate() sets strm->adler to the adler32 checksum of all input read | | deflate() sets strm->adler to the adler32 checksum of all input read | |
| so far (that is, total_in bytes). | | so far (that is, total_in bytes). | |
| | | | |
| deflate() may update strm->data_type if it can make a good guess about | | deflate() may update strm->data_type if it can make a good guess about | |
|
| the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considere | | the input data type (Z_BINARY or Z_TEXT). In doubt, the data is consider | |
| d | | ed | |
| binary. This field is only for information purposes and does not affect | | binary. This field is only for information purposes and does not affect | |
| the compression algorithm in any manner. | | the | |
| | | compression algorithm in any manner. | |
| | | | |
| deflate() returns Z_OK if some progress has been made (more input | | deflate() returns Z_OK if some progress has been made (more input | |
| processed or more output produced), Z_STREAM_END if all input has been | | processed or more output produced), Z_STREAM_END if all input has been | |
| consumed and all output has been produced (only when flush is set to | | consumed and all output has been produced (only when flush is set to | |
| Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for examp
le | | Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for examp
le | |
|
| if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible | | if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possibl | |
| (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is no | | e | |
| t | | (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is n | |
| | | ot | |
| fatal, and deflate() can be called again with more input and more output | | fatal, and deflate() can be called again with more input and more output | |
| space to continue compressing. | | space to continue compressing. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); | | ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); | |
| /* | | /* | |
| All dynamically allocated data structures for this stream are freed. | | All dynamically allocated data structures for this stream are freed. | |
|
| This function discards any unprocessed input and does not flush any | | This function discards any unprocessed input and does not flush any pend | |
| pending output. | | ing | |
| | | output. | |
| | | | |
| deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the | | deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the | |
| stream state was inconsistent, Z_DATA_ERROR if the stream was freed | | stream state was inconsistent, Z_DATA_ERROR if the stream was freed | |
|
| prematurely (some input or output was discarded). In the error case, | | prematurely (some input or output was discarded). In the error case, ms | |
| msg may be set but then points to a static string (which must not be | | g | |
| | | may be set but then points to a static string (which must not be | |
| deallocated). | | deallocated). | |
| */ | | */ | |
| | | | |
| /* | | /* | |
| ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); | | ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); | |
| | | | |
|
| Initializes the internal stream state for decompression. The fields | | Initializes the internal stream state for decompression. The fields | |
| next_in, avail_in, zalloc, zfree and opaque must be initialized before b
y | | next_in, avail_in, zalloc, zfree and opaque must be initialized before b
y | |
|
| the caller. If next_in is not Z_NULL and avail_in is large enough (the e | | the caller. If next_in is not Z_NULL and avail_in is large enough (the | |
| xact | | exact value depends on the compression method), inflateInit determines t | |
| value depends on the compression method), inflateInit determines the | | he | |
| compression method from the zlib header and allocates all data structure
s | | compression method from the zlib header and allocates all data structure
s | |
| accordingly; otherwise the allocation will be deferred to the first call
of | | accordingly; otherwise the allocation will be deferred to the first call
of | |
| inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates the
m to | | inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates the
m to | |
| use default allocation functions. | | use default allocation functions. | |
| | | | |
| inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enou
gh | | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enou
gh | |
| memory, Z_VERSION_ERROR if the zlib library version is incompatible with
the | | memory, Z_VERSION_ERROR if the zlib library version is incompatible with
the | |
|
| version assumed by the caller. msg is set to null if there is no error | | version assumed by the caller, or Z_STREAM_ERROR if the parameters are | |
| message. inflateInit does not perform any decompression apart from readi | | invalid, such as a null pointer to the structure. msg is set to null if | |
| ng | | there is no error message. inflateInit does not perform any decompressi | |
| the zlib header if present: this will be done by inflate(). (So next_in | | on | |
| and | | apart from possibly reading the zlib header if present: actual decompres | |
| avail_in may be modified, but next_out and avail_out are unchanged.) | | sion | |
| | | will be done by inflate(). (So next_in and avail_in may be modified, bu | |
| | | t | |
| | | next_out and avail_out are unused and unchanged.) The current implementa | |
| | | tion | |
| | | of inflateInit() does not process any header information -- that is defe | |
| | | rred | |
| | | until inflate() is called. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | | ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | |
| /* | | /* | |
| inflate decompresses as much data as possible, and stops when the input | | inflate decompresses as much data as possible, and stops when the input | |
|
| buffer becomes empty or the output buffer becomes full. It may introduce | | buffer becomes empty or the output buffer becomes full. It may introduce | |
| some output latency (reading input without producing any output) except w
hen | | some output latency (reading input without producing any output) except w
hen | |
| forced to flush. | | forced to flush. | |
| | | | |
|
| The detailed semantics are as follows. inflate performs one or both of th
e | | The detailed semantics are as follows. inflate performs one or both of t
he | |
| following actions: | | following actions: | |
| | | | |
| - Decompress more input starting at next_in and update next_in and avail_
in | | - Decompress more input starting at next_in and update next_in and avail_
in | |
|
| accordingly. If not all input can be processed (because there is not | | accordingly. If not all input can be processed (because there is not | |
| enough room in the output buffer), next_in is updated and processing | | enough room in the output buffer), next_in is updated and processing wi | |
| will resume at this point for the next call of inflate(). | | ll | |
| | | resume at this point for the next call of inflate(). | |
| | | | |
| - Provide more output starting at next_out and update next_out and avail_
out | | - Provide more output starting at next_out and update next_out and avail_
out | |
|
| accordingly. inflate() provides as much output as possible, until ther | | accordingly. inflate() provides as much output as possible, until ther | |
| e | | e is | |
| is no more input data or no more space in the output buffer (see below | | no more input data or no more space in the output buffer (see below abo | |
| about the flush parameter). | | ut | |
| | | the flush parameter). | |
| Before the call of inflate(), the application should ensure that at least | | | |
| one of the actions is possible, by providing more input and/or consuming | | Before the call of inflate(), the application should ensure that at lea | |
| more output, and updating the next_* and avail_* values accordingly. | | st | |
| The application can consume the uncompressed output when it wants, for | | one of the actions is possible, by providing more input and/or consuming | |
| example when the output buffer is full (avail_out == 0), or after each | | more | |
| call of inflate(). If inflate returns Z_OK and with zero avail_out, it | | output, and updating the next_* and avail_* values accordingly. The | |
| must be called again after making room in the output buffer because there | | application can consume the uncompressed output when it wants, for exampl | |
| might be more output pending. | | e | |
| | | when the output buffer is full (avail_out == 0), or after each call of | |
| The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, | | inflate(). If inflate returns Z_OK and with zero avail_out, it must be | |
| Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much | | called again after making room in the output buffer because there might b | |
| output as possible to the output buffer. Z_BLOCK requests that inflate() | | e | |
| stop | | more output pending. | |
| if and when it gets to the next deflate block boundary. When decoding the | | | |
| zlib or gzip format, this will cause inflate() to return immediately afte | | The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FIN | |
| r | | ISH, | |
| the header and before the first block. When doing a raw inflate, inflate( | | Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much | |
| ) | | output as possible to the output buffer. Z_BLOCK requests that inflate() | |
| will go ahead and process the first block, and will return when it gets t | | stop if and when it gets to the next deflate block boundary. When decodi | |
| o | | ng | |
| the end of that block, or when it runs out of data. | | the zlib or gzip format, this will cause inflate() to return immediately | |
| | | after the header and before the first block. When doing a raw inflate, | |
| | | inflate() will go ahead and process the first block, and will return when | |
| | | it | |
| | | gets to the end of that block, or when it runs out of data. | |
| | | | |
| The Z_BLOCK option assists in appending to or combining deflate streams
. | | The Z_BLOCK option assists in appending to or combining deflate streams
. | |
| Also to assist in this, on return inflate() will set strm->data_type to t
he | | Also to assist in this, on return inflate() will set strm->data_type to t
he | |
|
| number of unused bits in the last byte taken from strm->next_in, plus 64 | | number of unused bits in the last byte taken from strm->next_in, plus 64 | |
| if inflate() is currently decoding the last block in the deflate stream, | | if | |
| plus 128 if inflate() returned immediately after decoding an end-of-block | | inflate() is currently decoding the last block in the deflate stream, plu | |
| code or decoding the complete header up to just before the first byte of | | s | |
| the | | 128 if inflate() returned immediately after decoding an end-of-block code | |
| deflate stream. The end-of-block will not be indicated until all of the | | or | |
| uncompressed data from that block has been written to strm->next_out. Th | | decoding the complete header up to just before the first byte of the defl | |
| e | | ate | |
| number of unused bits may in general be greater than seven, except when | | stream. The end-of-block will not be indicated until all of the uncompre | |
| bit 7 of data_type is set, in which case the number of unused bits will b | | ssed | |
| e | | data from that block has been written to strm->next_out. The number of | |
| less than eight. | | unused bits may in general be greater than seven, except when bit 7 of | |
| | | data_type is set, in which case the number of unused bits will be less th | |
| | | an | |
| | | eight. data_type is set as noted here every time inflate() returns for a | |
| | | ll | |
| | | flush options, and so can be used to determine the amount of currently | |
| | | consumed input in bits. | |
| | | | |
| | | The Z_TREES option behaves as Z_BLOCK does, but it also returns when th | |
| | | e | |
| | | end of each deflate block header is reached, before any actual data in th | |
| | | at | |
| | | block is decoded. This allows the caller to determine the length of the | |
| | | deflate block header for later use in random access within a deflate bloc | |
| | | k. | |
| | | 256 is added to the value of strm->data_type when inflate() returns | |
| | | immediately after reaching the end of the deflate block header. | |
| | | | |
| inflate() should normally be called until it returns Z_STREAM_END or an | | inflate() should normally be called until it returns Z_STREAM_END or an | |
|
| error. However if all decompression is to be performed in a single step | | error. However if all decompression is to be performed in a single step | |
| (a single call of inflate), the parameter flush should be set to | | (a | |
| Z_FINISH. In this case all pending input is processed and all pending | | single call of inflate), the parameter flush should be set to Z_FINISH. | |
| output is flushed; avail_out must be large enough to hold all the | | In | |
| uncompressed data. (The size of the uncompressed data may have been saved | | this case all pending input is processed and all pending output is flushe | |
| by the compressor for this purpose.) The next operation on this stream mu | | d; | |
| st | | avail_out must be large enough to hold all of the uncompressed data for t | |
| be inflateEnd to deallocate the decompression state. The use of Z_FINISH | | he | |
| is never required, but can be used to inform inflate that a faster approa | | operation to complete. (The size of the uncompressed data may have been | |
| ch | | saved by the compressor for this purpose.) The use of Z_FINISH is not | |
| may be used for the single inflate() call. | | required to perform an inflation in one step. However it may be used to | |
| | | inform inflate that a faster approach can be used for the single inflate( | |
| | | ) | |
| | | call. Z_FINISH also informs inflate to not maintain a sliding window if | |
| | | the | |
| | | stream completes, which reduces inflate's memory footprint. If the strea | |
| | | m | |
| | | does not complete, either because not all of the stream is provided or no | |
| | | t | |
| | | enough output space is provided, then a sliding window will be allocated | |
| | | and | |
| | | inflate() can be called again to continue the operation as if Z_NO_FLUSH | |
| | | had | |
| | | been used. | |
| | | | |
| In this implementation, inflate() always flushes as much output as | | In this implementation, inflate() always flushes as much output as | |
| possible to the output buffer, and always uses the faster approach on the | | possible to the output buffer, and always uses the faster approach on the | |
|
| first call. So the only effect of the flush parameter in this implementat | | first call. So the effects of the flush parameter in this implementation | |
| ion | | are | |
| is on the return value of inflate(), as noted below, or when it returns e | | on the return value of inflate() as noted below, when inflate() returns e | |
| arly | | arly | |
| because Z_BLOCK is used. | | when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation | |
| | | of | |
| | | memory for a sliding window when Z_FINISH is used. | |
| | | | |
| If a preset dictionary is needed after this call (see inflateSetDictio
nary | | If a preset dictionary is needed after this call (see inflateSetDictio
nary | |
|
| below), inflate sets strm->adler to the adler32 checksum of the dictionar
y | | below), inflate sets strm->adler to the Adler-32 checksum of the dictiona
ry | |
| chosen by the compressor and returns Z_NEED_DICT; otherwise it sets | | chosen by the compressor and returns Z_NEED_DICT; otherwise it sets | |
|
| strm->adler to the adler32 checksum of all output produced so far (that i
s, | | strm->adler to the Adler-32 checksum of all output produced so far (that
is, | |
| total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as descr
ibed | | total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as descr
ibed | |
|
| below. At the end of the stream, inflate() checks that its computed adler
32 | | below. At the end of the stream, inflate() checks that its computed adle
r32 | |
| checksum is equal to that saved by the compressor and returns Z_STREAM_EN
D | | checksum is equal to that saved by the compressor and returns Z_STREAM_EN
D | |
| only if the checksum is correct. | | only if the checksum is correct. | |
| | | | |
|
| inflate() will decompress and check either zlib-wrapped or gzip-wrapped | | inflate() can decompress and check either zlib-wrapped or gzip-wrapped | |
| deflate data. The header type is detected automatically. Any informatio | | deflate data. The header type is detected automatically, if requested wh | |
| n | | en | |
| contained in the gzip header is not retained, so applications that need t | | initializing with inflateInit2(). Any information contained in the gzip | |
| hat | | header is not retained, so applications that need that information should | |
| information should instead use raw inflate, see inflateInit2() below, or | | instead use raw inflate, see inflateInit2() below, or inflateBack() and | |
| inflateBack() and perform their own processing of the gzip header and | | perform their own processing of the gzip header and trailer. When proces | |
| trailer. | | sing | |
| | | gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the outp | |
| | | ut | |
| | | producted so far. The CRC-32 is checked against the gzip trailer. | |
| | | | |
| inflate() returns Z_OK if some progress has been made (more input proce
ssed | | inflate() returns Z_OK if some progress has been made (more input proce
ssed | |
| or more output produced), Z_STREAM_END if the end of the compressed data
has | | or more output produced), Z_STREAM_END if the end of the compressed data
has | |
| been reached and all uncompressed output has been produced, Z_NEED_DICT i
f a | | been reached and all uncompressed output has been produced, Z_NEED_DICT i
f a | |
| preset dictionary is needed at this point, Z_DATA_ERROR if the input data
was | | preset dictionary is needed at this point, Z_DATA_ERROR if the input data
was | |
| corrupted (input stream not conforming to the zlib format or incorrect ch
eck | | corrupted (input stream not conforming to the zlib format or incorrect ch
eck | |
| value), Z_STREAM_ERROR if the stream structure was inconsistent (for exam
ple | | value), Z_STREAM_ERROR if the stream structure was inconsistent (for exam
ple | |
|
| if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough mem
ory, | | next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memo
ry, | |
| Z_BUF_ERROR if no progress is possible or if there was not enough room in
the | | Z_BUF_ERROR if no progress is possible or if there was not enough room in
the | |
|
| output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal,
and | | output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal,
and | |
| inflate() can be called again with more input and more output space to | | inflate() can be called again with more input and more output space to | |
|
| continue decompressing. If Z_DATA_ERROR is returned, the application may | | continue decompressing. If Z_DATA_ERROR is returned, the application may | |
| then | | then call inflateSync() to look for a good compression block if a partial | |
| call inflateSync() to look for a good compression block if a partial reco | | recovery of the data is desired. | |
| very | | | |
| of the data is desired. | | | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); | | ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); | |
| /* | | /* | |
| All dynamically allocated data structures for this stream are freed. | | All dynamically allocated data structures for this stream are freed. | |
|
| This function discards any unprocessed input and does not flush any | | This function discards any unprocessed input and does not flush any pend | |
| pending output. | | ing | |
| | | output. | |
| | | | |
| inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state | | inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state | |
|
| was inconsistent. In the error case, msg may be set but then points to a | | was inconsistent. In the error case, msg may be set but then points to
a | |
| static string (which must not be deallocated). | | static string (which must not be deallocated). | |
| */ | | */ | |
| | | | |
| /* Advanced functions */ | | /* Advanced functions */ | |
| | | | |
| /* | | /* | |
| The following functions are needed only in some special applications. | | The following functions are needed only in some special applications. | |
| */ | | */ | |
| | | | |
| /* | | /* | |
| ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, | | ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, | |
| int level, | | int level, | |
| int method, | | int method, | |
| int windowBits, | | int windowBits, | |
| int memLevel, | | int memLevel, | |
| int strategy)); | | int strategy)); | |
| | | | |
|
| This is another version of deflateInit with more compression options. | | This is another version of deflateInit with more compression options. | |
| The | | The | |
| fields next_in, zalloc, zfree and opaque must be initialized before by | | fields next_in, zalloc, zfree and opaque must be initialized before by t | |
| the caller. | | he | |
| | | caller. | |
| | | | |
|
| The method parameter is the compression method. It must be Z_DEFLATED
in | | The method parameter is the compression method. It must be Z_DEFLATED
in | |
| this version of the library. | | this version of the library. | |
| | | | |
| The windowBits parameter is the base two logarithm of the window size | | The windowBits parameter is the base two logarithm of the window size | |
|
| (the size of the history buffer). It should be in the range 8..15 for th | | (the size of the history buffer). It should be in the range 8..15 for t | |
| is | | his | |
| version of the library. Larger values of this parameter result in better | | version of the library. Larger values of this parameter result in bette | |
| compression at the expense of memory usage. The default value is 15 if | | r | |
| | | compression at the expense of memory usage. The default value is 15 if | |
| deflateInit is used instead. | | deflateInit is used instead. | |
| | | | |
|
| windowBits can also be -8..-15 for raw deflate. In this case, -windowB | | windowBits can also be -8..-15 for raw deflate. In this case, -window | |
| its | | Bits | |
| determines the window size. deflate() will then generate raw deflate dat | | determines the window size. deflate() will then generate raw deflate da | |
| a | | ta | |
| with no zlib header or trailer, and will not compute an adler32 check va
lue. | | with no zlib header or trailer, and will not compute an adler32 check va
lue. | |
| | | | |
|
| windowBits can also be greater than 15 for optional gzip encoding. Add | | windowBits can also be greater than 15 for optional gzip encoding. Ad
d | |
| 16 to windowBits to write a simple gzip header and trailer around the | | 16 to windowBits to write a simple gzip header and trailer around the | |
|
| compressed data instead of a zlib wrapper. The gzip header will have no | | compressed data instead of a zlib wrapper. The gzip header will have no | |
| file name, no extra data, no comment, no modification time (set to zero) | | file name, no extra data, no comment, no modification time (set to zero) | |
| , | | , no | |
| no header crc, and the operating system will be set to 255 (unknown). I | | header crc, and the operating system will be set to 255 (unknown). If a | |
| f a | | | |
| gzip stream is being written, strm->adler is a crc32 instead of an adler
32. | | gzip stream is being written, strm->adler is a crc32 instead of an adler
32. | |
| | | | |
| The memLevel parameter specifies how much memory should be allocated | | The memLevel parameter specifies how much memory should be allocated | |
|
| for the internal compression state. memLevel=1 uses minimum memory but | | for the internal compression state. memLevel=1 uses minimum memory but | |
| is slow and reduces compression ratio; memLevel=9 uses maximum memory | | is | |
| for optimal speed. The default value is 8. See zconf.h for total memory | | slow and reduces compression ratio; memLevel=9 uses maximum memory for | |
| usage as a function of windowBits and memLevel. | | optimal speed. The default value is 8. See zconf.h for total memory us | |
| | | age | |
| | | as a function of windowBits and memLevel. | |
| | | | |
|
| The strategy parameter is used to tune the compression algorithm. Use
the | | The strategy parameter is used to tune the compression algorithm. Use
the | |
| value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced b
y a | | value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced b
y a | |
| filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no | | filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no | |
| string match), or Z_RLE to limit match distances to one (run-length | | string match), or Z_RLE to limit match distances to one (run-length | |
|
| encoding). Filtered data consists mostly of small values with a somewhat | | encoding). Filtered data consists mostly of small values with a somewha | |
| random distribution. In this case, the compression algorithm is tuned to | | t | |
| compress them better. The effect of Z_FILTERED is to force more Huffman | | random distribution. In this case, the compression algorithm is tuned t | |
| | | o | |
| | | compress them better. The effect of Z_FILTERED is to force more Huffman | |
| coding and less string matching; it is somewhat intermediate between | | coding and less string matching; it is somewhat intermediate between | |
|
| Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as | | Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost a | |
| Z_HUFFMAN_ONLY, but give better compression for PNG image data. The stra | | s | |
| tegy | | fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. | |
| parameter only affects the compression ratio but not the correctness of | | The | |
| the | | strategy parameter only affects the compression ratio but not the | |
| compressed output even if it is not set appropriately. Z_FIXED prevents | | correctness of the compressed output even if it is not set appropriately | |
| the | | . | |
| use of dynamic Huffman codes, allowing for a simpler decoder for special | | Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simple | |
| applications. | | r | |
| | | decoder for special applications. | |
| deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not en | | | |
| ough | | deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not eno | |
| memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid | | ugh | |
| method). msg is set to null if there is no error message. deflateInit2 | | memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid | |
| does | | method), or Z_VERSION_ERROR if the zlib library version (zlib_version) i | |
| not perform any compression: this will be done by deflate(). | | s | |
| | | incompatible with the version assumed by the caller (ZLIB_VERSION). msg | |
| | | is | |
| | | set to null if there is no error message. deflateInit2 does not perform | |
| | | any | |
| | | compression: this will be done by deflate(). | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, | | ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, | |
| const Bytef *dictionary, | | const Bytef *dictionary, | |
| uInt dictLength)); | | uInt dictLength)); | |
| /* | | /* | |
| Initializes the compression dictionary from the given byte sequence | | Initializes the compression dictionary from the given byte sequence | |
|
| without producing any compressed output. This function must be called | | without producing any compressed output. When using the zlib format, th | |
| immediately after deflateInit, deflateInit2 or deflateReset, before any | | is | |
| call of deflate. The compressor and decompressor must use exactly the sa | | function must be called immediately after deflateInit, deflateInit2 or | |
| me | | deflateReset, and before any call of deflate. When doing raw deflate, t | |
| dictionary (see inflateSetDictionary). | | his | |
| | | function must be called either before any call of deflate, or immediatel | |
| | | y | |
| | | after the completion of a deflate block, i.e. after all input has been | |
| | | consumed and all output has been delivered when using any of the flush | |
| | | options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The | |
| | | compressor and decompressor must use exactly the same dictionary (see | |
| | | inflateSetDictionary). | |
| | | | |
| The dictionary should consist of strings (byte sequences) that are lik
ely | | The dictionary should consist of strings (byte sequences) that are lik
ely | |
| to be encountered later in the data to be compressed, with the most comm
only | | to be encountered later in the data to be compressed, with the most comm
only | |
|
| used strings preferably put towards the end of the dictionary. Using a | | used strings preferably put towards the end of the dictionary. Using a | |
| dictionary is most useful when the data to be compressed is short and ca
n be | | dictionary is most useful when the data to be compressed is short and ca
n be | |
| predicted with good accuracy; the data can then be compressed better tha
n | | predicted with good accuracy; the data can then be compressed better tha
n | |
| with the default empty dictionary. | | with the default empty dictionary. | |
| | | | |
| Depending on the size of the compression data structures selected by | | Depending on the size of the compression data structures selected by | |
| deflateInit or deflateInit2, a part of the dictionary may in effect be | | deflateInit or deflateInit2, a part of the dictionary may in effect be | |
|
| discarded, for example if the dictionary is larger than the window size | | discarded, for example if the dictionary is larger than the window size | |
| in | | provided in deflateInit or deflateInit2. Thus the strings most likely t | |
| deflate or deflate2. Thus the strings most likely to be useful should be | | o be | |
| put at the end of the dictionary, not at the front. In addition, the | | useful should be put at the end of the dictionary, not at the front. In | |
| current implementation of deflate will use at most the window size minus | | addition, the current implementation of deflate will use at most the win | |
| 262 bytes of the provided dictionary. | | dow | |
| | | size minus 262 bytes of the provided dictionary. | |
| | | | |
| Upon return of this function, strm->adler is set to the adler32 value | | Upon return of this function, strm->adler is set to the adler32 value | |
| of the dictionary; the decompressor may later use this value to determin
e | | of the dictionary; the decompressor may later use this value to determin
e | |
|
| which dictionary has been used by the compressor. (The adler32 value | | which dictionary has been used by the compressor. (The adler32 value | |
| applies to the whole dictionary even if only a subset of the dictionary
is | | applies to the whole dictionary even if only a subset of the dictionary
is | |
| actually used by the compressor.) If a raw deflate was requested, then t
he | | actually used by the compressor.) If a raw deflate was requested, then t
he | |
| adler32 value is not computed and strm->adler is not set. | | adler32 value is not computed and strm->adler is not set. | |
| | | | |
| deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a | | deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a | |
|
| parameter is invalid (such as NULL dictionary) or the stream state is | | parameter is invalid (e.g. dictionary being Z_NULL) or the stream state
is | |
| inconsistent (for example if deflate has already been called for this st
ream | | inconsistent (for example if deflate has already been called for this st
ream | |
|
| or if the compression method is bsort). deflateSetDictionary does not | | or if not at a block boundary for raw deflate). deflateSetDictionary do | |
| perform any compression: this will be done by deflate(). | | es | |
| | | not perform any compression: this will be done by deflate(). | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, | | ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, | |
| z_streamp source)); | | z_streamp source)); | |
| /* | | /* | |
| Sets the destination stream as a complete copy of the source stream. | | Sets the destination stream as a complete copy of the source stream. | |
| | | | |
| This function can be useful when several compression strategies will b
e | | This function can be useful when several compression strategies will b
e | |
| tried, for example when there are several ways of pre-processing the inp
ut | | tried, for example when there are several ways of pre-processing the inp
ut | |
|
| data with a filter. The streams that will be discarded should then be fr
eed | | data with a filter. The streams that will be discarded should then be f
reed | |
| by calling deflateEnd. Note that deflateCopy duplicates the internal | | by calling deflateEnd. Note that deflateCopy duplicates the internal | |
|
| compression state which can be quite large, so this strategy is slow and | | compression state which can be quite large, so this strategy is slow and | |
| can consume lots of memory. | | can | |
| | | consume lots of memory. | |
| | | | |
| deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not | | deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not | |
| enough memory, Z_STREAM_ERROR if the source stream state was inconsisten
t | | enough memory, Z_STREAM_ERROR if the source stream state was inconsisten
t | |
|
| (such as zalloc being NULL). msg is left unchanged in both source and | | (such as zalloc being Z_NULL). msg is left unchanged in both source and | |
| destination. | | destination. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); | | ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); | |
| /* | | /* | |
| This function is equivalent to deflateEnd followed by deflateInit, | | This function is equivalent to deflateEnd followed by deflateInit, | |
|
| but does not free and reallocate all the internal compression state. | | but does not free and reallocate all the internal compression state. Th | |
| The stream will keep the same compression level and any other attributes | | e | |
| that may have been set by deflateInit2. | | stream will keep the same compression level and any other attributes tha | |
| | | t | |
| | | may have been set by deflateInit2. | |
| | | | |
|
| deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source | | deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source | |
| stream state was inconsistent (such as zalloc or state being NULL). | | stream state was inconsistent (such as zalloc or state being Z_NULL). | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, | | ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, | |
| int level, | | int level, | |
| int strategy)); | | int strategy)); | |
| /* | | /* | |
| Dynamically update the compression level and compression strategy. Th
e | | Dynamically update the compression level and compression strategy. Th
e | |
| interpretation of level and strategy is as in deflateInit2. This can be | | interpretation of level and strategy is as in deflateInit2. This can be | |
| used to switch between compression and straight copy of the input data,
or | | used to switch between compression and straight copy of the input data,
or | |
|
| to switch to a different kind of input data requiring a different | | to switch to a different kind of input data requiring a different strate | |
| strategy. If the compression level is changed, the input available so fa | | gy. | |
| r | | If the compression level is changed, the input available so far is | |
| is compressed with the old level (and may be flushed); the new level wil | | compressed with the old level (and may be flushed); the new level will t | |
| l | | ake | |
| take effect only at the next call of deflate(). | | effect only at the next call of deflate(). | |
| | | | |
| Before the call of deflateParams, the stream state must be set as for | | Before the call of deflateParams, the stream state must be set as for | |
|
| a call of deflate(), since the currently available input may have to | | a call of deflate(), since the currently available input may have to be | |
| be compressed and flushed. In particular, strm->avail_out must be non-ze | | compressed and flushed. In particular, strm->avail_out must be non-zero | |
| ro. | | . | |
| | | | |
| deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source | | deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source | |
|
| stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR | | stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR | |
| if strm->avail_out was zero. | | if | |
| | | strm->avail_out was zero. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, | | ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, | |
| int good_length, | | int good_length, | |
| int max_lazy, | | int max_lazy, | |
| int nice_length, | | int nice_length, | |
| int max_chain)); | | int max_chain)); | |
| /* | | /* | |
| Fine tune deflate's internal compression parameters. This should only
be | | Fine tune deflate's internal compression parameters. This should only
be | |
| used by someone who understands the algorithm used by zlib's deflate for | | used by someone who understands the algorithm used by zlib's deflate for | |
| | | | |
| skipping to change at line 642 | | skipping to change at line 694 | |
| max_lazy, good_length, nice_length, and max_chain parameters. | | max_lazy, good_length, nice_length, and max_chain parameters. | |
| | | | |
| deflateTune() can be called after deflateInit() or deflateInit2(), and | | deflateTune() can be called after deflateInit() or deflateInit2(), and | |
| returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream
. | | returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream
. | |
| */ | | */ | |
| | | | |
| ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, | | ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, | |
| uLong sourceLen)); | | uLong sourceLen)); | |
| /* | | /* | |
| deflateBound() returns an upper bound on the compressed size after | | deflateBound() returns an upper bound on the compressed size after | |
|
| deflation of sourceLen bytes. It must be called after deflateInit() | | deflation of sourceLen bytes. It must be called after deflateInit() or | |
| or deflateInit2(). This would be used to allocate an output buffer | | deflateInit2(), and after deflateSetHeader(), if used. This would be us | |
| for deflation in a single pass, and so would be called before deflate(). | | ed | |
| */ | | to allocate an output buffer for deflation in a single pass, and so woul | |
| | | d be | |
| | | called before deflate(). If that first deflate() call is provided the | |
| | | sourceLen input bytes, an output buffer allocated to the size returned b | |
| | | y | |
| | | deflateBound(), and the flush value Z_FINISH, then deflate() is guarante | |
| | | ed | |
| | | to return Z_STREAM_END. Note that it is possible for the compressed siz | |
| | | e to | |
| | | be larger than the value returned by deflateBound() if flush options oth | |
| | | er | |
| | | than Z_FINISH or Z_NO_FLUSH are used. | |
| | | */ | |
| | | | |
| | | ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, | |
| | | unsigned *pending, | |
| | | int *bits)); | |
| | | /* | |
| | | deflatePending() returns the number of bytes and bits of output that h | |
| | | ave | |
| | | been generated, but not yet provided in the available output. The bytes | |
| | | not | |
| | | provided would be due to the available output space having being consume | |
| | | d. | |
| | | The number of bits of output not provided are between 0 and 7, where the | |
| | | y | |
| | | await more bits to join them in order to fill out a full byte. If pendi | |
| | | ng | |
| | | or bits are Z_NULL, then those values are not set. | |
| | | | |
| | | deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the sourc | |
| | | e | |
| | | stream state was inconsistent. | |
| | | */ | |
| | | | |
| ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, | | ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, | |
| int bits, | | int bits, | |
| int value)); | | int value)); | |
| /* | | /* | |
| deflatePrime() inserts bits in the deflate output stream. The intent | | deflatePrime() inserts bits in the deflate output stream. The intent | |
|
| is that this function is used to start off the deflate output with the | | is that this function is used to start off the deflate output with the b | |
| bits leftover from a previous deflate stream when appending to it. As su | | its | |
| ch, | | leftover from a previous deflate stream when appending to it. As such, | |
| this function can only be used for raw deflate, and must be used before t | | this | |
| he | | function can only be used for raw deflate, and must be used before the f | |
| first deflate() call after a deflateInit2() or deflateReset(). bits must | | irst | |
| be | | deflate() call after a deflateInit2() or deflateReset(). bits must be l | |
| less than or equal to 16, and that many of the least significant bits of | | ess | |
| value will be inserted in the output. | | than or equal to 16, and that many of the least significant bits of valu | |
| | | e | |
| deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source | | will be inserted in the output. | |
| stream state was inconsistent. | | | |
| | | deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not eno | |
| | | ugh | |
| | | room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the | |
| | | source stream state was inconsistent. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, | | ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, | |
| gz_headerp head)); | | gz_headerp head)); | |
| /* | | /* | |
|
| deflateSetHeader() provides gzip header information for when a gzip | | deflateSetHeader() provides gzip header information for when a gzip | |
| stream is requested by deflateInit2(). deflateSetHeader() may be called | | stream is requested by deflateInit2(). deflateSetHeader() may be called | |
| after deflateInit2() or deflateReset() and before the first call of | | after deflateInit2() or deflateReset() and before the first call of | |
| deflate(). The text, time, os, extra field, name, and comment informati
on | | deflate(). The text, time, os, extra field, name, and comment informati
on | |
| in the provided gz_header structure are written to the gzip header (xfla
g is | | in the provided gz_header structure are written to the gzip header (xfla
g is | |
| ignored -- the extra flags are set according to the compression level).
The | | ignored -- the extra flags are set according to the compression level).
The | |
| caller must assure that, if not Z_NULL, name and comment are terminated
with | | caller must assure that, if not Z_NULL, name and comment are terminated
with | |
| a zero byte, and that if extra is not Z_NULL, that extra_len bytes are | | a zero byte, and that if extra is not Z_NULL, that extra_len bytes are | |
| available there. If hcrc is true, a gzip header crc is included. Note
that | | available there. If hcrc is true, a gzip header crc is included. Note
that | |
| the current versions of the command-line version of gzip (up through ver
sion | | the current versions of the command-line version of gzip (up through ver
sion | |
| 1.3.x) do not support header crc's, and will report that it is a "multi-
part | | 1.3.x) do not support header crc's, and will report that it is a "multi-
part | |
| gzip file" and give up. | | gzip file" and give up. | |
| | | | |
|
| If deflateSetHeader is not used, the default gzip header has text fal
se, | | If deflateSetHeader is not used, the default gzip header has text fals
e, | |
| the time set to zero, and os set to 255, with no extra, name, or comment | | the time set to zero, and os set to 255, with no extra, name, or comment | |
| fields. The gzip header is returned to the default state by deflateRese
t(). | | fields. The gzip header is returned to the default state by deflateRese
t(). | |
| | | | |
|
| deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the so
urce | | deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the sou
rce | |
| stream state was inconsistent. | | stream state was inconsistent. | |
| */ | | */ | |
| | | | |
| /* | | /* | |
| ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | | ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | |
| int windowBits)); | | int windowBits)); | |
| | | | |
|
| This is another version of inflateInit with an extra parameter. The | | This is another version of inflateInit with an extra parameter. The | |
| fields next_in, avail_in, zalloc, zfree and opaque must be initialized | | fields next_in, avail_in, zalloc, zfree and opaque must be initialized | |
| before by the caller. | | before by the caller. | |
| | | | |
| The windowBits parameter is the base two logarithm of the maximum wind
ow | | The windowBits parameter is the base two logarithm of the maximum wind
ow | |
| size (the size of the history buffer). It should be in the range 8..15
for | | size (the size of the history buffer). It should be in the range 8..15
for | |
|
| this version of the library. The default value is 15 if inflateInit is u | | this version of the library. The default value is 15 if inflateInit is | |
| sed | | used | |
| instead. windowBits must be greater than or equal to the windowBits valu | | instead. windowBits must be greater than or equal to the windowBits val | |
| e | | ue | |
| provided to deflateInit2() while compressing, or it must be equal to 15
if | | provided to deflateInit2() while compressing, or it must be equal to 15
if | |
|
| deflateInit2() was not used. If a compressed stream with a larger window | | deflateInit2() was not used. If a compressed stream with a larger windo
w | |
| size is given as input, inflate() will return with the error code | | size is given as input, inflate() will return with the error code | |
| Z_DATA_ERROR instead of trying to allocate a larger window. | | Z_DATA_ERROR instead of trying to allocate a larger window. | |
| | | | |
|
| windowBits can also be -8..-15 for raw inflate. In this case, -windowB | | windowBits can also be zero to request that inflate use the window siz | |
| its | | e in | |
| determines the window size. inflate() will then process raw deflate data | | the zlib header of the compressed stream. | |
| , | | | |
| | | windowBits can also be -8..-15 for raw inflate. In this case, -window | |
| | | Bits | |
| | | determines the window size. inflate() will then process raw deflate dat | |
| | | a, | |
| not looking for a zlib or gzip header, not generating a check value, and
not | | not looking for a zlib or gzip header, not generating a check value, and
not | |
|
| looking for any check values for comparison at the end of the stream. Th
is | | looking for any check values for comparison at the end of the stream. T
his | |
| is for use with other formats that use the deflate compressed data forma
t | | is for use with other formats that use the deflate compressed data forma
t | |
|
| such as zip. Those formats provide their own check values. If a custom | | such as zip. Those formats provide their own check values. If a custom | |
| format is developed using the raw deflate format for compressed data, it
is | | format is developed using the raw deflate format for compressed data, it
is | |
| recommended that a check value such as an adler32 or a crc32 be applied
to | | recommended that a check value such as an adler32 or a crc32 be applied
to | |
| the uncompressed data as is done in the zlib, gzip, and zip formats. Fo
r | | the uncompressed data as is done in the zlib, gzip, and zip formats. Fo
r | |
|
| most applications, the zlib format should be used as is. Note that comme
nts | | most applications, the zlib format should be used as is. Note that comm
ents | |
| above on the use in deflateInit2() applies to the magnitude of windowBit
s. | | above on the use in deflateInit2() applies to the magnitude of windowBit
s. | |
| | | | |
|
| windowBits can also be greater than 15 for optional gzip decoding. Add | | windowBits can also be greater than 15 for optional gzip decoding. Ad
d | |
| 32 to windowBits to enable zlib and gzip decoding with automatic header | | 32 to windowBits to enable zlib and gzip decoding with automatic header | |
| detection, or add 16 to decode only the gzip format (the zlib format wil
l | | detection, or add 16 to decode only the gzip format (the zlib format wil
l | |
|
| return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler | | return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler | |
| is | | is a | |
| a crc32 instead of an adler32. | | crc32 instead of an adler32. | |
| | | | |
| inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not eno
ugh | | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not eno
ugh | |
|
| memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). | | memory, Z_VERSION_ERROR if the zlib library version is incompatible with | |
| msg | | the | |
| is set to null if there is no error message. inflateInit2 does not perf | | version assumed by the caller, or Z_STREAM_ERROR if the parameters are | |
| orm | | invalid, such as a null pointer to the structure. msg is set to null if | |
| any decompression apart from reading the zlib header if present: this wi | | there is no error message. inflateInit2 does not perform any decompress | |
| ll | | ion | |
| be done by inflate(). (So next_in and avail_in may be modified, but next | | apart from possibly reading the zlib header if present: actual decompres | |
| _out | | sion | |
| and avail_out are unchanged.) | | will be done by inflate(). (So next_in and avail_in may be modified, bu | |
| | | t | |
| | | next_out and avail_out are unused and unchanged.) The current implementa | |
| | | tion | |
| | | of inflateInit2() does not process any header information -- that is | |
| | | deferred until inflate() is called. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, | | ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, | |
| const Bytef *dictionary, | | const Bytef *dictionary, | |
| uInt dictLength)); | | uInt dictLength)); | |
| /* | | /* | |
| Initializes the decompression dictionary from the given uncompressed b
yte | | Initializes the decompression dictionary from the given uncompressed b
yte | |
|
| sequence. This function must be called immediately after a call of infla | | sequence. This function must be called immediately after a call of infl | |
| te, | | ate, | |
| if that call returned Z_NEED_DICT. The dictionary chosen by the compress | | if that call returned Z_NEED_DICT. The dictionary chosen by the compres | |
| or | | sor | |
| can be determined from the adler32 value returned by that call of inflat
e. | | can be determined from the adler32 value returned by that call of inflat
e. | |
| The compressor and decompressor must use exactly the same dictionary (se
e | | The compressor and decompressor must use exactly the same dictionary (se
e | |
|
| deflateSetDictionary). For raw inflate, this function can be called | | deflateSetDictionary). For raw inflate, this function can be called at | |
| immediately after inflateInit2() or inflateReset() and before any call o | | any | |
| f | | time to set the dictionary. If the provided dictionary is smaller than | |
| inflate() to set the dictionary. The application must insure that the | | the | |
| dictionary that was used for compression is provided. | | window and there is already data in the window, then the provided dictio | |
| | | nary | |
| | | will amend what's there. The application must insure that the dictionar | |
| | | y | |
| | | that was used for compression is provided. | |
| | | | |
| inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a | | inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a | |
|
| parameter is invalid (such as NULL dictionary) or the stream state is | | parameter is invalid (e.g. dictionary being Z_NULL) or the stream state
is | |
| inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the | | inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the | |
|
| expected one (incorrect adler32 value). inflateSetDictionary does not | | expected one (incorrect adler32 value). inflateSetDictionary does not | |
| perform any decompression: this will be done by subsequent calls of | | perform any decompression: this will be done by subsequent calls of | |
| inflate(). | | inflate(). | |
| */ | | */ | |
| | | | |
|
| | | ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, | |
| | | Bytef *dictionary, | |
| | | uInt *dictLength)); | |
| | | /* | |
| | | Returns the sliding dictionary being maintained by inflate. dictLengt | |
| | | h is | |
| | | set to the number of bytes in the dictionary, and that many bytes are co | |
| | | pied | |
| | | to dictionary. dictionary must have enough space, where 32768 bytes is | |
| | | always enough. If inflateGetDictionary() is called with dictionary equa | |
| | | l to | |
| | | Z_NULL, then only the dictionary length is returned, and nothing is copi | |
| | | ed. | |
| | | Similary, if dictLength is Z_NULL, then it is not set. | |
| | | | |
| | | inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the | |
| | | stream state is inconsistent. | |
| | | */ | |
| | | | |
| ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); | | ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); | |
| /* | | /* | |
|
| Skips invalid compressed data until a full flush point (see above the | | Skips invalid compressed data until a possible full flush point (see a | |
| description of deflate with Z_FULL_FLUSH) can be found, or until all | | bove | |
| available input is skipped. No output is provided. | | for the description of deflate with Z_FULL_FLUSH) can be found, or until | |
| | | all | |
| inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ER | | available input is skipped. No output is provided. | |
| ROR | | | |
| if no more input was provided, Z_DATA_ERROR if no flush point has been fo | | inflateSync searches for a 00 00 FF FF pattern in the compressed data. | |
| und, | | All full flush points have this pattern, but not all occurrences of this | |
| or Z_STREAM_ERROR if the stream structure was inconsistent. In the succes | | pattern are full flush points. | |
| s | | | |
| case, the application may save the current current value of total_in whic | | inflateSync returns Z_OK if a possible full flush point has been found | |
| h | | , | |
| indicates where valid compressed data was found. In the error case, the | | Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush poin | |
| application may repeatedly call inflateSync, providing more input each ti | | t | |
| me, | | has been found, or Z_STREAM_ERROR if the stream structure was inconsiste | |
| until success or end of the input data. | | nt. | |
| | | In the success case, the application may save the current current value | |
| | | of | |
| | | total_in which indicates where valid compressed data was found. In the | |
| | | error case, the application may repeatedly call inflateSync, providing m | |
| | | ore | |
| | | input each time, until success or end of the input data. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, | | ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, | |
| z_streamp source)); | | z_streamp source)); | |
| /* | | /* | |
| Sets the destination stream as a complete copy of the source stream. | | Sets the destination stream as a complete copy of the source stream. | |
| | | | |
| This function can be useful when randomly accessing a large stream. T
he | | This function can be useful when randomly accessing a large stream. T
he | |
| first pass through the stream can periodically record the inflate state, | | first pass through the stream can periodically record the inflate state, | |
| allowing restarting inflate at those points when randomly accessing the | | allowing restarting inflate at those points when randomly accessing the | |
| stream. | | stream. | |
| | | | |
| inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not | | inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not | |
| enough memory, Z_STREAM_ERROR if the source stream state was inconsisten
t | | enough memory, Z_STREAM_ERROR if the source stream state was inconsisten
t | |
|
| (such as zalloc being NULL). msg is left unchanged in both source and | | (such as zalloc being Z_NULL). msg is left unchanged in both source and | |
| destination. | | destination. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); | | ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); | |
| /* | | /* | |
| This function is equivalent to inflateEnd followed by inflateInit, | | This function is equivalent to inflateEnd followed by inflateInit, | |
|
| but does not free and reallocate all the internal decompression state. | | but does not free and reallocate all the internal decompression state. | |
| The stream will keep attributes that may have been set by inflateInit2. | | The | |
| | | stream will keep attributes that may have been set by inflateInit2. | |
| | | | |
| | | inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source | |
| | | stream state was inconsistent (such as zalloc or state being Z_NULL). | |
| | | */ | |
| | | | |
|
| inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source | | ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, | |
| stream state was inconsistent (such as zalloc or state being NULL). | | int windowBits)); | |
| | | /* | |
| | | This function is the same as inflateReset, but it also permits changin | |
| | | g | |
| | | the wrap and window size requests. The windowBits parameter is interpre | |
| | | ted | |
| | | the same as it is for inflateInit2. | |
| | | | |
| | | inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source | |
| | | stream state was inconsistent (such as zalloc or state being Z_NULL), or | |
| | | if | |
| | | the windowBits parameter is invalid. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, | | ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, | |
| int bits, | | int bits, | |
| int value)); | | int value)); | |
| /* | | /* | |
| This function inserts bits in the inflate input stream. The intent is | | This function inserts bits in the inflate input stream. The intent is | |
|
| that this function is used to start inflating at a bit position in the | | that this function is used to start inflating at a bit position in the | |
| middle of a byte. The provided bits will be used before any bytes are us | | middle of a byte. The provided bits will be used before any bytes are u | |
| ed | | sed | |
| from next_in. This function should only be used with raw inflate, and | | from next_in. This function should only be used with raw inflate, and | |
| should be used before the first inflate() call after inflateInit2() or | | should be used before the first inflate() call after inflateInit2() or | |
| inflateReset(). bits must be less than or equal to 16, and that many of | | inflateReset(). bits must be less than or equal to 16, and that many of | |
| the | | the | |
| least significant bits of value will be inserted in the input. | | least significant bits of value will be inserted in the input. | |
| | | | |
| | | If bits is negative, then the input stream bit buffer is emptied. The | |
| | | n | |
| | | inflatePrime() can be called again to put bits in the buffer. This is u | |
| | | sed | |
| | | to clear out bits leftover after feeding inflate a block description pri | |
| | | or | |
| | | to feeding inflate codes. | |
| | | | |
|
| inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source | | inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source | |
| stream state was inconsistent. | | stream state was inconsistent. | |
| */ | | */ | |
| | | | |
|
| | | ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); | |
| | | /* | |
| | | This function returns two values, one in the lower 16 bits of the retu | |
| | | rn | |
| | | value, and the other in the remaining upper bits, obtained by shifting t | |
| | | he | |
| | | return value down 16 bits. If the upper value is -1 and the lower value | |
| | | is | |
| | | zero, then inflate() is currently decoding information outside of a bloc | |
| | | k. | |
| | | If the upper value is -1 and the lower value is non-zero, then inflate i | |
| | | s in | |
| | | the middle of a stored block, with the lower value equaling the number o | |
| | | f | |
| | | bytes from the input remaining to copy. If the upper value is not -1, t | |
| | | hen | |
| | | it is the number of bits back from the current bit position in the input | |
| | | of | |
| | | the code (literal or length/distance pair) currently being processed. I | |
| | | n | |
| | | that case the lower value is the number of bytes already emitted for tha | |
| | | t | |
| | | code. | |
| | | | |
| | | A code is being processed if inflate is waiting for more input to comp | |
| | | lete | |
| | | decoding of the code, or if it has completed decoding but is waiting for | |
| | | more output space to write the literal or match data. | |
| | | | |
| | | inflateMark() is used to mark locations in the input data for random | |
| | | access, which may be at bit positions, and to note those cases where the | |
| | | output of a code may span boundaries of random access blocks. The curre | |
| | | nt | |
| | | location in the input stream can be determined from avail_in and data_ty | |
| | | pe | |
| | | as noted in the description for the Z_BLOCK flush parameter for inflate. | |
| | | | |
| | | inflateMark returns the value noted above or -1 << 16 if the provided | |
| | | source stream state was inconsistent. | |
| | | */ | |
| | | | |
| ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, | | ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, | |
| gz_headerp head)); | | gz_headerp head)); | |
| /* | | /* | |
|
| inflateGetHeader() requests that gzip header information be stored in
the | | inflateGetHeader() requests that gzip header information be stored in
the | |
| provided gz_header structure. inflateGetHeader() may be called after | | provided gz_header structure. inflateGetHeader() may be called after | |
| inflateInit2() or inflateReset(), and before the first call of inflate()
. | | inflateInit2() or inflateReset(), and before the first call of inflate()
. | |
| As inflate() processes the gzip stream, head->done is zero until the hea
der | | As inflate() processes the gzip stream, head->done is zero until the hea
der | |
| is completed, at which time head->done is set to one. If a zlib stream
is | | is completed, at which time head->done is set to one. If a zlib stream
is | |
| being decoded, then head->done is set to -1 to indicate that there will
be | | being decoded, then head->done is set to -1 to indicate that there will
be | |
|
| no gzip header information forthcoming. Note that Z_BLOCK can be used t | | no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES ca | |
| o | | n be | |
| force inflate() to return immediately after header processing is complet | | used to force inflate() to return immediately after header processing is | |
| e | | complete and before any actual data is decompressed. | |
| and before any actual data is decompressed. | | | |
| | | | |
|
| The text, time, xflags, and os fields are filled in with the gzip hea
der | | The text, time, xflags, and os fields are filled in with the gzip head
er | |
| contents. hcrc is set to true if there is a header CRC. (The header CR
C | | contents. hcrc is set to true if there is a header CRC. (The header CR
C | |
|
| was valid if done is set to one.) If extra is not Z_NULL, then extra_ma
x | | was valid if done is set to one.) If extra is not Z_NULL, then extra_max | |
| contains the maximum number of bytes to write to extra. Once done is tr
ue, | | contains the maximum number of bytes to write to extra. Once done is tr
ue, | |
| extra_len contains the actual extra field length, and extra contains the | | extra_len contains the actual extra field length, and extra contains the | |
| extra field, or that field truncated if extra_max is less than extra_len
. | | extra field, or that field truncated if extra_max is less than extra_len
. | |
| If name is not Z_NULL, then up to name_max characters are written there, | | If name is not Z_NULL, then up to name_max characters are written there, | |
| terminated with a zero unless the length is greater than name_max. If | | terminated with a zero unless the length is greater than name_max. If | |
| comment is not Z_NULL, then up to comm_max characters are written there, | | comment is not Z_NULL, then up to comm_max characters are written there, | |
|
| terminated with a zero unless the length is greater than comm_max. When | | terminated with a zero unless the length is greater than comm_max. When | |
| any of extra, name, or comment are not Z_NULL and the respective field i | | any | |
| s | | of extra, name, or comment are not Z_NULL and the respective field is no | |
| not present in the header, then that field is set to Z_NULL to signal it | | t | |
| s | | present in the header, then that field is set to Z_NULL to signal its | |
| absence. This allows the use of deflateSetHeader() with the returned | | absence. This allows the use of deflateSetHeader() with the returned | |
| structure to duplicate the header. However if those fields are set to | | structure to duplicate the header. However if those fields are set to | |
| allocated memory, then the application will need to save those pointers | | allocated memory, then the application will need to save those pointers | |
| elsewhere so that they can be eventually freed. | | elsewhere so that they can be eventually freed. | |
| | | | |
|
| If inflateGetHeader is not used, then the header information is simpl
y | | If inflateGetHeader is not used, then the header information is simply | |
| discarded. The header is always checked for validity, including the hea
der | | discarded. The header is always checked for validity, including the hea
der | |
| CRC if present. inflateReset() will reset the process to discard the he
ader | | CRC if present. inflateReset() will reset the process to discard the he
ader | |
| information. The application would need to call inflateGetHeader() agai
n to | | information. The application would need to call inflateGetHeader() agai
n to | |
| retrieve the header from the next gzip stream. | | retrieve the header from the next gzip stream. | |
| | | | |
|
| inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the so
urce | | inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the sou
rce | |
| stream state was inconsistent. | | stream state was inconsistent. | |
| */ | | */ | |
| | | | |
| /* | | /* | |
| ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, | | ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, | |
| unsigned char FAR *window)); | | unsigned char FAR *window)); | |
| | | | |
| Initialize the internal stream state for decompression using inflateBa
ck() | | Initialize the internal stream state for decompression using inflateBa
ck() | |
| calls. The fields zalloc, zfree and opaque in strm must be initialized | | calls. The fields zalloc, zfree and opaque in strm must be initialized | |
| before the call. If zalloc and zfree are Z_NULL, then the default libra
ry- | | before the call. If zalloc and zfree are Z_NULL, then the default libra
ry- | |
| derived memory allocation routines are used. windowBits is the base two | | derived memory allocation routines are used. windowBits is the base two | |
| logarithm of the window size, in the range 8..15. window is a caller | | logarithm of the window size, in the range 8..15. window is a caller | |
| supplied buffer of that size. Except for special applications where it
is | | supplied buffer of that size. Except for special applications where it
is | |
| assured that deflate was used with small window sizes, windowBits must b
e 15 | | assured that deflate was used with small window sizes, windowBits must b
e 15 | |
| and a 32K byte window must be supplied to be able to decompress general | | and a 32K byte window must be supplied to be able to decompress general | |
| deflate streams. | | deflate streams. | |
| | | | |
| See inflateBack() for the usage of these routines. | | See inflateBack() for the usage of these routines. | |
| | | | |
| inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of | | inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of | |
|
| the paramaters are invalid, Z_MEM_ERROR if the internal state could not | | the parameters are invalid, Z_MEM_ERROR if the internal state could not | |
| be allocated, or Z_VERSION_ERROR if the version of the library does not | | be | |
| match the version of the header file. | | allocated, or Z_VERSION_ERROR if the version of the library does not mat | |
| | | ch | |
| | | the version of the header file. | |
| */ | | */ | |
| | | | |
|
| typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); | | typedef unsigned (*in_func) OF((void FAR *, | |
| | | z_const unsigned char FAR * FAR *)); | |
| typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); | | typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); | |
| | | | |
| ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, | | ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, | |
| in_func in, void FAR *in_desc, | | in_func in, void FAR *in_desc, | |
| out_func out, void FAR *out_desc)); | | out_func out, void FAR *out_desc)); | |
| /* | | /* | |
| inflateBack() does a raw inflate with a single call using a call-back | | inflateBack() does a raw inflate with a single call using a call-back | |
|
| interface for input and output. This is more efficient than inflate() f | | interface for input and output. This is potentially more efficient than | |
| or | | inflate() for file i/o applications, in that it avoids copying between t | |
| file i/o applications in that it avoids copying between the output and t | | he | |
| he | | output and the sliding window by simply making the window itself the out | |
| sliding window by simply making the window itself the output buffer. Th | | put | |
| is | | buffer. inflate() can be faster on modern CPUs when used with large | |
| function trusts the application to not change the output buffer passed b | | buffers. inflateBack() trusts the application to not change the output | |
| y | | buffer passed by the output function, at least until inflateBack() retur | |
| the output function, at least until inflateBack() returns. | | ns. | |
| | | | |
| inflateBackInit() must be called first to allocate the internal state | | inflateBackInit() must be called first to allocate the internal state | |
| and to initialize the state with the user-provided window buffer. | | and to initialize the state with the user-provided window buffer. | |
| inflateBack() may then be used multiple times to inflate a complete, raw | | inflateBack() may then be used multiple times to inflate a complete, raw | |
|
| deflate stream with each call. inflateBackEnd() is then called to free | | deflate stream with each call. inflateBackEnd() is then called to free | |
| the allocated state. | | the | |
| | | allocated state. | |
| | | | |
| A raw deflate stream is one with no zlib or gzip header or trailer. | | A raw deflate stream is one with no zlib or gzip header or trailer. | |
| This routine would normally be used in a utility that reads zip or gzip | | This routine would normally be used in a utility that reads zip or gzip | |
| files and writes out uncompressed files. The utility would decode the | | files and writes out uncompressed files. The utility would decode the | |
|
| header and process the trailer on its own, hence this routine expects | | header and process the trailer on its own, hence this routine expects on | |
| only the raw deflate stream to decompress. This is different from the | | ly | |
| normal behavior of inflate(), which expects either a zlib or gzip header | | the raw deflate stream to decompress. This is different from the normal | |
| and | | behavior of inflate(), which expects either a zlib or gzip header and | |
| trailer around the deflate stream. | | trailer around the deflate stream. | |
| | | | |
| inflateBack() uses two subroutines supplied by the caller that are the
n | | inflateBack() uses two subroutines supplied by the caller that are the
n | |
| called by inflateBack() for input and output. inflateBack() calls those | | called by inflateBack() for input and output. inflateBack() calls those | |
| routines until it reads a complete deflate stream and writes out all of
the | | routines until it reads a complete deflate stream and writes out all of
the | |
| uncompressed data, or until it encounters an error. The function's | | uncompressed data, or until it encounters an error. The function's | |
| parameters and return types are defined above in the in_func and out_fun
c | | parameters and return types are defined above in the in_func and out_fun
c | |
| typedefs. inflateBack() will call in(in_desc, &buf) which should return
the | | typedefs. inflateBack() will call in(in_desc, &buf) which should return
the | |
| number of bytes of provided input, and a pointer to that input in buf.
If | | number of bytes of provided input, and a pointer to that input in buf.
If | |
| there is no input available, in() must return zero--buf is ignored in th
at | | there is no input available, in() must return zero--buf is ignored in th
at | |
| | | | |
| skipping to change at line 922 | | skipping to change at line 1070 | |
| inflateBackInit(), which is also the buffer that out() uses to write fro
m. | | inflateBackInit(), which is also the buffer that out() uses to write fro
m. | |
| The length written by out() will be at most the window size. Any non-ze
ro | | The length written by out() will be at most the window size. Any non-ze
ro | |
| amount of input may be provided by in(). | | amount of input may be provided by in(). | |
| | | | |
| For convenience, inflateBack() can be provided input on the first call
by | | For convenience, inflateBack() can be provided input on the first call
by | |
| setting strm->next_in and strm->avail_in. If that input is exhausted, t
hen | | setting strm->next_in and strm->avail_in. If that input is exhausted, t
hen | |
| in() will be called. Therefore strm->next_in must be initialized before | | in() will be called. Therefore strm->next_in must be initialized before | |
| calling inflateBack(). If strm->next_in is Z_NULL, then in() will be ca
lled | | calling inflateBack(). If strm->next_in is Z_NULL, then in() will be ca
lled | |
| immediately for input. If strm->next_in is not Z_NULL, then strm->avail
_in | | immediately for input. If strm->next_in is not Z_NULL, then strm->avail
_in | |
| must also be initialized, and then if strm->avail_in is not zero, input
will | | must also be initialized, and then if strm->avail_in is not zero, input
will | |
|
| initially be taken from strm->next_in[0 .. strm->avail_in - 1]. | | initially be taken from strm->next_in[0 .. strm->avail_in - 1]. | |
| | | | |
| The in_desc and out_desc parameters of inflateBack() is passed as the | | The in_desc and out_desc parameters of inflateBack() is passed as the | |
| first parameter of in() and out() respectively when they are called. Th
ese | | first parameter of in() and out() respectively when they are called. Th
ese | |
| descriptors can be optionally used to pass any information that the call
er- | | descriptors can be optionally used to pass any information that the call
er- | |
| supplied in() and out() functions need to do their job. | | supplied in() and out() functions need to do their job. | |
| | | | |
| On return, inflateBack() will set strm->next_in and strm->avail_in to | | On return, inflateBack() will set strm->next_in and strm->avail_in to | |
| pass back any unused input that was provided by the last in() call. The | | pass back any unused input that was provided by the last in() call. The | |
| return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERR
OR | | return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERR
OR | |
|
| if in() or out() returned an error, Z_DATA_ERROR if there was a format | | if in() or out() returned an error, Z_DATA_ERROR if there was a format e | |
| error in the deflate stream (in which case strm->msg is set to indicate | | rror | |
| the | | in the deflate stream (in which case strm->msg is set to indicate the na | |
| nature of the error), or Z_STREAM_ERROR if the stream was not properly | | ture | |
| initialized. In the case of Z_BUF_ERROR, an input or output error can b | | of the error), or Z_STREAM_ERROR if the stream was not properly initiali | |
| e | | zed. | |
| distinguished using strm->next_in which will be Z_NULL only if in() retu | | In the case of Z_BUF_ERROR, an input or output error can be distinguishe | |
| rned | | d | |
| an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to | | using strm->next_in which will be Z_NULL only if in() returned an error. | |
| out() returning non-zero. (in() will always be called before out(), so | | If | |
| strm->next_in is assured to be defined if out() returns non-zero.) Note | | strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() retur | |
| that inflateBack() cannot return Z_OK. | | ning | |
| | | non-zero. (in() will always be called before out(), so strm->next_in is | |
| | | assured to be defined if out() returns non-zero.) Note that inflateBack( | |
| | | ) | |
| | | cannot return Z_OK. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); | | ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); | |
| /* | | /* | |
| All memory allocated by inflateBackInit() is freed. | | All memory allocated by inflateBackInit() is freed. | |
| | | | |
| inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the str
eam | | inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the str
eam | |
| state was inconsistent. | | state was inconsistent. | |
| */ | | */ | |
| | | | |
| | | | |
| skipping to change at line 992 | | skipping to change at line 1140 | |
| | | | |
| The sprintf variant used by gzprintf (zero is best): | | The sprintf variant used by gzprintf (zero is best): | |
| 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the forma
t | | 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the forma
t | |
| 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! | | 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! | |
| 26: 0 = returns value, 1 = void -- 1 means inferred string length retu
rned | | 26: 0 = returns value, 1 = void -- 1 means inferred string length retu
rned | |
| | | | |
| Remainder: | | Remainder: | |
| 27-31: 0 (reserved) | | 27-31: 0 (reserved) | |
| */ | | */ | |
| | | | |
|
| | | #ifndef Z_SOLO | |
| | | | |
| /* utility functions */ | | /* utility functions */ | |
| | | | |
| /* | | /* | |
|
| The following utility functions are implemented on top of the | | The following utility functions are implemented on top of the basic | |
| basic stream-oriented functions. To simplify the interface, some | | stream-oriented functions. To simplify the interface, some default opti | |
| default options are assumed (compression level and memory usage, | | ons | |
| standard memory allocation functions). The source code of these | | are assumed (compression level and memory usage, standard memory allocat | |
| utility functions can easily be modified if you need special options. | | ion | |
| | | functions). The source code of these utility functions can be modified | |
| | | if | |
| | | you need special options. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, | | ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, | |
| const Bytef *source, uLong sourceLen)); | | const Bytef *source, uLong sourceLen)); | |
| /* | | /* | |
| Compresses the source buffer into the destination buffer. sourceLen i
s | | Compresses the source buffer into the destination buffer. sourceLen i
s | |
|
| the byte length of the source buffer. Upon entry, destLen is the total | | the byte length of the source buffer. Upon entry, destLen is the total | |
| size of the destination buffer, which must be at least the value returne | | size | |
| d | | of the destination buffer, which must be at least the value returned by | |
| by compressBound(sourceLen). Upon exit, destLen is the actual size of th | | compressBound(sourceLen). Upon exit, destLen is the actual size of the | |
| e | | | |
| compressed buffer. | | compressed buffer. | |
|
| This function can be used to compress a whole file at once if the | | | |
| input file is mmap'ed. | | | |
| compress returns Z_OK if success, Z_MEM_ERROR if there was not | | compress returns Z_OK if success, Z_MEM_ERROR if there was not | |
| enough memory, Z_BUF_ERROR if there was not enough room in the output | | enough memory, Z_BUF_ERROR if there was not enough room in the output | |
| buffer. | | buffer. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, | | ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, | |
| const Bytef *source, uLong sourceLen, | | const Bytef *source, uLong sourceLen, | |
| int level)); | | int level)); | |
| /* | | /* | |
|
| Compresses the source buffer into the destination buffer. The level | | Compresses the source buffer into the destination buffer. The level | |
| parameter has the same meaning as in deflateInit. sourceLen is the byte | | parameter has the same meaning as in deflateInit. sourceLen is the byte | |
|
| length of the source buffer. Upon entry, destLen is the total size of th
e | | length of the source buffer. Upon entry, destLen is the total size of t
he | |
| destination buffer, which must be at least the value returned by | | destination buffer, which must be at least the value returned by | |
|
| compressBound(sourceLen). Upon exit, destLen is the actual size of the | | compressBound(sourceLen). Upon exit, destLen is the actual size of the | |
| compressed buffer. | | compressed buffer. | |
| | | | |
| compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough | | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough | |
| memory, Z_BUF_ERROR if there was not enough room in the output buffer, | | memory, Z_BUF_ERROR if there was not enough room in the output buffer, | |
| Z_STREAM_ERROR if the level parameter is invalid. | | Z_STREAM_ERROR if the level parameter is invalid. | |
| */ | | */ | |
| | | | |
| ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); | | ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); | |
| /* | | /* | |
| compressBound() returns an upper bound on the compressed size after | | compressBound() returns an upper bound on the compressed size after | |
|
| compress() or compress2() on sourceLen bytes. It would be used before | | compress() or compress2() on sourceLen bytes. It would be used before a | |
| a compress() or compress2() call to allocate the destination buffer. | | compress() or compress2() call to allocate the destination buffer. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, | | ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, | |
| const Bytef *source, uLong sourceLen)); | | const Bytef *source, uLong sourceLen)); | |
| /* | | /* | |
| Decompresses the source buffer into the destination buffer. sourceLen
is | | Decompresses the source buffer into the destination buffer. sourceLen
is | |
|
| the byte length of the source buffer. Upon entry, destLen is the total | | the byte length of the source buffer. Upon entry, destLen is the total | |
| size of the destination buffer, which must be large enough to hold the | | size | |
| entire uncompressed data. (The size of the uncompressed data must have | | of the destination buffer, which must be large enough to hold the entire | |
| been saved previously by the compressor and transmitted to the decompres | | uncompressed data. (The size of the uncompressed data must have been sa | |
| sor | | ved | |
| by some mechanism outside the scope of this compression library.) | | previously by the compressor and transmitted to the decompressor by some | |
| Upon exit, destLen is the actual size of the compressed buffer. | | mechanism outside the scope of this compression library.) Upon exit, des | |
| This function can be used to decompress a whole file at once if the | | tLen | |
| input file is mmap'ed. | | is the actual size of the uncompressed buffer. | |
| | | | |
| uncompress returns Z_OK if success, Z_MEM_ERROR if there was not | | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not | |
| enough memory, Z_BUF_ERROR if there was not enough room in the output | | enough memory, Z_BUF_ERROR if there was not enough room in the output | |
|
| buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. | | buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. | |
| | | In | |
| | | the case where there is not enough room, uncompress() will fill the outp | |
| | | ut | |
| | | buffer with the uncompressed data up to that point. | |
| */ | | */ | |
| | | | |
|
| typedef voidp gzFile; | | /* gzip file access functions */ | |
| | | | |
|
| ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); | | | |
| /* | | /* | |
|
| Opens a gzip (.gz) file for reading or writing. The mode parameter | | This library supports reading and writing files in gzip (.gz) format w | |
| is as in fopen ("rb" or "wb") but can also include a compression level | | ith | |
| ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for | | an interface similar to that of stdio, using the functions that start wi | |
| Huffman only compression as in "wb1h", or 'R' for run-length encoding | | th | |
| as in "wb1R". (See the description of deflateInit2 for more information | | "gz". The gzip format is different from the zlib format. gzip is a gzi | |
| about the strategy parameter.) | | p | |
| | | wrapper, documented in RFC 1952, wrapped around a deflate stream. | |
| | | */ | |
| | | | |
| | | typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ | |
| | | | |
| | | /* | |
| | | ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); | |
| | | | |
| | | Opens a gzip (.gz) file for reading or writing. The mode parameter is | |
| | | as | |
| | | in fopen ("rb" or "wb") but can also include a compression level ("wb9") | |
| | | or | |
| | | a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only | |
| | | compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or ' | |
| | | F' | |
| | | for fixed code compression as in "wb9F". (See the description of | |
| | | deflateInit2 for more information about the strategy parameter.) 'T' wi | |
| | | ll | |
| | | request transparent writing or appending with no compression and not usi | |
| | | ng | |
| | | the gzip format. | |
| | | | |
| | | "a" can be used instead of "w" to request that the gzip stream that wi | |
| | | ll | |
| | | be written be appended to the file. "+" will result in an error, since | |
| | | reading and writing to the same gzip file is not supported. The additio | |
| | | n of | |
| | | "x" when writing will create the file exclusively, which fails if the fi | |
| | | le | |
| | | already exists. On systems that support it, the addition of "e" when | |
| | | reading or writing will set the flag to close the file on an execve() ca | |
| | | ll. | |
| | | | |
| | | These functions, as well as gzip, will read and decode a sequence of g | |
| | | zip | |
| | | streams in a file. The append function of gzopen() can be used to creat | |
| | | e | |
| | | such a file. (Also see gzflush() for another way to do this.) When | |
| | | appending, gzopen does not test whether the file begins with a gzip stre | |
| | | am, | |
| | | nor does it look for the end of the gzip streams to begin appending. gz | |
| | | open | |
| | | will simply append a gzip stream to the existing file. | |
| | | | |
| gzopen can be used to read a file which is not in gzip format; in this | | gzopen can be used to read a file which is not in gzip format; in this | |
|
| case gzread will directly read from the file without decompression. | | case gzread will directly read from the file without decompression. Whe | |
| | | n | |
| | | reading, this will be detected automatically by looking for the magic tw | |
| | | o- | |
| | | byte gzip header. | |
| | | | |
| | | gzopen returns NULL if the file could not be opened, if there was | |
| | | insufficient memory to allocate the gzFile state, or if an invalid mode | |
| | | was | |
| | | specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). | |
| | | errno can be checked to determine if the reason gzopen failed was that t | |
| | | he | |
| | | file could not be opened. | |
| | | */ | |
| | | | |
| | | ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); | |
| | | /* | |
| | | gzdopen associates a gzFile with the file descriptor fd. File descrip | |
| | | tors | |
| | | are obtained from calls like open, dup, creat, pipe or fileno (if the fi | |
| | | le | |
| | | has been previously opened with fopen). The mode parameter is as in gzo | |
| | | pen. | |
| | | | |
| | | The next call of gzclose on the returned gzFile will also close the fi | |
| | | le | |
| | | descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descri | |
| | | ptor | |
| | | fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd | |
| | | , | |
| | | mode);. The duplicated descriptor should be saved to avoid a leak, sinc | |
| | | e | |
| | | gzdopen does not close fd if it fails. If you are using fileno() to get | |
| | | the | |
| | | file descriptor from a FILE *, then you will have to use dup() to avoid | |
| | | double-close()ing the file descriptor. Both gzclose() and fclose() will | |
| | | close the associated file descriptor, so they need to have different fil | |
| | | e | |
| | | descriptors. | |
| | | | |
| | | gzdopen returns NULL if there was insufficient memory to allocate the | |
| | | gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was | |
| | | not | |
| | | provided, or '+' was provided), or if fd is -1. The file descriptor is | |
| | | not | |
| | | used until the next gz* read, write, seek, or close operation, so gzdope | |
| | | n | |
| | | will not detect if fd is invalid (unless fd is -1). | |
| | | */ | |
| | | | |
| | | ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); | |
| | | /* | |
| | | Set the internal buffer size used by this library's functions. The | |
| | | default buffer size is 8192 bytes. This function must be called after | |
| | | gzopen() or gzdopen(), and before any other calls that read or write the | |
| | | file. The buffer memory allocation is always deferred to the first read | |
| | | or | |
| | | write. Two buffers are allocated, either both of the specified size whe | |
| | | n | |
| | | writing, or one of the specified size and the other twice that size when | |
| | | reading. A larger buffer size of, for example, 64K or 128K bytes will | |
| | | noticeably increase the speed of decompression (reading). | |
| | | | |
|
| gzopen returns NULL if the file could not be opened or if there was | | The new buffer size also affects the maximum length for gzprintf(). | |
| insufficient memory to allocate the (de)compression state; errno | | | |
| can be checked to distinguish the two cases (if errno is zero, the | | gzbuffer() returns 0 on success, or -1 on failure, such as being calle | |
| zlib error is Z_MEM_ERROR). */ | | d | |
| | | too late. | |
| ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); | | | |
| /* | | | |
| gzdopen() associates a gzFile with the file descriptor fd. File | | | |
| descriptors are obtained from calls like open, dup, creat, pipe or | | | |
| fileno (in the file has been previously opened with fopen). | | | |
| The mode parameter is as in gzopen. | | | |
| The next call of gzclose on the returned gzFile will also close the | | | |
| file descriptor fd, just like fclose(fdopen(fd), mode) closes the file | | | |
| descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). | | | |
| gzdopen returns NULL if there was insufficient memory to allocate | | | |
| the (de)compression state. | | | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | | ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | |
| /* | | /* | |
|
| Dynamically update the compression level or strategy. See the descript
ion | | Dynamically update the compression level or strategy. See the descrip
tion | |
| of deflateInit2 for the meaning of these parameters. | | of deflateInit2 for the meaning of these parameters. | |
|
| | | | |
| gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was
not | | gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was
not | |
| opened for writing. | | opened for writing. | |
| */ | | */ | |
| | | | |
|
| ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | |
| /* | | /* | |
|
| Reads the given number of uncompressed bytes from the compressed file. | | Reads the given number of uncompressed bytes from the compressed file. | |
| If the input file was not in gzip format, gzread copies the given number | | If | |
| of bytes into the buffer. | | the input file is not in gzip format, gzread copies the given number of | |
| gzread returns the number of uncompressed bytes actually read (0 for | | bytes into the buffer directly from the file. | |
| end of file, -1 for error). */ | | | |
| | | After reaching the end of a gzip stream in the input, gzread will cont | |
| | | inue | |
| | | to read, looking for another gzip stream. Any number of gzip streams ma | |
| | | y be | |
| | | concatenated in the input file, and will all be decompressed by gzread() | |
| | | . | |
| | | If something other than a gzip stream is encountered after a gzip stream | |
| | | , | |
| | | that remaining trailing garbage is ignored (and no error is returned). | |
| | | | |
| | | gzread can be used to read a gzip file that is being concurrently writ | |
| | | ten. | |
| | | Upon reaching the end of the input, gzread will return with the availabl | |
| | | e | |
| | | data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, the | |
| | | n | |
| | | gzclearerr can be used to clear the end of file indicator in order to pe | |
| | | rmit | |
| | | gzread to be tried again. Z_OK indicates that a gzip stream was complet | |
| | | ed | |
| | | on the last gzread. Z_BUF_ERROR indicates that the input file ended in | |
| | | the | |
| | | middle of a gzip stream. Note that gzread does not return -1 in the eve | |
| | | nt | |
| | | of an incomplete gzip stream. This error is deferred until gzclose(), w | |
| | | hich | |
| | | will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip | |
| | | stream. Alternatively, gzerror can be used before gzclose to detect thi | |
| | | s | |
| | | case. | |
| | | | |
| | | gzread returns the number of uncompressed bytes actually read, less th | |
| | | an | |
| | | len for end of file, or -1 for error. | |
| | | */ | |
| | | | |
|
| ZEXTERN int ZEXPORT gzwrite OF((gzFile file, | | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, | |
| voidpc buf, unsigned len)); | | voidpc buf, unsigned len)); | |
| /* | | /* | |
| Writes the given number of uncompressed bytes into the compressed file
. | | Writes the given number of uncompressed bytes into the compressed file
. | |
|
| gzwrite returns the number of uncompressed bytes actually written | | gzwrite returns the number of uncompressed bytes written or 0 in case of | |
| (0 in case of error). | | error. | |
| */ | | */ | |
| | | | |
|
| ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...))
; | | ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)
); | |
| /* | | /* | |
|
| Converts, formats, and writes the args to the compressed file under | | Converts, formats, and writes the arguments to the compressed file und | |
| control of the format string, as in fprintf. gzprintf returns the number | | er | |
| of | | control of the format string, as in fprintf. gzprintf returns the numbe | |
| uncompressed bytes actually written (0 in case of error). The number of | | r of | |
| uncompressed bytes written is limited to 4095. The caller should assure | | uncompressed bytes actually written, or 0 in case of error. The number | |
| that | | of | |
| this limit is not exceeded. If it is exceeded, then gzprintf() will retu | | uncompressed bytes written is limited to 8191, or one less than the buff | |
| rn | | er | |
| return an error (0) with nothing written. In this case, there may also b | | size given to gzbuffer(). The caller should assure that this limit is n | |
| e a | | ot | |
| buffer overflow with unpredictable consequences, which is possible only | | exceeded. If it is exceeded, then gzprintf() will return an error (0) w | |
| if | | ith | |
| zlib was compiled with the insecure functions sprintf() or vsprintf() | | nothing written. In this case, there may also be a buffer overflow with | |
| because the secure snprintf() or vsnprintf() functions were not availabl | | unpredictable consequences, which is possible only if zlib was compiled | |
| e. | | with | |
| | | the insecure functions sprintf() or vsprintf() because the secure snprin | |
| | | tf() | |
| | | or vsnprintf() functions were not available. This can be determined usi | |
| | | ng | |
| | | zlibCompileFlags(). | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); | | ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); | |
| /* | | /* | |
|
| Writes the given null-terminated string to the compressed file, exclu
ding | | Writes the given null-terminated string to the compressed file, exclud
ing | |
| the terminating null character. | | the terminating null character. | |
|
| gzputs returns the number of characters written, or -1 in case of err | | | |
| or. | | gzputs returns the number of characters written, or -1 in case of erro | |
| | | r. | |
| */ | | */ | |
| | | | |
| ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); | | ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); | |
| /* | | /* | |
|
| Reads bytes from the compressed file until len-1 characters are read, | | Reads bytes from the compressed file until len-1 characters are read, | |
| or | | or a | |
| a newline character is read and transferred to buf, or an end-of-file | | newline character is read and transferred to buf, or an end-of-file | |
| condition is encountered. The string is then terminated with a null | | condition is encountered. If any characters are read or if len == 1, th | |
| character. | | e | |
| gzgets returns buf, or Z_NULL in case of error. | | string is terminated with a null character. If no characters are read d | |
| | | ue | |
| | | to an end-of-file or len < 1, then the buffer is left untouched. | |
| | | | |
| | | gzgets returns buf which is a null-terminated string, or it returns NU | |
| | | LL | |
| | | for end-of-file or in case of error. If there was an error, the content | |
| | | s at | |
| | | buf are indeterminate. | |
| */ | | */ | |
| | | | |
|
| ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); | | ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); | |
| /* | | /* | |
|
| Writes c, converted to an unsigned char, into the compressed file. | | Writes c, converted to an unsigned char, into the compressed file. gz | |
| gzputc returns the value that was written, or -1 in case of error. | | putc | |
| | | returns the value that was written, or -1 in case of error. | |
| */ | | */ | |
| | | | |
|
| ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); | | ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); | |
| /* | | /* | |
|
| Reads one byte from the compressed file. gzgetc returns this byte | | Reads one byte from the compressed file. gzgetc returns this byte or | |
| or -1 in case of end of file or error. | | -1 | |
| | | in case of end of file or error. This is implemented as a macro for spe | |
| | | ed. | |
| | | As such, it does not do all of the checking the other functions do. I.e | |
| | | . | |
| | | it does not check to see if file is NULL, nor whether the structure file | |
| | | points to has been clobbered or not. | |
| */ | | */ | |
| | | | |
|
| ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); | | ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); | |
| /* | | /* | |
|
| Push one character back onto the stream to be read again later. | | Push one character back onto the stream to be read as the first charac | |
| Only one character of push-back is allowed. gzungetc() returns the | | ter | |
| character pushed, or -1 on failure. gzungetc() will fail if a | | on the next read. At least one character of push-back is allowed. | |
| character has been pushed but not read yet, or if c is -1. The pushed | | gzungetc() returns the character pushed, or -1 on failure. gzungetc() w | |
| character will be discarded if the stream is repositioned with gzseek() | | ill | |
| or gzrewind(). | | fail if c is -1, and may fail if a character has been pushed but not rea | |
| | | d | |
| | | yet. If gzungetc is used immediately after gzopen or gzdopen, at least | |
| | | the | |
| | | output buffer size of pushed characters is allowed. (See gzbuffer above | |
| | | .) | |
| | | The pushed character will be discarded if the stream is repositioned wit | |
| | | h | |
| | | gzseek() or gzrewind(). | |
| */ | | */ | |
| | | | |
|
| ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); | | ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); | |
| /* | | /* | |
|
| Flushes all pending output into the compressed file. The parameter | | Flushes all pending output into the compressed file. The parameter fl | |
| flush is as in the deflate() function. The return value is the zlib | | ush | |
| error number (see function gzerror below). gzflush returns Z_OK if | | is as in the deflate() function. The return value is the zlib error num | |
| the flush parameter is Z_FINISH and all output could be flushed. | | ber | |
| gzflush should be called only when strictly necessary because it can | | (see function gzerror below). gzflush is only permitted when writing. | |
| degrade compression. | | | |
| | | If the flush parameter is Z_FINISH, the remaining data is written and | |
| | | the | |
| | | gzip stream is completed in the output. If gzwrite() is called again, a | |
| | | new | |
| | | gzip stream will be started in the output. gzread() is able to read suc | |
| | | h | |
| | | concatented gzip streams. | |
| | | | |
| | | gzflush should be called only when strictly necessary because it will | |
| | | degrade compression if called too often. | |
| */ | | */ | |
| | | | |
|
| ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, | | | |
| z_off_t offset, int whence)); | | | |
| /* | | /* | |
|
| Sets the starting position for the next gzread or gzwrite on the | | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, | |
| given compressed file. The offset represents a number of bytes in the | | z_off_t offset, int whence)); | |
| uncompressed data stream. The whence parameter is defined as in lseek(2) | | | |
| ; | | Sets the starting position for the next gzread or gzwrite on the given | |
| | | compressed file. The offset represents a number of bytes in the | |
| | | uncompressed data stream. The whence parameter is defined as in lseek(2 | |
| | | ); | |
| the value SEEK_END is not supported. | | the value SEEK_END is not supported. | |
|
| | | | |
| If the file is opened for reading, this function is emulated but can b
e | | If the file is opened for reading, this function is emulated but can b
e | |
|
| extremely slow. If the file is opened for writing, only forward seeks ar
e | | extremely slow. If the file is opened for writing, only forward seeks a
re | |
| supported; gzseek then compresses a sequence of zeroes up to the new | | supported; gzseek then compresses a sequence of zeroes up to the new | |
| starting position. | | starting position. | |
| | | | |
|
| gzseek returns the resulting offset location as measured in bytes fro
m | | gzseek returns the resulting offset location as measured in bytes from | |
| the beginning of the uncompressed stream, or -1 in case of error, in | | the beginning of the uncompressed stream, or -1 in case of error, in | |
| particular if the file is opened for writing and the new starting positi
on | | particular if the file is opened for writing and the new starting positi
on | |
| would be before the current position. | | would be before the current position. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); | | ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); | |
| /* | | /* | |
| Rewinds the given file. This function is supported only for reading. | | Rewinds the given file. This function is supported only for reading. | |
| | | | |
|
| gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) | | gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) | |
| */ | | */ | |
| | | | |
|
| | | /* | |
| ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); | | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); | |
|
| | | | |
| | | Returns the starting position for the next gzread or gzwrite on the gi | |
| | | ven | |
| | | compressed file. This position represents a number of bytes in the | |
| | | uncompressed data stream, and is zero when starting, even if appending o | |
| | | r | |
| | | reading a gzip stream from the middle of a file using gzdopen(). | |
| | | | |
| | | gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) | |
| | | */ | |
| | | | |
| /* | | /* | |
|
| Returns the starting position for the next gzread or gzwrite on the | | ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); | |
| given compressed file. This position represents a number of bytes in the | | | |
| uncompressed data stream. | | | |
| | | | |
|
| gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) | | Returns the current offset in the file being read or written. This of | |
| | | fset | |
| | | includes the count of bytes that precede the gzip stream, for example wh | |
| | | en | |
| | | appending or when using gzdopen() for reading. When reading, the offset | |
| | | does not include as yet unused buffered input. This information can be | |
| | | used | |
| | | for a progress indicator. On error, gzoffset() returns -1. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT gzeof OF((gzFile file)); | | ZEXTERN int ZEXPORT gzeof OF((gzFile file)); | |
| /* | | /* | |
|
| Returns 1 when EOF has previously been detected reading the given | | Returns true (1) if the end-of-file indicator has been set while readi | |
| input stream, otherwise zero. | | ng, | |
| | | false (0) otherwise. Note that the end-of-file indicator is set only if | |
| | | the | |
| | | read tried to go past the end of the input, but came up short. Therefor | |
| | | e, | |
| | | just like feof(), gzeof() may return false even if there is no more data | |
| | | to | |
| | | read, in the event that the last read request was for the exact number o | |
| | | f | |
| | | bytes remaining in the input file. This will happen if the input file s | |
| | | ize | |
| | | is an exact multiple of the buffer size. | |
| | | | |
| | | If gzeof() returns true, then the read functions will return no more d | |
| | | ata, | |
| | | unless the end-of-file indicator is reset by gzclearerr() and the input | |
| | | file | |
| | | has grown since the previous end of file was detected. | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); | | ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); | |
| /* | | /* | |
|
| Returns 1 if file is being read directly without decompression, otherw | | Returns true (1) if file is being copied directly while reading, or fa | |
| ise | | lse | |
| zero. | | (0) if file is a gzip stream being decompressed. | |
| | | | |
| | | If the input file is empty, gzdirect() will return true, since the inp | |
| | | ut | |
| | | does not contain a gzip stream. | |
| | | | |
| | | If gzdirect() is used immediately after gzopen() or gzdopen() it will | |
| | | cause buffers to be allocated to allow reading the file to determine if | |
| | | it | |
| | | is a gzip file. Therefore if gzbuffer() is used, it should be called be | |
| | | fore | |
| | | gzdirect(). | |
| | | | |
| | | When writing, gzdirect() returns true (1) if transparent writing was | |
| | | requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: | |
| | | gzdirect() is not needed when writing. Transparent writing must be | |
| | | explicitly requested, so the application already knows the answer. When | |
| | | linking statically, using gzdirect() will include all of the zlib code f | |
| | | or | |
| | | gzip file reading and decompression, which may not be desired.) | |
| */ | | */ | |
| | | | |
| ZEXTERN int ZEXPORT gzclose OF((gzFile file)); | | ZEXTERN int ZEXPORT gzclose OF((gzFile file)); | |
| /* | | /* | |
|
| Flushes all pending output if necessary, closes the compressed file | | Flushes all pending output if necessary, closes the compressed file an | |
| and deallocates all the (de)compression state. The return value is the z | | d | |
| lib | | deallocates the (de)compression state. Note that once file is closed, y | |
| error number (see function gzerror below). | | ou | |
| | | cannot call gzerror with file, since its structures have been deallocate | |
| | | d. | |
| | | gzclose must not be called more than once on the same file, just as free | |
| | | must not be called more than once on the same allocation. | |
| | | | |
| | | gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a | |
| | | file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the | |
| | | last read ended in the middle of a gzip stream, or Z_OK on success. | |
| | | */ | |
| | | | |
| | | ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); | |
| | | ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); | |
| | | /* | |
| | | Same as gzclose(), but gzclose_r() is only for use when reading, and | |
| | | gzclose_w() is only for use when writing or appending. The advantage to | |
| | | using these instead of gzclose() is that they avoid linking in zlib | |
| | | compression or decompression code that is not used when only reading or | |
| | | only | |
| | | writing respectively. If gzclose() is used, then both compression and | |
| | | decompression code will be included the application when linking to a st | |
| | | atic | |
| | | zlib library. | |
| */ | | */ | |
| | | | |
| ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); | | ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); | |
| /* | | /* | |
|
| Returns the error message for the last error which occurred on the | | Returns the error message for the last error which occurred on the giv | |
| given compressed file. errnum is set to zlib error number. If an | | en | |
| error occurred in the file system and not in the compression library, | | compressed file. errnum is set to zlib error number. If an error occur | |
| errnum is set to Z_ERRNO and the application may consult errno | | red | |
| to get the exact error code. | | in the file system and not in the compression library, errnum is set to | |
| | | Z_ERRNO and the application may consult errno to get the exact error cod | |
| | | e. | |
| | | | |
| | | The application must not modify the returned string. Future calls to | |
| | | this function may invalidate the previously returned string. If file is | |
| | | closed, then the string previously returned by gzerror will no longer be | |
| | | available. | |
| | | | |
| | | gzerror() should be used to distinguish errors from end-of-file for th | |
| | | ose | |
| | | functions above that do not distinguish those cases in their return valu | |
| | | es. | |
| */ | | */ | |
| | | | |
| ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); | | ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); | |
| /* | | /* | |
|
| Clears the error and end-of-file flags for file. This is analogous to | | Clears the error and end-of-file flags for file. This is analogous to | |
| the | | the | |
| clearerr() function in stdio. This is useful for continuing to read a gz | | clearerr() function in stdio. This is useful for continuing to read a g | |
| ip | | zip | |
| file that is being written concurrently. | | file that is being written concurrently. | |
| */ | | */ | |
| | | | |
|
| | | #endif /* !Z_SOLO */ | |
| | | | |
| /* checksum functions */ | | /* checksum functions */ | |
| | | | |
| /* | | /* | |
| These functions are not related to compression but are exported | | These functions are not related to compression but are exported | |
|
| anyway because they might be useful in applications using the | | anyway because they might be useful in applications using the compressio | |
| compression library. | | n | |
| | | library. | |
| */ | | */ | |
| | | | |
| ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len))
; | | ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len))
; | |
| /* | | /* | |
| Update a running Adler-32 checksum with the bytes buf[0..len-1] and | | Update a running Adler-32 checksum with the bytes buf[0..len-1] and | |
|
| return the updated checksum. If buf is NULL, this function returns | | return the updated checksum. If buf is Z_NULL, this function returns th | |
| the required initial value for the checksum. | | e | |
| An Adler-32 checksum is almost as reliable as a CRC32 but can be compute | | required initial value for the checksum. | |
| d | | | |
| much faster. Usage example: | | An Adler-32 checksum is almost as reliable as a CRC32 but can be compu | |
| | | ted | |
| | | much faster. | |
| | | | |
| | | Usage example: | |
| | | | |
| uLong adler = adler32(0L, Z_NULL, 0); | | uLong adler = adler32(0L, Z_NULL, 0); | |
| | | | |
| while (read_buffer(buffer, length) != EOF) { | | while (read_buffer(buffer, length) != EOF) { | |
| adler = adler32(adler, buffer, length); | | adler = adler32(adler, buffer, length); | |
| } | | } | |
| if (adler != original_adler) error(); | | if (adler != original_adler) error(); | |
| */ | | */ | |
| | | | |
|
| | | /* | |
| ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, | | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, | |
| z_off_t len2)); | | z_off_t len2)); | |
|
| /* | | | |
| Combine two Adler-32 checksums into one. For two sequences of bytes,
seq1 | | Combine two Adler-32 checksums into one. For two sequences of bytes,
seq1 | |
| and seq2 with lengths len1 and len2, Adler-32 checksums were calculated
for | | and seq2 with lengths len1 and len2, Adler-32 checksums were calculated
for | |
| each, adler1 and adler2. adler32_combine() returns the Adler-32 checksu
m of | | each, adler1 and adler2. adler32_combine() returns the Adler-32 checksu
m of | |
|
| seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. | | seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. No | |
| | | te | |
| | | that the z_off_t type (like off_t) is a signed integer. If len2 is | |
| | | negative, the result has no meaning or utility. | |
| */ | | */ | |
| | | | |
| ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); | | ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); | |
| /* | | /* | |
| Update a running CRC-32 with the bytes buf[0..len-1] and return the | | Update a running CRC-32 with the bytes buf[0..len-1] and return the | |
|
| updated CRC-32. If buf is NULL, this function returns the required initi | | updated CRC-32. If buf is Z_NULL, this function returns the required | |
| al | | initial value for the crc. Pre- and post-conditioning (one's complement | |
| value for the for the crc. Pre- and post-conditioning (one's complement) | | ) is | |
| is | | | |
| performed within this function so it shouldn't be done by the applicatio
n. | | performed within this function so it shouldn't be done by the applicatio
n. | |
|
| | | | |
| Usage example: | | Usage example: | |
| | | | |
| uLong crc = crc32(0L, Z_NULL, 0); | | uLong crc = crc32(0L, Z_NULL, 0); | |
| | | | |
| while (read_buffer(buffer, length) != EOF) { | | while (read_buffer(buffer, length) != EOF) { | |
| crc = crc32(crc, buffer, length); | | crc = crc32(crc, buffer, length); | |
| } | | } | |
| if (crc != original_crc) error(); | | if (crc != original_crc) error(); | |
| */ | | */ | |
| | | | |
|
| | | /* | |
| ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len
2)); | | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len
2)); | |
| | | | |
|
| /* | | | |
| Combine two CRC-32 check values into one. For two sequences of bytes, | | Combine two CRC-32 check values into one. For two sequences of bytes, | |
| seq1 and seq2 with lengths len1 and len2, CRC-32 check values were | | seq1 and seq2 with lengths len1 and len2, CRC-32 check values were | |
| calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 | | calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 | |
| check value of seq1 and seq2 concatenated, requiring only crc1, crc2, an
d | | check value of seq1 and seq2 concatenated, requiring only crc1, crc2, an
d | |
| len2. | | len2. | |
| */ | | */ | |
| | | | |
| /* various hacks, don't look :) */ | | /* various hacks, don't look :) */ | |
| | | | |
| /* deflateInit and inflateInit are macros to allow checking the zlib versio
n | | /* deflateInit and inflateInit are macros to allow checking the zlib versio
n | |
| | | | |
| skipping to change at line 1323 | | skipping to change at line 1639 | |
| int windowBits, int memLevel, | | int windowBits, int memLevel, | |
| int strategy, const char *version, | | int strategy, const char *version, | |
| int stream_size)); | | int stream_size)); | |
| ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, | | ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, | |
| const char *version, int stream_size)
); | | const char *version, int stream_size)
); | |
| ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, | | ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, | |
| unsigned char FAR *window, | | unsigned char FAR *window, | |
| const char *version, | | const char *version, | |
| int stream_size)); | | int stream_size)); | |
| #define deflateInit(strm, level) \ | | #define deflateInit(strm, level) \ | |
|
| deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) | | deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) | |
| #define inflateInit(strm) \ | | #define inflateInit(strm) \ | |
|
| inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) | | inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) | |
| #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ | | #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ | |
| deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ | | deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ | |
|
| (strategy), ZLIB_VERSION, sizeof(z_stream)) | | (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) | |
| #define inflateInit2(strm, windowBits) \ | | #define inflateInit2(strm, windowBits) \ | |
|
| inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) | | inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ | |
| | | (int)sizeof(z_stream)) | |
| #define inflateBackInit(strm, windowBits, window) \ | | #define inflateBackInit(strm, windowBits, window) \ | |
| inflateBackInit_((strm), (windowBits), (window), \ | | inflateBackInit_((strm), (windowBits), (window), \ | |
|
| ZLIB_VERSION, sizeof(z_stream)) | | ZLIB_VERSION, (int)sizeof(z_stream)) | |
| | | | |
|
| | | #ifndef Z_SOLO | |
| | | | |
| | | /* gzgetc() macro and its supporting function and exposed data structure. | |
| | | Note | |
| | | * that the real internal state is much larger than the exposed structure. | |
| | | * This abbreviated structure exposes just enough for the gzgetc() macro. | |
| | | The | |
| | | * user should not mess with these exposed elements, since their names or | |
| | | * behavior could change in the future, perhaps even capriciously. They ca | |
| | | n | |
| | | * only be used by the gzgetc() macro. You have been warned. | |
| | | */ | |
| | | struct gzFile_s { | |
| | | unsigned have; | |
| | | unsigned char *next; | |
| | | z_off64_t pos; | |
| | | }; | |
| | | ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility * | |
| | | / | |
| | | #ifdef Z_PREFIX_SET | |
| | | # undef z_gzgetc | |
| | | # define z_gzgetc(g) \ | |
| | | ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g | |
| | | )) | |
| | | #else | |
| | | # define gzgetc(g) \ | |
| | | ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g | |
| | | )) | |
| | | #endif | |
| | | | |
| | | /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or | |
| | | * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if | |
| | | * both are true, the application gets the *64 functions, and the regular | |
| | | * functions are changed to 64 bits) -- in case these are set on systems | |
| | | * without large file support, _LFS64_LARGEFILE must also be true | |
| | | */ | |
| | | #ifdef Z_LARGE64 | |
| | | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | |
| | | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); | |
| | | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); | |
| | | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); | |
| | | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); | |
| | | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); | |
| | | #endif | |
| | | | |
| | | #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) | |
| | | # ifdef Z_PREFIX_SET | |
| | | # define z_gzopen z_gzopen64 | |
| | | # define z_gzseek z_gzseek64 | |
| | | # define z_gztell z_gztell64 | |
| | | # define z_gzoffset z_gzoffset64 | |
| | | # define z_adler32_combine z_adler32_combine64 | |
| | | # define z_crc32_combine z_crc32_combine64 | |
| | | # else | |
| | | # define gzopen gzopen64 | |
| | | # define gzseek gzseek64 | |
| | | # define gztell gztell64 | |
| | | # define gzoffset gzoffset64 | |
| | | # define adler32_combine adler32_combine64 | |
| | | # define crc32_combine crc32_combine64 | |
| | | # endif | |
| | | # ifndef Z_LARGE64 | |
| | | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | |
| | | ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); | |
| | | ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); | |
| | | ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); | |
| | | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); | |
| | | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); | |
| | | # endif | |
| | | #else | |
| | | ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); | |
| | | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); | |
| | | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); | |
| | | ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); | |
| | | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); | |
| | | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); | |
| | | #endif | |
| | | | |
| | | #else /* Z_SOLO */ | |
| | | | |
| | | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); | |
| | | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); | |
| | | | |
| | | #endif /* !Z_SOLO */ | |
| | | | |
| | | /* hack for buggy compilers */ | |
| #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) | | #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) | |
|
| struct internal_state {int dummy;}; /* hack for buggy compilers */ | | struct internal_state {int dummy;}; | |
| #endif | | #endif | |
| | | | |
|
| | | /* undocumented functions */ | |
| ZEXTERN const char * ZEXPORT zError OF((int)); | | ZEXTERN const char * ZEXPORT zError OF((int)); | |
|
| ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); | | ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); | |
| ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); | | ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); | |
| | | ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); | |
| | | ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); | |
| | | ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); | |
| | | #if defined(_WIN32) && !defined(Z_SOLO) | |
| | | ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, | |
| | | const char *mode)); | |
| | | #endif | |
| | | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | |
| | | # ifndef Z_SOLO | |
| | | ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, | |
| | | const char *format, | |
| | | va_list va)); | |
| | | # endif | |
| | | #endif | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* ZLIB_H */ | | #endif /* ZLIB_H */ | |
| | | | |
End of changes. 193 change blocks. |
| 587 lines changed or deleted | | 1246 lines changed or added | |
|