NCEPLIBS-bufr 11.7.1
cfe.h File Reference

Define signatures and declare variables for internal storage of master Code/Flag table entries. More...

Go to the source code of this file.

Data Structures

struct  code_flag_entry
 This structure contains array and variable declarations used to store a master Code/Flag table entry. More...
 

Macros

#define MAX_MEANING_LEN   150
 

Functions

int cmpstia1 (const void *, const void *)
 This function defines a comparison between two entries within the internal memory structure for storage of master Code/Flag table entries. More...
 
int cmpstia2 (const void *, const void *)
 This function defines a comparison between two entries within the internal memory structure for storage of master Code/Flag table entries. More...
 
void dlloctbf (void)
 This subroutine frees any memory that was dynamically allocated during a previous call to subroutine inittbf(). More...
 
void inittbf (void)
 This subroutine initializes the internal memory structure for storage of master Code/Flag table entries, including dynamically allocating space for this structure if needed. More...
 
void sorttbf (void)
 This subroutine sorts the entries within the internal memory structure for storage of master Code/Flag table entries, in preparation for future searches using subroutine srchtbf(). More...
 
void srchtbf (f77int *, f77int *, f77int *, f77int *, f77int *, char *, f77int *, f77int *, f77int *)
 This subroutine searches for a specified FXY number and associated value (code figure or bit number) within the internal memory structure for storage of master Code/Flag table entries, and if found returns the associated meaning as a character string. More...
 
void strtbfe (f77int *, f77int *, char *, f77int *, f77int *, f77int *)
 This subroutine adds a new entry to the internal memory structure for storage of master Code/Flag table entries. More...
 

Variables

struct code_flag_entrycfe
 Master Code/Flag table entries. More...
 
f77int mxmtbf
 Maximum number of master Code/Flag table entries, counting across all individual Code/Flag tables, and counting each defined code figure (within each individual Code table) or defined bit number (within each individual Flag table) as a separate entry. More...
 
f77int nmtf
 Number of stored master Code/Flag table entries in cfe, up to a maximum of MXMTBF. More...
 

Detailed Description

Define signatures and declare variables for internal storage of master Code/Flag table entries.

Author
J. Ator
Date
2017-11-16

Definition in file cfe.h.


Data Type Documentation

◆ code_flag_entry

struct code_flag_entry

This structure contains array and variable declarations used to store a master Code/Flag table entry.

Definition at line 33 of file cfe.h.

Data Fields
f77int iffxyn Bit-wise representation of FXY number to which this entry belongs.
f77int iffxynd Bit-wise representation of FXY number upon which this entry is dependent, if any.

Set to (-1) if no dependency.

char ifmeaning[MAX_MEANING_LEN+1] Meaning corresponding to ifval.
f77int ifval Code figure or bit number.
f77int ifvald Code figure or bit number upon which this entry is dependent, if any.

Set to (-1) if no dependency.

Macro Definition Documentation

◆ MAX_MEANING_LEN

#define MAX_MEANING_LEN   150

Definition at line 8 of file cfe.h.

Function Documentation

◆ cmpstia1()

int cmpstia1 ( const void *  pe1,
const void *  pe2 
)

This function defines a comparison between two entries within the internal memory structure for storage of master Code/Flag table entries.

The comparison is used by the intrinsic C functions qsort and bsearch, and it differs from the the comparison in function cmpstia2() because it compares all of the iffxyn, ifval, iffxynd and ifvald components of the structure, whereas cmpstia2() only compares the iffxyn and ifval components.

Author
J. Ator
Date
2017-11-13
Parameters
[in]pe1– struct code_flag_entry*: First master Code/Flag table entry
[in]pe2– struct code_flag_entry*: Second master Code/Flag table entry
Returns
cmpstia1 – integer:
  • -1 = pe1 is less than pe2
  • 0 = pe1 is equal to pe2
  • 1 = pe1 is greater than pe2

Program history log:

Date Programmer Comments
2017-11-13 J. Ator Original author

Definition at line 34 of file cmpstia1.c.

References code_flag_entry::iffxyn, code_flag_entry::iffxynd, code_flag_entry::ifval, and code_flag_entry::ifvald.

Referenced by sorttbf(), and srchtbf().

◆ cmpstia2()

int cmpstia2 ( const void *  pe1,
const void *  pe2 
)

This function defines a comparison between two entries within the internal memory structure for storage of master Code/Flag table entries.

The comparison is used by the intrinsic C function bsearch, and it differs from the the comparison in function cmpstia1() because it only compares the iffxyn and ifval components of the structure, whereas cmpstia1() compares all of the iffxyn, ifval, iffxynd and ifvald components of the structure.

Author
J. Ator
Date
2017-11-13
Parameters
[in]pe1– struct code_flag_entry*: First master Code/Flag table entry
[in]pe2– struct code_flag_entry*: Second master Code/Flag table entry
Returns
cmpstia2 – integer:
  • -1 = pe1 is less than pe2
  • 0 = pe1 is equal to pe2
  • 1 = pe1 is greater than pe2

Program history log:

Date Programmer Comments
2017-11-13 J. Ator Original author

Definition at line 34 of file cmpstia2.c.

References code_flag_entry::iffxyn, and code_flag_entry::ifval.

Referenced by srchtbf().

◆ dlloctbf()

void dlloctbf ( void  )

This subroutine frees any memory that was dynamically allocated during a previous call to subroutine inittbf().

Author
J. Ator
Date
2017-11-03

Program history log:

Date Programmer Comments
2017-11-03 J. Ator Original author

Definition at line 20 of file dlloctbf.c.

References cfe.

Referenced by exitbufr().

◆ inittbf()

