BibTeXq
query a bibtex file
Defines | Functions | Variables
bibtexq.c File Reference

Queries a BIBTEX file by field name. More...

#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <regex.h>
#include <jwsc/base/option.h>
#include <jwsc/base/error.h>
#include "bibtex_entry.h"

Go to the source code of this file.

Defines

#define NUM_OPTS_NO_ARG   2
#define NUM_OPTS_WITH_ARG   8

Functions

int yyparse ()
static Errorinit_regex (const char *value, regex_t *preg)
static void print_usage (void)
 Prints the program usage to stderr.
static Errorprocess_help_opt (void)
 Process the 'help' program option.
static Errorprocess_version_opt (void)
 Process the 'version' program option.
static Errorprocess_output_opt (Option_arg arg)
 Process the 'output' program option.
static Errorprocess_type_opt (Option_arg arg)
 Process the 'type' program option.
static Errorprocess_key_opt (Option_arg arg)
 Process the 'key' program option.
static Errorprocess_author_opt (Option_arg arg)
 Process the 'author' program option.
static Errorprocess_title_opt (Option_arg arg)
 Process the 'title' program option.
static Errorprocess_project_opt (Option_arg arg)
 Process the 'project' program option.
static Errorprocess_venue_opt (Option_arg arg)
 Process the 'venue' program option.
static Errorprocess_keyword_opt (Option_arg arg)
 Process the 'keyword' program option.
static void init_options (void)
 Initializes the program options.
void query_bibtex_entry (Bibtex_entry *entry)
 Query a BIBTEX entry against a bibtex file and writes the entry if it matches.
int main (int argc, const char **argv)
 Main function for the haplo_predict program.

Variables

FILE * yyin
Bibtex_entryentry = NULL
 BIBTEX entry used by the grammar/parser.
static Option_no_arg opts_no_arg [NUM_OPTS_NO_ARG]
 Program options not taking an argument.
static Option_with_arg opts_with_arg [NUM_OPTS_WITH_ARG]
 Program options taking an argument.
static const char * output_fname
 File name to write matching BIBTEX entries to.
static FILE * output_fp
 File to write matching BIBTEX entries to.
static uint8_t query_type
 Boolean indicating whether to query the BIBTEX entry type.
static uint8_t query_key
 Boolean indicating whether to query the BIBTEX entry type.
static uint8_t query_author
 Boolean indicating whether to query the BIBTEX author field.
static uint8_t query_title
 Boolean indicating whether to query the BIBTEX title field.
static uint8_t query_project
 Boolean indicating whether to query the BIBTEX project field.
static uint8_t query_venue
 Boolean indicating whether to query the BIBTEX venue field.
static uint8_t query_keyword
 Boolean indicating whether to query the BIBTEX keyword field.
static regex_t type_preg
 BIBTEX entry type regular expresion.
static regex_t key_preg
 BIBTEX entry uniue key regular expresion.
static regex_t author_preg
 BIBTEX author field regular expresion.
static regex_t title_preg
 BIBTEX title field regular expresion.
static regex_t project_preg
 BIBTEX project field regular expresion.
static regex_t venue_preg
 BIBTEX venue field regular expresion.
static regex_t keyword_preg
 BIBTEX keyword field regular expresion.

Detailed Description

Queries a BIBTEX file by field name.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Definition in file bibtexq.c.


Define Documentation

#define NUM_OPTS_NO_ARG   2

Definition at line 92 of file bibtexq.c.

#define NUM_OPTS_WITH_ARG   8

Definition at line 93 of file bibtexq.c.


Function Documentation

int yyparse ( )
static Error* init_regex ( const char *  value,
regex_t *  preg 
) [static]

Definition at line 159 of file bibtexq.c.

static void print_usage ( void  ) [static]

Prints the program usage to stderr.

Definition at line 173 of file bibtexq.c.

static Error* process_help_opt ( void  ) [static]

Process the 'help' program option.

Definition at line 181 of file bibtexq.c.

static Error* process_version_opt ( void  ) [static]

Process the 'version' program option.

Definition at line 189 of file bibtexq.c.

static Error* process_output_opt ( Option_arg  arg) [static]

