Next: , Previous: bpipe_dpkt_n, Up: Data Packet Field Manipulations


A.3.2 bpipe_dpktf_add

Add a data packet field to the core image of a data packet.

Synopsis

     #include <bpipe/bpipe.h>
     
     
     
int bpipe_dpktf_add( BPipe *bpipe, const char *name, BPDataType type, BPMatrix *matrix );

Parameters

BPipe *bpipe
the binary pipe to which to add the new data packet field
const char *name
the name of the new field
BPDataType type
the data type of the new field
          
          
Possible values for a BPDataType are as follows: BPDType_char, BPDType_double, BPDType_int, BPDType_uint, BPDType_DVector2, BPDType_DVector3, BPDType_IVector2, BPDType_IVector3, BPDType_UIVector2, BPDType_UIVector3, BPDType_DComplex, BPDType_DCVector2, BPDType_DCVector3
BPMatrix *matrix
the field's matrix description

Description

This routine adds a new field to the definition of the core image of a data packet. If no similarly named field exists, a new field with the given name is created and placed at the end of the list of current fields. The name data is duplicated. If the matrix specification is NULL, a matrix specification for a scalar is constructed.

If the calling procedure constructs a matrix specification (a BPMatrix structure), bpipe_dpktf_add uses this structure as is and directs the BPipe cleanup code to take responsibility for freeing it. The calling procedure should not free it, nor should it pass it to any other BPipe routine which takes responsibility for freeing it. It should not alter it in any way after passing it to bpipe_dpktf_add.

Returns

It returns ‘0’ upon success. If a field with the same name already exists, it returns ‘1’. It returns ‘-1’ upon error, and sets bpipe_errno.

Errors

Upon error bpipe_errno is set to one of the following:

BPEBADARG

BPENOMEM
a memory allocation failed