nvpair.h File Reference

This module is deprecated, please use jx.h for new code. More...

`#include <stdio.h>`
`#include "int_sizes.h"`
`#include "hash_table.h"`

Go to the source code of this file.

## Functions

struct nvpair * | nvpair_create ()
| Create an empty nvpair.
void | nvpair_delete (struct nvpair *n)
| Delete an nvpair.
void | nvpair_parse (struct nvpair *n, const char *text)
| Load in an nvpair from ASCII text.
int | nvpair_parse_stream (struct nvpair *n, FILE *stream)
| Load in an nvpair from a standard I/O stream.
int | nvpair_print (struct nvpair *n, char *text, int length)
| Print an nvpair to ASCII text with a limit.
int | nvpair_print_alloc (struct nvpair *n, char **text)
| Print an nvpair to ASCII text, allocating the needed buffer.
void | nvpair_remove (struct nvpair *n, const char *name)
| Remove a property from an nvpair.
void | nvpair_insert_string (struct nvpair *n, const char *name, const char *value)
| Insert a property in string form.
void | nvpair_insert_integer (struct nvpair *n, const char *name, INT64_T value)
| Insert a property in integer form.
void | nvpair_insert_float (struct nvpair *n, const char *name, double value)
| Insert a property in floating point form.
const char * | nvpair_lookup_string (struct nvpair *n, const char *name)
| Lookup a property in string form.
INT64_T | nvpair_lookup_integer (struct nvpair *n, const char *name)
| Lookup a property in integer form.
double | nvpair_lookup_float (struct nvpair *n, const char *name)
| Lookup a property in floating point form.
void | nvpair_export (struct nvpair *nv)
| Export all items in the nvpair to the environment with setenv.
void | nvpair_first_item (struct nvpair *nv)
| Begin iteration over all items.
int | nvpair_next_item (struct nvpair *nv, char **name, char **value)
| Continue iteration over all items.

## Detailed Description

This module is deprecated, please use jx.h for new code.

An nvpair object is a collection of name-value pairs that might describe a complex object such as a host or a job. An nvpair object is a subset of the full generality of an XML document or a ClassAd. In fact, an nvpair can easily be exported into these and other formats. We use an nvapir object instead of these other database, because it has a dramatically simpler implementation that these other complex datatypes and removes any dependence on external software.

## Function Documentation

## nvpair_create()

struct nvpair * nvpair_create | ( |  | ) |

Create an empty nvpair.

Deprecated
  {

Returns
  A pointer to an nvpair.

## nvpair_delete()

void nvpair_delete | ( | struct nvpair * | n | ) |

Delete an nvpair.

Also deletes all contained names and values.

Parameters

  n | The nvpair to delete.

## nvpair_parse()

void nvpair_parse | ( | struct nvpair * | n,
|  | const char * | text )

Load in an nvpair from ASCII text.

Parameters

  n | An nvpair from nvpair_create.
  text | The ASCII text to parse.

## nvpair_parse_stream()

int nvpair_parse_stream | ( | struct nvpair * | n,
|  | FILE * | stream )

Load in an nvpair from a standard I/O stream.

Parameters

  n | An nvpair from nvpair_create.
  stream | The I/O stream to read.

## nvpair_print()

int nvpair_print | ( | struct nvpair * | n,
|  | char * | text,
|  | int | length )

Print an nvpair to ASCII text with a limit.

Parameters

  n | The npvair to print.
  text | The buffer to print to.
  length | The length of the buffer in bytes.

Returns
  The actual length of buffer needed, in bytes.

## nvpair_print_alloc()

int nvpair_print_alloc | ( | struct nvpair * | n,
|  | char ** | text )

Print an nvpair to ASCII text, allocating the needed buffer.

Parameters

  n | The npvair to print.
  text | A pointer to a buffer pointer that will be allocated to the needed size.

Returns
  The actual number of bytes written.

## nvpair_remove()

void nvpair_remove | ( | struct nvpair * | n,
|  | const char * | name )

Remove a property from an nvpair.

Parameters

  n | The nvpair to modify.
  name | The name of the property to remove.

## nvpair_insert_string()

void nvpair_insert_string | ( | struct nvpair * | n,
|  | const char * | name,
|  | const char * | value )

Insert a property in string form.

Parameters

  n | The nvpair to modify.
  name | The name of the property to insert.
  value | The value of the property to insert.

## nvpair_insert_integer()

void nvpair_insert_integer | ( | struct nvpair * | n,
|  | const char * | name,
|  | INT64_T | value )

Insert a property in integer form.

Parameters

  n | The nvpair to modify.
  name | The name of the property to insert.
  value | The value of the property to insert.

## nvpair_insert_float()

void nvpair_insert_float | ( | struct nvpair * | n,
|  | const char * | name,
|  | double | value )

Insert a property in floating point form.

Parameters

  n | The nvpair to modify.
  name | The name of the property to insert.
  value | The value of the property to insert.

## nvpair_lookup_string()

const char * nvpair_lookup_string | ( | struct nvpair * | n,
|  | const char * | name )

Lookup a property in string form.

Parameters

  n | The nvpair to examine.
  name | The name of the property to return.

Returns
  A pointer to the property string, if present, otherwise null.

## nvpair_lookup_integer()

INT64_T nvpair_lookup_integer | ( | struct nvpair * | n,
|  | const char * | name )

Lookup a property in integer form.

Parameters

  n | The nvpair to examine.
  name | The name of the property to return.

Returns
  The integer value of the property, or zero if not present or not a number.

## nvpair_lookup_float()

double nvpair_lookup_float | ( | struct nvpair * | n,
|  | const char * | name )

Lookup a property in floating point form.

Parameters

  n | The nvpair to examine.
  name | The name of the property to return.

Returns
  The floating point value of the property, or zero if not present or not a number.

## nvpair_export()

void nvpair_export | ( | struct nvpair * | nv | ) |

Export all items in the nvpair to the environment with setenv.

Parameters

  nv | The nvpair to be exported.

## nvpair_first_item()

void nvpair_first_item | ( | struct nvpair * | nv | ) |

Begin iteration over all items.

This function begins a new iteration over an nvpair, allowing you to visit every name and value in the table. Next, invoke nvpair_next_item to retrieve each value in order.

Parameters

  nv | A pointer to an nvpair.

## nvpair_next_item()

int nvpair_next_item | ( | struct nvpair * | nv,
|  | char ** | name,
|  | char ** | value )

Continue iteration over all items.

This function returns the next name and value in the iteration.

Parameters

  nv | A pointer to an nvpair.
  name | A pointer to a name pointer.
  value | A pointer to a value pointer.

Returns
  Zero if there are no more elements to visit, one otherwise.