Process the 'output' program option.

Definition at line 197 of file bibtexq.c.

static Error* process_type_opt ( Option_arg  arg) [static]

Process the 'type' program option.

Definition at line 208 of file bibtexq.c.

static Error* process_key_opt ( Option_arg  arg) [static]

Process the 'key' program option.

Definition at line 225 of file bibtexq.c.

static Error* process_author_opt ( Option_arg  arg) [static]

Process the 'author' program option.

Definition at line 242 of file bibtexq.c.

static Error* process_title_opt ( Option_arg  arg) [static]

Process the 'title' program option.

Definition at line 259 of file bibtexq.c.

static Error* process_project_opt ( Option_arg  arg) [static]

Process the 'project' program option.

Definition at line 276 of file bibtexq.c.

static Error* process_venue_opt ( Option_arg  arg) [static]

Process the 'venue' program option.

Definition at line 293 of file bibtexq.c.

static Error* process_keyword_opt ( Option_arg  arg) [static]

Process the 'keyword' program option.

Definition at line 310 of file bibtexq.c.

static void init_options ( void  ) [static]

Initializes the program options.

Definition at line 327 of file bibtexq.c.

void query_bibtex_entry ( Bibtex_entry entry)

Query a BIBTEX entry against a bibtex file and writes the entry if it matches.

Call-back function used in the yacc/lex parser/grammar for BIBTEX files.

Parameters:
entryEntry to check for a query match.

Definition at line 367 of file bibtexq.c.

int main ( int  argc,
const char **  argv 
)

Main function for the haplo_predict program.

Definition at line 476 of file bibtexq.c.


Variable Documentation

FILE* yyin

BIBTEX entry used by the grammar/parser.

Definition at line 101 of file bibtexq.c.

Option_no_arg opts_no_arg[NUM_OPTS_NO_ARG] [static]

Program options not taking an argument.

Definition at line 105 of file bibtexq.c.

Option_with_arg opts_with_arg[NUM_OPTS_WITH_ARG] [static]

Program options taking an argument.

Definition at line 108 of file bibtexq.c.

const char* output_fname [static]

File name to write matching BIBTEX entries to.

Definition at line 111 of file bibtexq.c.

FILE* output_fp [static]

File to write matching BIBTEX entries to.

Definition at line 114 of file bibtexq.c.

uint8_t query_type [static]

Boolean indicating whether to query the BIBTEX entry type.

Definition at line 117 of file bibtexq.c.

uint8_t query_key [static]

Boolean indicating whether to query the BIBTEX entry type.

Definition at line 120 of file bibtexq.c.

uint8_t query_author [static]

Boolean indicating whether to query the BIBTEX author field.

Definition at line 123 of file bibtexq.c.

uint8_t query_title [static]

Boolean indicating whether to query the BIBTEX title field.

Definition at line 126 of file bibtexq.c.

uint8_t query_project [static]

Boolean indicating whether to query the BIBTEX project field.

Definition at line 129 of file bibtexq.c.

uint8_t query_venue [static]

Boolean indicating whether to query the BIBTEX venue field.

Definition at line 132 of file bibtexq.c.

uint8_t query_keyword [static]

Boolean indicating whether to query the BIBTEX keyword field.

Definition at line 135 of file bibtexq.c.

regex_t type_preg [static]

BIBTEX entry type regular expresion.

Definition at line 138 of file bibtexq.c.

regex_t key_preg [static]

BIBTEX entry uniue key regular expresion.

Definition at line 141 of file bibtexq.c.

regex_t author_preg [static]

BIBTEX author field regular expresion.

Definition at line 144 of file bibtexq.c.

regex_t title_preg [static]

BIBTEX title field regular expresion.

Definition at line 147 of file bibtexq.c.

regex_t project_preg [static]

BIBTEX project field regular expresion.

Definition at line 150 of file bibtexq.c.

regex_t venue_preg [static]

BIBTEX venue field regular expresion.

Definition at line 153 of file bibtexq.c.

regex_t keyword_preg [static]

BIBTEX keyword field regular expresion.

Definition at line 156 of file bibtexq.c.