void inittbf ( void  )

This subroutine initializes the internal memory structure for storage of master Code/Flag table entries, including dynamically allocating space for this structure if needed.

Author
J. Ator
Date
2017-11-03

Program history log:

Date Programmer Comments
2017-11-03 J. Ator Original author

Definition at line 22 of file inittbf.c.

References bort(), cfe, igetprm(), mxmtbf, and nmtf.

Referenced by rdmtbf().

◆ sorttbf()

void sorttbf ( void  )

This subroutine sorts the entries within the internal memory structure for storage of master Code/Flag table entries, in preparation for future searches using subroutine srchtbf().

Author
J. Ator
Date
2017-11-16

Program history log:

Date Programmer Comments
2017-11-16 J. Ator Original author

Definition at line 20 of file sorttbf.c.

References cfe, cmpstia1(), and nmtf.

Referenced by rdmtbf().

◆ srchtbf()

void srchtbf ( f77int *  ifxyi,
f77int *  ivali,
f77int *  ifxyd,
f77int *  mxfxyd,
f77int *  ivald,
char *  meaning,
f77int *  mxmng,
f77int *  lnmng,
f77int *  iret 
)

This subroutine searches for a specified FXY number and associated value (code figure or bit number) within the internal memory structure for storage of master Code/Flag table entries, and if found returns the associated meaning as a character string.

The search may optionally include a specified second FXY number and associated value upon which the first FXY number and its associated value depend, for example when the meaning of an originating sub-center value depends on the identity of the originating center for which the sub-center in question is a member.

Author
J. Ator
Date
2018-01-11
Parameters
[in]ifxyi– f77int*: Bit-wise representation of FXY number to search for
[in]ivali– f77int*: Value (code figure or bit number) associated with ifxyi
[in,out]ifxyd– f77int*:
  • On input, ifxyd[0] is set to the bit-wise representation of the FXY number upon which ifxyi and ivali depend, or else set to (-1) if ifxyi and ivali do not depend on the value associated with any other FXY number
  • On output, if the initial search of the master Code/Flag table was unsuccessful, and if ifxyd[0] and ivald were both set to (-1) on input, and if a second search of the table determines that the meaning of ifxyi and ivali indeed depends on one or more other FXY numbers, then the bit-wise representations of those FXY numbers are returned within the first iret elements of ifxyd
[in]ivald– f77int*: Value (code figure or bit number) associated with the FXY number in ifxyd[0]; set to (-1) whenever ifxyd[0] is also set to (-1)
[in]mxfxyd– f77int*: Dimensioned size (in f77ints) of ifxyd; used by the subroutine to ensure that it doesn't overflow the ifxyd array
[in]mxmng– f77int*: Dimensioned size (in bytes) of meaning string; used by the subroutine to ensure that it doesn't overflow the meaning string
[out]meaning– char*: Meaning corresponding to ifxyi and ivali (and to ifxyd[0] and ivald, if specified on input)
[out]lnmng– f77int*: Length (in bytes) of string returned in CMEANG
[out]iret– f77int*: return code
  • 0 = meaning found and stored in meaning string
  • -1 = meaning not found
  • >0 = meaning not found, and ifxyd[0] and ivald were both set to (-1) on input, and the meaning of ifxyi and ivali depends on the the value associated with one of the FXY numbers whose bit-wise representation is stored in the first iret elements of ifxyd

Program history log:

Date Programmer Comments
2018-01-11 J. Ator Original author

Definition at line 74 of file srchtbf.c.

References cfe, cmpstia1(), cmpstia2(), code_flag_entry::iffxyn, code_flag_entry::iffxynd, code_flag_entry::ifmeaning, code_flag_entry::ifval, code_flag_entry::ifvald, and nmtf.

Referenced by getcfmng(), and ufdump().

◆ strtbfe()

void strtbfe ( f77int *  ifxyn,
f77int *  ival,
char *  meaning,
f77int *  lmeaning,
f77int *  idfxy,
f77int *  idval 
)

This subroutine adds a new entry to the internal memory structure for storage of master Code/Flag table entries.

Author
J. Ator
Date
2017-11-13
Parameters
[in]ifxyn– f77int*: Bit-wise representation of FXY number for which ival is a defined code or flag table entry
[in]ival– f77int*: Code figure or bit number
[in]meaning– char*: Meaning associated with ifxyn and ival
[in]lmeaning– f77int*: Length (in bytes) of meaning
[in]idfxy– f77int*: Bit-wise representation of FXY number upon which ifxyn and ival depend (if any), or else set to a value of (-1)
[in]idval– f77int*: Code figure or bit number associated with idfxy and upon which ifxyn and ival depend (if any), or else set to (-1) whenever idfxy is also set to (-1)

Program history log:

Date Programmer Comments
2017-11-13 J. Ator Original author

Definition at line 33 of file strtbfe.c.

References bort(), cfe, code_flag_entry::iffxyn, code_flag_entry::ifval, mxmtbf, and nmtf.

Referenced by sntbfe().

Variable Documentation

◆ cfe

cfe
extern

Master Code/Flag table entries.

Referenced by dlloctbf(), inittbf(), sorttbf(), srchtbf(), and strtbfe().

◆ mxmtbf

mxmtbf
extern

Maximum number of master Code/Flag table entries, counting across all individual Code/Flag tables, and counting each defined code figure (within each individual Code table) or defined bit number (within each individual Flag table) as a separate entry.

Referenced by inittbf(), and strtbfe().

◆ nmtf

nmtf
extern

Number of stored master Code/Flag table entries in cfe, up to a maximum of MXMTBF.

Referenced by inittbf(), sorttbf(), srchtbf(), and strtbfe().