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)  

man_extractor.c File Reference

plugin to support man pages More...

#include "platform.h"
#include "extractor.h"
#include <ctype.h>
Include dependency graph for man_extractor.c:

Go to the source code of this file.

Macros

#define MAX_READ   (16 * 1024)
 
#define ADD(t, s)
 

Functions

static char * stndup (const char *str, size_t n)
 
static int add_keyword (enum EXTRACTOR_MetaType type, char *keyword, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
 
static void find_end_of_token (size_t *end, const char *buf, const size_t size)
 
void EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec)
 

Detailed Description

plugin to support man pages

Author
Christian Grothoff

Definition in file man_extractor.c.

Macro Definition Documentation

◆ ADD

#define ADD (   t,
 
)
Value:
do { if (0 != add_keyword (t, s, ec->proc, ec->cls)) return; \
} while (0)
static int add_keyword(enum EXTRACTOR_MetaType type, char *keyword, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
Definition: man_extractor.c:61

Add a keyword to LE.

Parameters
ttype to use
skeyword to give to LE

Definition at line 137 of file man_extractor.c.

◆ MAX_READ

#define MAX_READ   (16 * 1024)

How many bytes do we actually try to scan? (from the beginning of the file).

Definition at line 128 of file man_extractor.c.

Function Documentation

◆ add_keyword()

static int add_keyword ( enum EXTRACTOR_MetaType  type,
char *  keyword,
EXTRACTOR_MetaDataProcessor  proc,
void *  proc_cls 
)
static

Give a metadata item to LE. Removes double-quotes and makes sure we don't pass empty strings or NULL pointers.

Parameters
typemetadata type to use
keywordmetadata value; freed in the process
procfunction to call with meta data
proc_clsclosure for 'proc'
Returns
0 to continue extracting, 1 if we are done

Definition at line 61 of file man_extractor.c.

References EXTRACTOR_METAFORMAT_UTF8, NULL, and type.

◆ EXTRACTOR_man_extract_method()

void EXTRACTOR_man_extract_method ( struct EXTRACTOR_ExtractContext ec)

Main entry method for the man page extraction plugin.

Parameters
ecextraction context provided to the plugin

Definition at line 147 of file man_extractor.c.

References _, ADD, EXTRACTOR_ExtractContext::cls, EXTRACTOR_METATYPE_BOOK_TITLE, EXTRACTOR_METATYPE_MODIFICATION_DATE, EXTRACTOR_METATYPE_SECTION, EXTRACTOR_METATYPE_SOURCE, EXTRACTOR_METATYPE_TITLE, find_end_of_token(), MAX_READ, EXTRACTOR_ExtractContext::read, and stndup().

◆ find_end_of_token()

static void find_end_of_token ( size_t *  end,
const char *  buf,
const size_t  size 
)
static

Find the end of the current token (which may be quoted).

Parameters
endbeginning of the current token, updated to its end; set to size + 1 if the token does not end properly
bufinput buffer with the characters
sizenumber of bytes in buf

Definition at line 104 of file man_extractor.c.

Referenced by EXTRACTOR_man_extract_method().

◆ stndup()

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

Create string from first 'n' characters of 'str'. See 'strndup'.

Parameters
strinput string
ndesired output length (plus 0-termination)
Returns
copy of first 'n' bytes from 'str' plus 0-terminator, NULL on error

Definition at line 38 of file man_extractor.c.

References NULL.

Referenced by EXTRACTOR_man_extract_method().