Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Examples

datafile.c File Reference

#include <string.h>
#include "libnjb.h"
#include "njb_error.h"
#include "defs.h"
#include "base.h"
#include "unicode.h"
#include "protocol3.h"
#include "byteorder.h"
#include "datafile.h"

Functions

njb_datafile_tdatafile_new (void)
void NJB_Datafile_Destroy (njb_datafile_t *df)
u_int64_t datafile_size (njb_datafile_t *df)
void datafile_set_size (njb_datafile_t *df, u_int64_t size)
void datafile_set_time (njb_datafile_t *df, time_t ts)
int datafile_set_name (njb_datafile_t *df, const char *filename)
int datafile_set_folder (njb_datafile_t *df, const char *folder)
njb_datafile_tdatafile_unpack (unsigned char *data, size_t nbytes)
unsigned char * datafile_pack (njb_datafile_t *df, u_int32_t *size)
unsigned char * datafile_pack3 (njb_t *njb, njb_datafile_t *df, u_int32_t *size)
unsigned char * new_folder_pack3 (njb_t *njb, const char *name, u_int32_t *size)

Variables

int __sub_depth
int njb_unicode_flag

Detailed Description

This file contains functions that deal with putting regular data files onto the devices. It is not quite a "file system" but metadata elements in a database that have all the attributes of regular files.

Function Documentation

njb_datafile_t* datafile_new void   ) 
 

Creates a new datafile struct.

Returns:
a nullified and freshly allocated njb_datafile_t struct

unsigned char* datafile_pack njb_datafile_t df,
u_int32_t *  size
 

A function that packs a datafile tag into the format used by the NJB1.

Parameters:
df the datafile tag to pack.
size a pointer to a variable that shall hold the size of the packed object after this function has been called.
Returns:
a pointer to the packed struct, which must be freed by the caller after use.

unsigned char* datafile_pack3 njb_t njb,
njb_datafile_t df,
u_int32_t *  size
 

This function packs (serialize, marshall) a high-level representation of a datafile metadata structure into a simple byte-array as used by the series 3 devices.

Parameters:
njb the NJB object to use
df the datafile in libnjb structure format
size a pointer to an integer that will hold the resulting size of the packed structure
Returns:
the packed structure as a newly allocated byte array. The caller shall free this memory after use. Returns NULL on failure.

int datafile_set_folder njb_datafile_t df,
const char *  folder
 

Helper function that sets the foldername of a datafile.

Parameters:
df the datafile to be altered.
folder the new folder name. Folder names always begin and end with a backslash (\) with a backslash separator between levels, like this: "\foo\bar\fnord\".
Returns:
0 on success, -1 on failure.

int datafile_set_name njb_datafile_t df,
const char *  filename
 

Helper function that sets the name of a datafile.

Parameters:
df the datafile to be altered.
filename the new name.
Returns:
0 on success, -1 on failure.

void datafile_set_size njb_datafile_t df,
u_int64_t  size
 

Helper function that sets the size of the datafile.

Parameters:
df the datafile to be altered.
size the size of the file as a 64bit unsigned integer.

void datafile_set_time njb_datafile_t df,
time_t  ts
 

Helper function that sets the timestamp for a datafile.

Parameters:
df the datafile to be altered.
ts the new timestamp for this datafile.

u_int64_t datafile_size njb_datafile_t df  ) 
 

Helper function that returns the size of the datafile as a 64bit unsigned integer

Parameters:
df the datafile whose size we are interested in.
Returns:
the size.

njb_datafile_t* datafile_unpack unsigned char *  data,
size_t  nbytes
 

Unpacks a datafile struct from NJB1.

Parameters:
data the raw binary data to unpack
nbytes the size of the raw binary data in bytes
Returns:
a newly allocated and filled in njb_datafile_t struct.

unsigned char* new_folder_pack3 njb_t njb,
const char *  name,
u_int32_t *  size
 

This creates a folder metadata entry for a new folder on the series 3 devices. (Not applicable for NJB1.)

Parameters:
njb the NJB object to use
name the name of the new folder, must have a reasonable format!
size a pointer to an integer that will hold the resulting size of the packed folder structure
Returns:
the packed folder structure as a newly allocated byte array. the caller shall free this memory after use. Returns NULL on failure.


Variable Documentation

int __sub_depth
 

The current subroutine depth for all of libnjb (global)


Generated on Thu Oct 20 20:35:58 2005 for libnjb by  doxygen 1.4.4