libextractor  1.11
About: GNU libextractor is a library used to extract meta-data from files of arbitrary type.
  Fossies Dox: libextractor-1.11.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

deb_extractor.c File Reference

plugin to support Debian archives More...

#include "platform.h"
#include "extractor.h"
#include <zlib.h>
Include dependency graph for deb_extractor.c:

Go to the source code of this file.

Data Structures

struct  Matches
 
struct  TarHeader
 
struct  USTarHeader
 
struct  ObjectHeader
 

Macros

#define MAX_CONTROL_SIZE   (1024 * 1024)
 

Functions

static char * stndup (const char *str, size_t n)
 
static int processControl (const char *data, const size_t size, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
 
static int processControlTar (const char *data, size_t size, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
 
static int processControlTGZ (struct EXTRACTOR_ExtractContext *ec, unsigned long long size)
 
void EXTRACTOR_deb_extract_method (struct EXTRACTOR_ExtractContext *ec)
 

Variables

static struct Matches tmap []
 

Detailed Description

plugin to support Debian archives

Author
Christian Grothoff

The .deb is an ar-chive file. It contains a tar.gz file named "control.tar.gz" which then contains a file 'control' that has the meta-data. And which variant of the various ar file formats is used is also not quite certain. Yuck.

References: http://www.mkssoftware.com/docs/man4/tar.4.asp http://lists.debian.org/debian-policy/2003/12/msg00000.html http://www.opengroup.org/onlinepubs/009695399/utilities/ar.html

Definition in file deb_extractor.c.

Macro Definition Documentation

◆ MAX_CONTROL_SIZE

#define MAX_CONTROL_SIZE   (1024 * 1024)

Maximum file size we allow for control.tar.gz files. This is a sanity check to avoid allocating huge amounts of memory.

Definition at line 45 of file deb_extractor.c.

Function Documentation

◆ EXTRACTOR_deb_extract_method()

void EXTRACTOR_deb_extract_method ( struct EXTRACTOR_ExtractContext ec)

◆ processControl()

static int processControl ( const char *  data,
const size_t  size,
EXTRACTOR_MetaDataProcessor  proc,
void *  proc_cls 
)
static

Process the "control" file from the control.tar.gz

Parameters
datadecompressed control data
sizenumber of bytes in data
procfunction to call with meta data
proc_clsclosure for 'proc'
Returns
0 to continue extracting, 1 if we are done

Definition at line 123 of file deb_extractor.c.

References EXTRACTOR_METAFORMAT_UTF8, NULL, stndup(), Matches::text, tmap, and type.

Referenced by processControlTar().

◆ processControlTar()

static int processControlTar ( const char *  data,
size_t  size,
EXTRACTOR_MetaDataProcessor  proc,
void *  proc_cls 
)
static

Process the control.tar file.

Parameters
datathe deflated control.tar file data
sizenumber of bytes in data
procfunction to call with meta data
proc_clsclosure for 'proc'
Returns
0 to continue extracting, 1 if we are done

Definition at line 293 of file deb_extractor.c.

References TarHeader::filesize, USTarHeader::magic, TarHeader::name, processControl(), and USTarHeader::tar.

Referenced by processControlTGZ().

◆ processControlTGZ()

static int processControlTGZ ( struct EXTRACTOR_ExtractContext ec,
unsigned long long  size 
)
static

Process the control.tar.gz file.

Parameters
ecextractor context with control.tar.gz at current read position
sizenumber of bytes in the control file
Returns
0 to continue extracting, 1 if we are done

Definition at line 352 of file deb_extractor.c.

References EXTRACTOR_ExtractContext::cls, MAX_CONTROL_SIZE, NULL, EXTRACTOR_ExtractContext::proc, processControlTar(), and EXTRACTOR_ExtractContext::read.

Referenced by EXTRACTOR_deb_extract_method().

◆ stndup()

static char* stndup ( const char *  str,
size_t  n 
)
static

Re-implementation of 'strndup'.

Parameters
strstring to duplicate
nmaximum number of bytes to copy
Returns
NULL on error, otherwise 0-terminated copy of 'str' with at most n characters

Definition at line 57 of file deb_extractor.c.

References NULL.

Referenced by processControl().

Variable Documentation

◆ tmap

struct Matches tmap[]
static
Initial value:
= {
{"Description: ", EXTRACTOR_METATYPE_DESCRIPTION},
{NULL, 0}
}
#define NULL
Definition: getopt1.c:60
@ EXTRACTOR_METATYPE_SECTION
Definition: extractor.h:212
@ EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE
Definition: extractor.h:221
@ EXTRACTOR_METATYPE_TARGET_ARCHITECTURE
Definition: extractor.h:224
@ EXTRACTOR_METATYPE_PACKAGE_PROVIDES
Definition: extractor.h:217
@ EXTRACTOR_METATYPE_PACKAGE_PRE_DEPENDENCY
Definition: extractor.h:225
@ EXTRACTOR_METATYPE_PACKAGE_ESSENTIAL
Definition: extractor.h:223
@ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY
Definition: extractor.h:214
@ EXTRACTOR_METATYPE_PACKAGE_RECOMMENDS
Definition: extractor.h:218
@ EXTRACTOR_METATYPE_PACKAGE_VERSION
Definition: extractor.h:211
@ EXTRACTOR_METATYPE_UPLOAD_PRIORITY
Definition: extractor.h:213
@ EXTRACTOR_METATYPE_PACKAGE_CONFLICTS
Definition: extractor.h:215
@ EXTRACTOR_METATYPE_PACKAGE_REPLACES
Definition: extractor.h:216
@ EXTRACTOR_METATYPE_PACKAGE_SUGGESTS
Definition: extractor.h:219
@ EXTRACTOR_METATYPE_PACKAGE_NAME
Definition: extractor.h:210
@ EXTRACTOR_METATYPE_PACKAGE_SOURCE
Definition: extractor.h:222
@ EXTRACTOR_METATYPE_PACKAGE_MAINTAINER
Definition: extractor.h:220
@ EXTRACTOR_METATYPE_DESCRIPTION
Definition: extractor.h:182

Map from deb-control entries to LE types.

see also: "man 5 deb-control"

Definition at line 57 of file deb_extractor.c.

Referenced by processControl().