BibTeXq
query a bibtex file
Functions
bibtex_entry.c File Reference

Definitions for a BIBTEX entry data type. More...

#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include "bibtex_entry.h"

Go to the source code of this file.

Functions

static void remove_extra_spaces (char *str)
 Removes extra spaces, newlines, and tabs from a string.
static void create_bibtex_field (Bibtex_field **field_out, const char *name, const char *value)
 Creates a Bibtex_field.
static void free_bibtex_fields (Bibtex_field **fields, uint32_t num_fields)
 Frees an array of Bibtex_field.
void create_bibtex_entry (Bibtex_entry **entry_out, const char *type, const char *key)
 Creates a Bibtex_entry.
void free_bibtex_entry (Bibtex_entry *entry)
 Frees a Bibtex_entry.
void add_field_to_bibtex_entry (Bibtex_entry *entry, const char *name, const char *value)
 Adds a field to a Bibtex_entry.
void write_bibtex_entry (Bibtex_entry *entry, FILE *fp)
 Writes a Bibtex_entry to a file stream.

Detailed Description

Definitions for a BIBTEX entry data type.

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

Definition in file bibtex_entry.c.


Function Documentation

static void remove_extra_spaces ( char *  str) [static]

Removes extra spaces, newlines, and tabs from a string.

Definition at line 63 of file bibtex_entry.c.

static void create_bibtex_field ( Bibtex_field **  field_out,
const char *  name,
const char *  value 
) [static]

Creates a Bibtex_field.

Removes duplicate spaces, newlines, and tabs from the copies of name and value that are put in the created field.

Parameters:
field_outResult parameter. If *field_out is NULL, a Bibtex_field is allocated; otherwise its space is re-used.
nameName of the field.
valueValue of the field.

Definition at line 134 of file bibtex_entry.c.

static void free_bibtex_fields ( Bibtex_field **  fields,
uint32_t  num_fields 
) [static]

Frees an array of Bibtex_field.

Frees each Bibtex_field in the array and the array of field pointers.

Parameters:
fieldsArray to free.
num_fieldsNumber of fields in the array.

Definition at line 169 of file bibtex_entry.c.

void create_bibtex_entry ( Bibtex_entry **  entry_out,
const char *  type,
const char *  key 
)

Creates a Bibtex_entry.

If *entry_out is not NULL, then the Bibtex_entry::num_used_fields is set to 0.

Parameters:
entry_outResult parameter. If *entry_out is NULL, a Bibtex_entry is allocated; otherwise its space is re-used.
typeType of entry.
keyUnique entry key.

Definition at line 199 of file bibtex_entry.c.

void free_bibtex_entry ( Bibtex_entry entry)

Frees a Bibtex_entry.

Parameters:
entryBibtex_entry to free.

Definition at line 232 of file bibtex_entry.c.

void add_field_to_bibtex_entry ( Bibtex_entry entry,
const char *  name,
const char *  value 
)

Adds a field to a Bibtex_entry.

Parameters:
entryBibtex_entry to add the field to.
nameField name.
valueField value.

Definition at line 251 of file bibtex_entry.c.

void write_bibtex_entry ( Bibtex_entry entry,
FILE *  fp 
)

Writes a Bibtex_entry to a file stream.

Parameters:
entryBibtex_entry to write.
fpFile string to write to.

Definition at line 281 of file bibtex_entry.c.