Chapter 2. FDL Functions

Table of Contents

2.1. Overview
2.2. fballoc
2.3. fbbufop
2.4. fbbufop_proj
2.5. fbcalcsize
2.6. fbchg_tu
2.7. fbchg_tut
2.8. fbdelall
2.9. fbdelall_tu
2.10. fbdelete
2.11. fbextread
2.12. fbfldcount
2.13. fbfprint
2.14. fbfree
2.15. fbftos
2.16. fbget
2.17. fbgetalloc_tu
2.18. fbgetalloc_tut
2.19. fbget_fbsize
2.20. fbget_fldkey
2.21. fbget_fldname
2.22. fbget_fldno
2.23. fbget_fldtype
2.24. fbgetlast_tu
2.25. fbget_strfldtype
2.26. fbget_tu
2.27. fbget_tut
2.28. fbget_unused
2.29. fbget_used
2.30. fbgetf
2.31. fbgetlen
2.32. fbgetnth
2.33. fbgetntht
2.34. fbgetval
2.35. fbgetvali
2.36. fbgetval_last_tu
2.37. fbgetvall_tu
2.38. fbgetvals
2.39. fbgetvals_tu
2.40. fbgetvalt
2.41. fbinit
2.42. fbinsert
2.43. fbisfbuf
2.44. fbispres
2.45. fbkeyoccur
2.46. fbmake_fldkey
2.47. fbnext_tu
2.48. fbprint
2.49. fbput
2.50. fbputt
2.51. fbrealloc
2.52. fbread
2.53. fbsnull
2.54. fbstelinit
2.55. fbstinit
2.56. fbstof
2.57. fbstrerror
2.58. fbtypecvt
2.59. fbupdate
2.60. fbwrite
2.61. getfberrno
2.62. getfberror

This chapter lists and describes the usage of FDL functions.

2.1. Overview

The following lists each FDL function and gives a short description.

Function nameDescription
fballocCalculates the size of a field buffer and allocates memory.
fbbufopCopies, moves, and compares field data within a field buffer by inputting the 'mode' parameter.
fbbufop_projCopies field data in a certain field buffer to a specified field buffer.
fbcalcsizeCalculates the size of a field buffer to allocate a proper amount of memory using the fballoc() or tpalloc() functions.
fbchg_tuModifies field serial data of a field key specified in a field buffer.
fbchg_tutReplaces the value of a field key whose type is specified by the type of another field key at a specified start position in a field buffer allocated by the fballoc() or tpalloc() functions. Also changes the values of previously stored data to another value by specifying a field value type.
fbdelallDeletes all field key data specified in a field buffer.
fbdelall_tuDeletes all data in a field that is specified in a field key array.
fbdeleteDeletes data in a field at a specified position in a field buffer allocated by the fballoc() or tpalloc() function.
fbextreadReads a field key and its value from a file specified in iop and saves it in a field buffer which is allocated to the memory by the fballoc() or tpalloc() functions.
fbfldcountReturns the number of all fields within a field buffer allocated by the fballoc() or tpalloc() functions.
fbfprintPrints field data that is saved in a field buffer to a file stream.
fbfreeFrees memory in a field buffer allocated by the fballoc() or tpalloc() functions.
fbftosTransfers data saved in a field buffer to a matched struct buffer.
fbgetReads the field data that corresponds to the field key of a field buffer.
fbgetalloc_tuReads the field data that corresponds to the sequential number of a field key.
fbgetalloc_tutStores the field data that corresponds to the sequential number of a field key. It is specified in a field buffer, in a defined data type in the buffer that is re-allocated to a defined length, and returned.
fbget_fbsizeObtains the size of a field buffer allocated by the fballoc() or tpalloc() functions.
fbget_fldkeyReturns the identifier of a field matched with a specified field name by referencing the table (FDL file set in FDLFILE) that was created by compiling in fdlc.
fbget_fldnameReturns a field name for a specified field key by referencing the table (FDL file set in FDLFILE) that was created by compiling in fdlc.
fbget_fldnoReturns a field number that matches with a specified field key.
fbget_fldtypeReturns and converts the field type of a specified field key into an integer.
fbgetlast_tuReturns the last data entry of fields defined in a field buffer.
fbget_strfldtypeReturns the field type for each field in a string.
fbget_tuReturns the field data that corresponds to the field sequential number in a field key.
fbget_tutConverts the field data that corresponds to a field sequential number of a specified field key into a specified type and then returns it.
fbget_unusedCalculates the size of unused fields in a field buffer allocated by the fballoc() or tpalloc() functions, and returns it in bytes.
fbget_usedCalculates the size of used fields in a field buffer allocated by the fballoc() or tpalloc() functions, and then returns it in bytes.
fbgetfSequentially returns the field data stored in a field buffer allocated by the fballoc() or tpalloc() functions.
fbgetlenReturns the length of the data that corresponds to the field sequential number of a specified field key.
fbgetnthReturns the number of fields that contains specified field data that is stored in a specified field key.
fbgetnthtReturns the sequential number of fields in which specified data is stored out of field data that is stored in a specified field key.
fbgetvalReturns the field data that corresponds to a specified field sequential number from field data that is stored in a specified field key in a field buffer.
fbgetvaliConverts field data that corresponds to a specified field sequential number into an integer, and then returns the value.
fbgetval_last_tuReturns the last sequentially number data from the field data stored in a field key specified in a field buffer.
fbgetvall_tuConverts the field data of a field sequential number of a field key specified in a field buffer into long type and returns it.
fbgetvalsConverts the field data of a field sequential number of a field key specified in a field buffer into string type and returns it.
fbgetvals_tuReturns the field data that is stored in a field key in a field buffer.
fbgetvaltConverts the field data corresponding to a field sequential number in a field key specified in a field buffer into a specified type (totype), and then returns it.
fbinitInitializes a field buffer allocated by the tpalloc() or fballoc() function.
fbinsertReturns data corresponding to the sequential number of a field key specified in a field buffer allocated by fballoc() or tpalloc().
fbisfbufChecks whether or not a specified field buffer is valid.
fbispresChecks whether or not the field data in a sequential number of a field specified in a field buffer exists.
fbkeyoccurReturns the number of fields in a field key specified in a field buffer.
fbmake_fldkeyDynamically creates a new field key.
fbnext_tuReturns the next field key and field data in a field buffer.
fbprintPrints out the data in a field buffer with a standard output.
fbputAdds a new field to a field buffer.
fbputtAdds a new field to a field buffer allocated by fballoc() or tpalloc().
fbreallocRe-allocates a field buffer by increasing the memory capacity when the size of the buffer is not enough.
fbreadReads data from a specified file stream and loads it in a field buffer.
fbsnullChecks whether or not the member variable in a structure mapped to the field sequential number of a specified field key is NULL.
fbstelinitInitializes the member variables of a structure to NULL.
fbstinitInitializes a specified struct variable.
fbstofUnlike fbftos(), fbstof sends data stored in a C struct buffer (stname) to a matching field buffer.
fbstrerrorIn the event of a field buffer operation, returns error details to a string.
fbtypecvtConverts the type of field data specified in fromval from fromtype into totype, and returns the data.
fbupdateUpdates the field value for a field key in a field buffer allocated by the fballoc() or tpalloc() function at a specified position. Generally the function is used to replace the data that was passed from other process in a field buffer.
fbwriteStores contents of a field buffer allocated by fballoc() or tpalloc() into a file stream specified in iop.
getfberrnoReturns an error code when an error occurs while performing an API function related to a field buffer.
getfberrorReturns an error code when an error occurs while performing an API function related to a field buffer.

2.2. fballoc

The fballoc function calculates a field buffer size and allocates its memory.

The number of fields and their lengths are passed into a function and used to calculate their size and allocate memory for the field buffer.

Allocated memory size = count*sizeof(int) + datalen + the size of field key header

A minimum of 1024 bytes is allocated even if the calculated size of fields is less than 1024 bytes. fballoc() only allocates the minimum required amount of memory to improve efficiency. Use the fbfree function to release the allocated memory when it is no longer used. Memory must be released after use.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    FBUF *fballoc(int count, FLDLEN datalen)
  • Parameter

    ParameterDescription
    countNumber of fields to be stored in memory.
    datalenTotal size of fields in bytes.
  • Return value

    Return valueDescription
    Memory pointerFunction call is successful.
    NULLFunction call failed. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEMALLOCSystem error. Failed to allocate memory for a field buffer.
  • Example

    #include <fbuf.h>
    #include <atmi.h>
    ...
    FBUF *fbuf;
    if ((fbuf = fballoc(100, 1000)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ...
    /* result allocated size : 1408 bytes */

    The following is an example of an alternative method of allocating a field buffer using tpalloc(). If the third parameter of tpalloc() is set to 0 or a value less than the default value, the default value of 1024 bytes will be allocated.

    . . .
    FBUF *fbuf;
    if ((fbuf = (FBUF *)tpalloc(“FIELD”, NULL, 0)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    /* result allocated size : 1024 bytes */
  • Related functions

    fbisfbuf(), fbcalcsize(), tpalloc(), fbinit()

2.3. fbbufop

The fbbufop function copies, moves, and compares field data within a field buffer according to the mode parameter. The dest and src parameters cannot share the same buffer. Each parameter must use different buffers allocated to different memory.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbbufop(FBUF *dest, FBUF *src, int mode)
  • Parameter

    ParameterDescription
    destAllocated by fballoc() or tpalloc(). Stores the contents of src by mode.
    srcAllocated by fballoc() or tpalloc(). Includes the value to be modified.
    modeSpecifies one of the following process modes.

    The following are the available modes:

    Process modeDescription
    FBMOVE

    Moves all src field buffer data to a dest field buffer. A string or carray buffer can be used for dest in this mode.

    To use a string or carray buffer, perform type casting on a field buffer (FBUF *) when using the dest parameter.

    FBCOPYCopies all src field buffer data to a dest field buffer. Both dest and src must be field buffers.

    FBCOMP

    Compares src and dest buffers. Input options:

    • 0 or 1: Values of the dest and src field buffers match. If the values, structure, number, and order of the two buffers are identical, 0 is returned. If only the values are not identical, while the others are the same, 1 is returned.

    • -1: dest and src field buffers do not match.

    FBCONCATAdds fields from a src buffer to a dest buffer. In the dest field buffer, existing data and data from the src field buffer are stored.
    FBJOINFields whose occurrence matches the fields of a field key are copied from the src field buffer to the dest field buffer. All previously existing data in the dest field buffer is overwritten.
    FBOJOINFunctions the same as FBJOIN but the data of dest buffer fields that have no corresponding field key/occurrence in a source buffer are not deleted and remain in the destination buffer.
    FBUPDATESimilar to FBOJOIN. From the src field buffer to the dest field buffer, fields whose occurrence matches the fields of a field key are copied. Fields that do not have a corresponding field key/occurrence in the source buffer are also copied to a dest field buffer. This effectively updates a destination buffer with the contents of a source field buffer.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values.

    Error codeDescription
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEMALLOCSystem error. Failed to allocate memory for a field buffer.
    FBEINVALInput parameter error.
  • Example

    #include "demo_fdl.h"
    ……
    main()
    {
        FBUF *destbuf, *srcbuf;
        …
        destbuf=fballoc(5,5);
        …
        fbput(destbuf, INPUT, "5555", 0);
        fbput(destbuf, INPUT, "7777", 0);
        fbput(destbuf, OUTPUT, "3333", 0);
        fbput(destbuf, SEQNO, "8888", 0);
    
        srcbuf=fballoc(5,5);
        …
        fbput(srcbuf, INPUT, "1111", 0);
        fbput(srcbuf, OUTPUT, "2222", 0);
        fbput(srcbuf, CORPNO, "3333", 0);
    
        /* Mode selection */
        …
        printf("input : "); 
        scanf("%d", &a);
    
        switch(a)
        {
            /*FBMOVE mode */
            case 1:
                iRet=fbbufop(destbuf, srcbuf, FBMOVE);
                …
    
                fbprint(destbuf);
                break;
            /* destbuf : “1111”, “2222”, “3333”*/
    
            /*FBCOMP mode */
            case 2:
                iRet=fbbufop(destbuf, srcbuf, FBCOMP);
                printf("ret = %d\n", iRet);
                if(iRet < 0) {
                   printf("Do not match!!!\n");
                   fbfree(destbuf);
                   fbfree(srcbuf);
                   exit(0);
                }
                printf("Match!!!\n");
                break;
            /* “Do not match!!! */
    
            /*FBCOPY mode */
            case 3:
                iRet=fbbufop(destbuf, srcbuf, FBCOPY);
                …
                fbprint(destbuf);
                break;
            /* destbuf : “1111”, “2222”, “3333”*/
    
            /*FBCONCAT mode */
            case 4:
                iRet=fbbufop(destbuf, srcbuf, FBCONCAT);
                …
                fbprint(destbuf);
                break;
            /* destbuf : “5555”, “7777”, “3333”, “8888”, “1111”, “2222”, “3333”*/
    
            /*FBJOIN mode */
            case 5:
               iRet=fbbufop(destbuf, srcbuf, FBJOIN);
               …
               fbprint(destbuf);
               break;
            /* destbuf : “1111”, “2222”*/
    
            /*FBOJOIN mode */
            case 6:
               iRet=fbbufop(destbuf, srcbuf, FBOJOIN);
               …
               fbprint(destbuf);
               break;
            /*  destbuf : “1111”, “7777”, “2222”, “8888”*/
    
            /*FBUPDATE mode */
            case 7:
               iRet=fbbufop(destbuf, srcbuf, FBUPDATE);
                …
               fbprint(destbuf);
               break;
            /* destbuf : “1111”, “7777”, “2222”, “8888”, “3333”*/
    
        }
        fbfree(destbuf);
        fbfree(srcbuf);
    }
  • Related functions

    fbbufop_proj()

2.4. fbbufop_proj

The fbbufop_proj function copies the data of a specified field in a src field buffer to a dest field buffer.

The dest and src parameters cannot share the same buffer. Each parameter must use different buffers allocated to different memory.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbbufop_proj(FBUF *dest, FBUF *src, FLDKEY *fldkey)
  • Parameter

    ParameterDescription
    destAllocated by fballoc() or tpalloc(). Stores the contents of src by mode.
    srcAllocated by fballoc() or tpalloc() and includes a value to be modified. If src is set to NULL, data from the specified field is copied to a dest field buffer.
    fldkeySpecifies an array of fields to be copied. '0' must be specified at the end of an array. If the fldkey pointer is declared as an array and then multiple fields are specified to be copied to the array, field data is copied from src to dest.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.

  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBEMALLOCSystem error. Failed to allocate memory for a field buffer.
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    ...
    
    int iRet, i;
    FBUF *destbuf, *srcbuf;
    FLDKEY fkey[4];
    
    ...
    fbput(destbuf, INPUT, "aaa", 0);
    fbput(destbuf, OUTPUT, "bbb", 0);
    fbput(destbuf, SEQNO, "ccc", 0);
    . . .
    fbput(srcbuf, TEST1, "AAA", 0);
    fbput(srcbuf, TEST2, "BBB", 0);
    fbput(srcbuf, TEST3, "CCC", 0);
    
    fkey[0]=fbget_fldkey("INPUT");
    fkey[1]=fbget_fldkey("SEQNO");
    fkey[2]=0; /* The last entry in the array must be 0 */
    
    ret=fbbufop_proj(destbuf, NULL, fkey);
    . . .
    /* destbuf : aaa, ccc */
    . . .
    fkey[0]=fbget_fldkey("TEST3");
    fkey[1]=fbget_fldkey("TEST1");
    fkey[2]=fbget_fldkey("TEST2");
    
    fkey[3]=0; /* The last entry in the array must be 0 */
    
    ret=fbbufop_proj(destbuf, srcbuf, fkey);
    . . .
    /* destbuf : AAA, BBB, CCC */
    /* fkey array is sorted if the entries are not in numeric order */
    . . .
  • Related functions

    fbbufop()

2.5. fbcalcsize

The fbcalcsize function calculates the size of a field buffer. The calculated size is used when allocating memory for a buffer via fballoc() or tpalloc().

fbcalcsize determines the amount of data stored in a field buffer according to the number and the length of all fields in bytes.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h> 
    long fbcalcsize(int count, FLDLEN datalen)
  • Parameter

    ParameterDescription
    countNumber of fields to be stored in memory.
    datalenTotal size of all fields in bytes.
  • Return value

    Returns the size of a field buffer in bytes, which is calculated based on the count and datalen parameters.

  • Example

    #include “demo_fdl.h”
    . . .
    
    FBUF *fbuf;
    long size;
    
    size = fbcalcsize(100, 1000);
    printf(“size : [%ld]\n”, size); /* output : size : [1408] */
    if ((fbuf = (FBUF *)tpalloc(“FIELD”, NULL, size)) == NULL) {
        printf(“tpalloc failed, errno = %d\n”, tperrno);
        .........
    }
    
    /* fbuf is set in 1024 bytes by default if size is less than 1024*/
    .....
  • Related functions

    fballoc(), tpalloc()

2.6. fbchg_tu

The fbchg_tu function replaces a value in a field key with another value at the specified start position in a field buffer allocated by fballoc() or tpalloc().

fbchg_tu modifies previously stored data. It also automatically adds a field key if the nth field occurrence is not in a field buffer. Performance can be reduced when adding field key data.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbchg_tu(FBUF *fbuf, FLDKEY fldkey, int nth, char *value, FLDLEN fldlen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to be changed in a field buffer.
    nthIndex of a field to be changed.
    valueField value to be replaced. value is a string; INTEGER and REAL type data must be converted to the CHARACTER type. If value is set to NULL, the corresponding field key will be cleared.
    fldlenOptional parameter. Note that the length of FB_CARRAY type fields is still required (in bytes).
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTA specified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    ...
    long rcvlen, ret;
    char buffer[100];
    FLDLEN fldlen;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, tperrno);
        ...
    }
        
    fbput(fbuf, INPUT, “aaaa”, 0);  /* There is aaaa in the 0th order. */
    ret = fbchg_tu(fbuf, INPUT, 1, “bbbb ”, 4);   /* bbbb is added in the first order. */
    if (ret < 0) {
        error processing...
    }
    ret = fbget_tu(fbuf, INPUT, 1, buffer, &fldlen); 
    /* Data in the first order is put into the buffer. */
    if (ret < 0) {
        error processing...
    }
    printf(“Field Data: [%s]\n”, buffer);
    /* output : Field Data: [bbbb] */
    
    fbprint(fbuf);   
    /* output : aaaa, bbbb   */
    .....
  • Related functions

    fbbufop_proj()

2.7. fbchg_tut

The fbchg_tut function replaces a value in a field key with a type specified by type. The value is replaced at a specified start position in a field buffer allocated by the fballoc() or tpalloc() function.

fbchg_tut, similar to fbchg_tu(), modifies previously stored data by specifying a type of a field value. However, fbchg_tut is used when the data types of the new and old data differ. It also automatically adds a field key if the nth field key data value is not in a field buffer. Performance can be reduced when adding field key data.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbchg_tut(FBUF *fbuf, FLDKEY fldkey, int nth, char *value, FLDLEN fldlen, int type)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyA field key to be changed in a field buffer.
    nthIndex of a field to be changed.
    valueA field value to be replaced. value is a string; INTEGER and REAL type data must be converted to the CHARACTER type.
    fldlenOptional parameter. However, the length of FB_CARRAY type fields is required (bytes).
    type

    Field value type. Input options: FB_CARRAY, FB_SHORT , FB_DOUBLE , FB_LONG , FB_STRING, FB_CHAR, FB_FLOAT , FB_INT

  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTA specified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVAL

    Input parameter error. (E.g., Data length is not specified when the type is FB_CARRAY.)

    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEBADFLDInvalid field.
  • Example

    #include “demo_fdl.h”
    . . .
    long ret, lVal=100000;
    FBUF *fbuf;
    . . .
    fbputt(fbuf, INPUT, "aaaa", 0, FB_STRING);
    fbchg_tut(fbuf, INPUT, 0, (char *)&lVal, 0, FB_LONG);
    printf("1st occurrence of INPUT field is changed as follows : \n");
    fbprint(fbuf);
    ......
    /* fkey = 469762149, fname = INPUT, type = string, value = 100000 */
  • Related functions

    fbput(), fbchg_tu(), fbget_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu()

2.8. fbdelall

The fbdelall function deletes all field key data specified in a field buffer.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbdelall(FBUF *fbuf, FLDKEY fldkey)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyA field key to be deleted. Before calling this function, at least 1 field occurrence must be saved in the field key in a field buffer. Otherwise, -1 is returned, and fberror is set to FBENOENT.
  • Return value

    Return valueDescription
    Number of deleted fieldsFunction call is successful.
    -1Function call failed to find a specified field key in a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTA specified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    int ret;
    FBUF *fbuf;
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, “cccc”, 0);
    
    ret = fbdelall(fbuf, INPUT);
    printf(“Delete Field Number: [%d]\n”, ret);
    /* output: Delete Field Number: [3] */
    ......
  • Related functions

    fbput(), fbget(), fbdelete(), fbdelall_tu()

2.9. fbdelall_tu

The fbdelall function deletes all field key data specified in a field buffer.

fbdelall_tu() is designed to delete all data in multiple field keys, while fbdelall() is designed to delete all data in a single field key.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbdelall_tu(FBUF *fbuf, FLDKEY *fldkey)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key array that contains multiple field keys to be deleted from a field buffer. The field key pointer points to a field key array that will be deleted. Specify a field key in the field key array, and enter 0 in the last index.
  • Return value

    Return valueDescription
    Number of deleted fieldsFunction call is successful.
    -1A field buffer is invalid and the input parameter is NULL. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values.

    Error codeDescription
    FBENOENTA specified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    FLDKEY fkey[3];
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, OUTPUT, “cccc”, 0);
    
    fkey[0] = INPUT;
    fkey[1] = OUTPUT;
    fkey[2] = 0; /* The last entry in the array must be 0 */
    
    ret = fbdelall_tu(fbuf, fkey);
    printf(“The Number of deleted fields: [%d]\n”, ret);
    
    /* output: Number of deleted fields: [3] */
    .....
  • Related functions

    fbput(), fbget(), fbdelete(), fbdelall()

2.10. fbdelete

The fbdelete function deletes the data in a field at the specified position in a field buffer allocated by the fballoc() or tpalloc() function.

Unlike fbchg_tu(), if a field key is not found at the specified position, an error occurs and fberror is set to FBENOENT. A field buffer must contain a field key for this function to be called.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbdelete(FBUF *fbuf, FLDKEY fldkey, int nth)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyA field key to be deleted from a field buffer.
    nthIndex of a field to be deleted.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed to find a specified field key at the start position in a field buffer. fberrno is set to the error code.

  • Error

    fberrno is set to one of the following values.

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl). If there is no data corresponding to the specified field sequential number, fberror is set to FBENOENT.
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    char buffer[100];
    int ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);  /* The 0th data of fbuf is “aaaa”. */
    fbput(fbuf, INPUT, “bbbb”, 0);  /* The first data of fbuf is “bbbb”. */
    fbput(fbuf, INPUT, “cccc”, 0);  /* The second data of fbuf is “cccc”. */
    fbdelete(fbuf, INPUT, 1);         /* Deletes “bbbb”, the first data of fbuf. */
    
    ret=fbdelete(fbuf, INPUT, 3);
    if(ret<0){
         printf("fbdelete error : %s\n", fbstrerror(fberror));
    }                                 /* As there is no data in the third order of fbuf,  
    fbdelete error : FBENOENT (not found) is displayed. */
    
    fbget(fbuf, INPUT, buffer, 0);
    printf(“INPUT: [%s]\n”, buffer);   /* output:  INPUT: [aaaa] */
    fbget(fbuf, INPUT, buffer, 0);
    printf(“INPUT: [%s]\n”, buffer);   /* output:  INPUT: [cccc] */
    .....
  • Related functions

    fbput(), fbget(), fbdelall(), fbdelall_tu()

2.11. fbextread

The fbextread function reads a field key and its value from the file specified in iop and saves it to a field buffer allocated by fballoc() or tpalloc().

fbextread calls the fbput() function when no flags are set in <demo.f>. If the + flag is set, fbextread calls fbchg_tu() , if the - flag is set, fbextread calls fbdelete(), and if the = flag is set, fbextread calls fbchg_tu() after calling fbget_tu(). If an error occurs in a called function, the error will also occur in fbextread().

The following are the flags, which are set in the <demo.f> file.

flagDescription
+Saves a value to occurrence 0 of a field key in a field buffer.
-Deletes the data in occurrence 0 of a field key in a field buffer.
=Replaces the field value in occurrence 0 of a first field name with a field value in occurrence 0 of a second field name. E.g., in the code shown below, occurrence 0 of field_name1 is replaced by occurrence 0 of field_name2.
#Comment
NULLAdds a new field to a field buffer.

The following are the formats of the data contained in a file that is read by fbextread. The formats are listed by flag.

  1. '+' flag is set. (Or no flag is set)

    [flag] field_name or field_id (tab) field_value
  2. '=' flag is set.

    [flag] field_name1 or field_id1 (tab) field_name2 or field_id2
  3. '-' flag is set.

    [flag] field_name or field_id

  • Prototype

    #include <stdio.h>
    #include <usrinc/fbuf.h>
    
    int fbextread(FBUF *fbuf, FILE *iop)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    iopPointer to a file that contains a field key and its values.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to the following value.

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include <stdio.h>
    #include <usrinc/atmi.h>
    #include <usrinc/fbuf.h>
    #include "demo_fdl.h"
    
    int main()
    {
            long len;
            int ret;
            FILE *fp;
            FBUF *fbuf;
            FLDLEN fldlen;
            char buffer[100];
    
            fbuf = (FBUF *)tpalloc("FIELD", NULL, 0);
            if (fbuf == NULL) {
                printf("fbuf tpalloc fail[%d]\n", tperrnㅇo);
            }
            ret = fbput(fbuf, INPUT, "user_input", 10);
            if (ret < 0) {
                printf("fbput fail[%d]\n", fberror);
                return -1;
            }
            ret = fbput(fbuf, OUTPUT, "user_output", 10);
            if (ret < 0) {
                printf("fbput fail[%d]\n", fberror);
                return -1;
            }
            ret = fbput(fbuf, STATLIN, "user_statlin", 10);
            if (ret < 0) {
                printf("fbput fail[%d]\n", fberror);
                return -1;
            }
            fp = fopen("file", "r");
            fbprint(fbuf);
    
            ret = fbextread(fbuf, fp);
            if (ret < 0) printf("Fextread fail[%s]\n", fberror);
    
            printf("\n\n<after Fextread>-----------------\n");
            fbprint(fbuf); 
            tpfree((char *)fbuf);
    }

    • When the '+' flag is set, occurrence 0 of the STATLIN field key is replaced with 'statlin0_'.

      +STATLIN       statlin0_

      [Result]

      user_input, user_output, statlin0_, user_statlin
    • Adds a field value to the fbuf buffer.

      OUTPUT  OUTPUT0_
      INPUT   INPUT0_
      INPUT   INPUT1_

      [Result]

      user_input, user_output, user_statlin, OUTPUT0_, INPUT0_, INPUT1_
    • When the '=' flag is set, the INPUT value is saved to OUTPUT.

      =OUTPUT  INPUT

      [Result]

      user_input, user_input, user_statlin
    • When the '-' flag is set, the INPUT field key is deleted.

      –INPUT

      [Result]

      user_output, user_statlin

  • Related functions

    fbput(), fbchg_tu(), fbdelete(), fbget_tu()

2.12. fbfldcount

The fbfldcount function returns the total number of fields within a field buffer allocated by the fballoc() or tpalloc() function.

fbfldcount counts the number of field values stored in a field buffer. Various built-in APIs can be used to check the number of fields stored in a field buffer. Even if multiple field keys have the same value, the function recognizes each value as a unique field.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbfldcount(FBUF *fbuf)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
  • Return value

    Return valueDescription
    The number of fieldsFunction call is successful.
    0Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    
    int cnt;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, OUTPUT, “cccc”, 0);
    cnt = fbfldcount(fbuf);
    printf(“Field Count: [%d]\n”, cnt);
    
    /* output: Field Count: [3] */
    . . .
    }
  • Related functions

    fbgetnth(), fbkeyoccur()

2.13. fbfprint

The fbfprint function outputs field data in a field buffer to a file stream.

fbfprint outputs data in a field buffer to a text file. The print format is the same as that of the fbprint() function.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbfprint(FBUF *fbuf, FILE *iop)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    iopPointer to a file stream that field buffer data will output to.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBEBADFBField buffer is invalid. A buffer properly allocated to memory must be used. (Current field buffer cannot be used.)
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    FILE *iop;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    iop = fopen(“sample.text”, “w”);
    fbput(fbuf, INPUT, “5555”, 0);
    fbput(fbuf, INPUT, “7777”, 0);
    fbfprint(fbuf, iop);
    fclose(iop);
  • Related functions

    fbprint()

2.14. fbfree

The fbfree function frees memory that is allocated by fballoc() or tpalloc() for a field buffer.

fbfree releases a previously allocated buffer from memory. Once this function is executed, the current buffer can no longer be used. Call this function only after the buffer is no longer needed.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbfree(FBUF *fbuf)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    int ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ......
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    ret = fbfree(fbuf);
    printf(“fbfree, ret = %d\n”, ret);
    /* output : fbfree, ret = 1 */
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbprint(fbuf);
    /* an error occurs since memory was not allocated. */
  • Related functions

    fbcalcsize(), tpalloc(), fballoc(), fbinit()

2.15. fbftos

The fbftos function transfers field buffer data to a matching structure buffer.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbftos(FBUF *fbuf, char *cstruct, char *stname)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    cstructChanges a structure type variable into (char *) by using type casting in order to use cstruct.
    stnameString that contains the name of structure defined in VIEW.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
    FBEBADSTRUCTInvalid structure. This error generally occurs when a structure type is not recognized by Tmax or a structure definition file is incorrectly compiled.
  • Example

    #include “demo_fdl.h”
    #include “demo_sdl.h”
    . . .
    int ret, fdllen, val = 1000;
    struct demo temp;
    FBUF *fbuf;
    Char *cstruct;
    
    if(tpstart((TPSTART_T *)NULL) == -1) {
        printf(“tpstart failed\n”);
        ........
    }
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    cstruct = (char *)&temp;
    if(fbstinit((char *)&temp, “demo”) < 1)  {
        printf(“fbstinit failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INTDATA, (char *)&val, 0);
    
    if(fbftos(fbuf, cstruct, “demo”) < 0) {
        ........
    }
    ........
  • Related functions

    fbstof(), fbstinit(), fbstelinit()

  • Note

    The fbftos function transfers field buffer data to a matching structure buffer (stname).

    The ***.s structure file, which differs from a general structure file, must be defined in advance. Each field key within a structure file must be mapped to a single member variable of the structure to be defined.

    The following is a sample structure file that provides a mapping function between a field buffer and a C struct.

    VIEW demo
    #type      cname      Fldkey      count      flag      size      null
    string   demodata     INPUT          5        -         20       “”
    carray  carraydata    CARRAYDATA     1        -         20     “star”
    char    chardata      CHARDATA       1        -         -       “c”
    int       inum        INTDATA        5        -         -         0
    short     snum        SHORTDATA      1        -         -         0
    long      lnum        LONGDATA       1        -         -         1
    float     fnum        FLOATDATA      1        -         -        1.0
    double    dnum        DOUBLEDATA     1        -         -        1.0
    END
    ItemDescription
    typeData type of a member variable within a structure.
    cnameName of a member variable.
    FldkeyField key mapped to a specified member variable. (Field key must be defined in advance in ***.f.)
    countMaximum number of field occurrences that can be stored in a structure.
    sizeSize of an array (for string type).
    nullValue during initialization. The value is copied into the C structure by default when transferring field data to the C structure buffer. If no value is stored in a field buffer and no null value is set, an appropriate default value for each data type will be stored in the C structure. The default value for string, carray and char is NULL; 0 for int, short, and long; and 0.0 for float and double.

    After defining a view in demo.s or demo.v, the VIEW file must be compiled with the sdlc utility (structure file compiling utility) in the client.

    $TMAXDIR$/sample/sdl> sdlc –c –v demo.s –o tmax.sdl 
    $TMAXDIR$/sample/sdl> sdlc –c –v demo.v –o tmax.sdl

    With the SDLFILE name specified in a configuration file (.profile file for korn shell), create a '.sdl' file by using the [–o] option so that SDLFILE contains the conversion information between the field key and structure. The field key defined in VIEWFILE must be defined in ***.f in this case.

    When compiling VIEWFILE, <demo_sdl.h> and <tmax.sdl> are generated. Include <demo_sdl.h> in the client program. In the server, VIEWFILE must be compiled with the sdlc utility.

    $TMAXDIR$/sample/sdl> sdlc –v demo.s

    When a structure file is compiled as shown above, <demo_sdl.c> and <demo_sdl.h> will be generated. Because <demo_sdl.c> contains conversion information between a field key and the structure, all server programs must be compiled together with <demo_sdl.c>. A server program does not need <tmax.sdl> because all required information will have been provided for compilation.

    If field keys are not mapped to member variable data when transferring field buffer data to a structure, the field keys will be ignored.

2.16. fbget

The fbget function gets the field data that corresponds to a field key in a field buffer.

fbget retrieves data from a field buffer. Field data for a specified key is read sequentially and then saved to loc. The fbget function reads all field data saved in the field key without having to manually increase the occurrence number. Once data is retrieved it cannot be read again. If this function is called more than the number of occurrences, the field data of the last field will be continuously returned.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbget(FBUF *fbuf, FLDKEY fldkey, char *loc, FLDLEN *fldlen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to be read from a field buffer.
    locPointer to field data that has been successively read. If a field key is an integer or real, use a variable appropriate for each type and perform type casting by using the prototype mentioned above.
    fldlenPointer that indicates the length of field values
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
  • Example

    #include “demo_fdl.h”
    . . .
    long rcvlen, ret;
    FLDLEN fldlen;
    char buffer[100];
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        .......
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, “cccc”, 0);
    
    fbget(fbuf, INPUT, buffer, &fldlen);
    printf(“Field Data: [%s]\n”, buffer);
    /* output: Field Data: [aaaa] */
    . . . 
  • Related functions

    fbput(), fbchg_tu(), fbget_tu(), fbchg_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu()

2.17. fbgetalloc_tu

The fbgetalloc_tut function stores field data that corresponds to a specified field occurrence of a specified field key.

fbgetalloc_tu reads field data that corresponds to the field occurrence of a field key specified in the nth and fldkey parameters. fbgetalloc_tu then allocates a new buffer with a length specified by extralen to store the field data in the buffer and returns a pointer.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbgetalloc_tu(FBUF *fbuf, FLDKEY fldkey, int nth, int *extralen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to be read from a field buffer.
    nthIndex of a field to be read.
    extralenSize of the buffer to be newly allocated in bytes. The memory allocated for the buffer must be released when it is no longer used. If extralen is 0, the buffer size is set to the length of the field data.
  • Return value

    Return valueDescription
    Pointer to the bufferFunction call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEMALLOCSystem error. Failed to allocate memory for a field buffer.
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
  • Example

    #include “demo_fdl.h”
    . . .
    long ret;
    int extralen;
    char *buffer;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, “cccc”, 0);
    
    extralen = 4;
    buffer = fbgetalloc_tu(fbuf, INPUT, 0, &extralen);
    printf(“Field Data: [%s]\n”, buffer);
    /* output: Field Data: [aaaa], returned after adding 4 bytes to
    the length of the field value. */
    fbfree(fbuf);
    ….
  • Related functions

    fbgetalloc_tut(), fbput(), fbchg_tu(), fbget_tu(), fbchg_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu()

2.18. fbgetalloc_tut

The fbgetalloc_tut function stores field data that corresponds to the specified field occurrence of the specified field key. It converts the field data to the specified type and allocates a new buffer with a length specified by extralen. The new buffer stores the field data, and fbgetalloc_tut returns the pointer.

fbgetalloc_tut() is similar to fbgetalloc_tu(), however, fbgetalloc_tut() can convert field data types.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbgetalloc_tut(FBUF *fbuf, FLDKEY fldkey, int nth, int type, int *extralen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to be retrieved from a field buffer.
    nthIndex of a field to be read.
    type

    Field value type. Input options:

    ( FB_CARRAY, FB_SHORT, FB_DOUBLE, FB_LONG, FB_STRING, FB_CHAR, FB_FLOAT, FB_INT)

    extralenSize in bytes to allocate for a new buffer. The memory allocated for the buffer must be released when it is no longer used. If extralen is 0, the buffer size will be set to the length of the field data.
  • Return value

    Return valueDescription
    Pointer of the bufferFunction call is successful. (Returns a pointer to a newly allocated buffer containing field data. If the value type is int, long, double, long, or float type, they cannot be expressed in char *, so perform type casting.)
    NullFunction call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEMALLOCSystem error. Failed to allocate memory for a field buffer.
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    long ret;
    int extralen;
    char *buffer;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, “cccc”, 0);
    
    extralen = 4;
    buffer = fbgetalloc_tut(fbuf, INPUT, 0, FB_STRING, &extralen);
    printf(“Field Data: [%s]\n”, buffer);
    /* output: Field Data: [aaaa], returned after adding 4 bytes to the length of the 
    field value. */
    
    fbfree(fbuf);
    . . .
  • Related functions

    fbgetalloc_tu (), fbput(), fbget_tu(), fbchg_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu()

2.19. fbget_fbsize

The fbget_fbsize function gets the size of a field buffer allocated by fballoc() or tpalloc().

A minimum of 1024 bytes is allocated to a field buffer by fballoc() or tpalloc() even if the calculated buffer size is less than 1024 bytes. If 1024 bytes are allocated, fbget_fbsize() returns 1024 + 8 = 1032 bytes because a 8-byte header that is internally used within Tmax is added. If the size of a field buffer is greater than 1024 bytes, fbget_fbsize() returns (fbcalcsize() + 8 (header size)).

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    long fbget_fbsize(FBUF *fbuf)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
  • Return value

    Return valueDescription
    field buffer sizeFunction call is successful. (Returns the size of allocated memory for a field buffer.)
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    long ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “1111”, 0);
    ret = fbget_fbsize(fbuf ) ;
    printf(“Field Buffer Size: [%ld]\n”, ret);
    /* output: Field Buffer Size: [1024] */
    . . .
  • Related functions

    fbcalcsize(), tpalloc(), fballoc(), fbfree(), fbinit()

2.20. fbget_fldkey

The fbget_fldkey function gets the field key of a specified field name by referencing a table (FDL file set in FDLFILE) that was created after compilation by fdlc. A user must know the field key for a specified field name to store data in a field buffer because a field buffer is based on field key-data pairs.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    FLDKEY fbget_fldkey(char *name)
  • Parameter

    ParameterDescription
    nameField name used to generate a field table.
  • Return value

    Return valueDescription
    0Field name for a specified field key exists in a field table.
    Field key matched with the field nameField name for a specified field key does not exist in a field table.
  • Example

    #include “demo_fdl.h”
    . . .
    FLDKEY fkey;
    FBUF *sndbuf;
    
    fkey = fbget_fldkey(“INPUT”);
    printf(“Field Key : [%d]\n”, fkey);
    
    /* output : Field Key : [469762149] */
    ........
    fbput(sndbuf, fkey, “1111", 0);
    . . .
  • Related functions

    fbget_fldname(), fbget_fldno(), fbget_fldtype(), fbget_strfldtype(), fbtypecvt()

2.21. fbget_fldname

In contrast to the fbget_fldkey() function, the fbget_fldname function returns the field name of a specified field key by referencing the table (FDL file set in FDLFILE) that was created after compilation by fdlc.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbget_fldname(FLDKEY fldkey)
  • Parameter

    ParameterDescription
    fldkeyField key obtained by using fbget_fldkey() or by referring to a header file(***_fdl.h). The header file is generated by compiling the file(***.f), which is used to create a field table in fdlc.
  • Return value

    Return valueDescription
    Field key matched with the field nameField name for a specified field key exists in a field table.
    NULLField name for a specified field key does not exist in a field table.
  • Example

    #include “demo_fdl.h”
    . . .
    FLDKEY fkey;
    char *name;
    
    fkey = fbget_fldkey(“INPUT”);
    printf(“Field Key : [%d]\n”, fkey);
    /* output : Field Key : [469762149] */
    
    name = fbget_fldname(fkey);
    printf(“Field Name : [%s]\n”, name);
    /* output : Field Name : [INPUT] */
    . . .
  • Related functions

    fbget_fldkey(), fbget_fldno(), fbget_fldtype(), fbget_strfldtype(), fbtypecvt()

2.22. fbget_fldno

The fbget_fldno returns the field number that matches the specified field key. To create a field table, a field type, field name, and field number are required, and they can be combined to generate a unique field key. A field table manages these field keys.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbget_fldno(FLDKEY fldkey)
  • Parameter

    ParameterDescription
    fldkeyField key obtained by using fbget_fldkey() or by referring to a header file(***_fdl.h). The header file is generated by compiling the file(***.f), which is used to create a field table in fdlc.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEBADFLDInvalid field.
  • Example

    #include “demo_fdl.h”
    . . .
    long ret;
    FLDKEY len;
    int nth;
    char buffer[100];
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, “cccc”, 0);
    
    fbgetlast_tu(fbuf, INPUT, &nth, buffer, &len);
    printf(“Field Data: [%s], occurrence = %d, len = %d\n”, buffer, nth, len);
    /* output: Field Data: [cccc], occurrence = 2, len = 4 */
    . . .
  • Related functions

    fbput(), fbchg_tu(), fbget_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetalloc_tu()

2.23. fbget_fldtype

The fbget_fldtype returns the field type of a specified field key as an integer.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbget_fldtype(FLDKEY fldkey)
  • Parameter

    ParameterDescription
    fldkeyField key obtained by using fbget_fldkey() or by referring to a header file(***_fdl.h). The header file is generated by compiling the file(***.f), which is used to create a field table in fdlc.
  • Return value

    Return valueField type
    1character
    2short integer
    3integer
    4long integer
    5float
    6double
    7string
    8character array(carray)
  • Example

    #include “demo_fdl.h”
    . . .
    FLDKEY fkey;
    int type;
    
    fkey = fbget_fldkey(“INPUT”);
    printf(“Field Key : [%d]\n”, fkey);/* output: Field Key : [469762149] */
    type = fbget_fldtype(fkey);
    printf(“Field Type : [%d]\n”, type);/* output : Field Type : [7] */
    . . .
  • Related functions

    fbget_fldname(), fbget_fldno(), fbget_fldkey(), fbget_strfldtype(), fbtypecvt()

2.24. fbgetlast_tu

The fbgetlast_tu function returns the data of the final field occurrence of a field key in a field buffer. fbgetlast_tu also returns the data index and field data length.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbgetlast_tu(FBUF *fbuf, FLDKEY fldkey, int *nth, char *loc, int *len)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to be retrieved from a field buffer.
    nthIndex of a field to be read.
    locPointer to where a field value will be stored.
    lenData length.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEBADFLDInvalid field.
  • Example

    #include “demo_fdl.h”
    . . .
    long ret;
    FLDKEY len;
    int nth;
    char buffer[100];
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, “cccc”, 0);
    
    fbgetlast_tu(fbuf, INPUT, &nth, buffer, &len);
    printf(“Field Data: [%s], occurrence = %d, len = %d\n”, buffer, nth, len);
    /* output: Field Data: [cccc], occurrence = 2, len = 4 */
    . . .
  • Related functions

    fbput(), fbchg_tu(), fbget_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetalloc_tu()

2.25. fbget_strfldtype

The fbget_strfldtype returns the field type of each field as a string. While fbget_fldtype() returns a field type as an integer, fbget_strfldtype returns the field type as a string.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbget_strfldtype(FLDKEY fldkey)
  • Parameter

    ParameterDescription
    fldkeyField key obtained by using fbget_fldkey() or by referring to a header file(***_fdl.h). The header file is generated by compiling the file(***.f), which is used to create a field table in fdlc.
  • Return value

    Return valueDescription
    Blank string (" ")Field type of a specified field key does not exist or the field key is invalid.
    String (field type of the specified field key)Specified field key exists.
  • Example

    #include “demo_fdl.h”
    . . .
    FLDKEY fkey;
    char *stype;
    ……
    fkey = fbget_fldkey(“INPUT”);
    printf(“Field Key : [%d]\n”, fkey);
    /* output : Field Key : [469762149] */
    
    stype = fbget_strfldtype(fkey);
    printf(“Field Type : [%s]\n”, stype);
    /* output : Field type : [string] */
  • Related functions

    fbget_fldname(), fbget_fldno(), fbget_fldtype(), fbtypecvt()

2.26. fbget_tu

The fbget_tu function retrieves the field data that corresponds to a specified field occurrence of a specified field key in a field buffer.

Like fbget_val(), fbget_tu() retrieves the value for a specified field key at a specified position. However, fbgetval() returns the field value as a pointer, while fbget_tu stores the data in a common character buffer. When compared to fbget_tu(), fbget() can read acquired data only once but fbget_tu() can read data many times.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbget_tu(FBUF *fbuf, FLDKEY fldkey, int nth, char *value, FLDLEN *len)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to be retrieved from a field buffer.
    nthIndex of a field to be read.
    valuePointer to field data that has been read. If a field key is an integer or real type, use a variable appropriate for that type and perform type cast using the previously listed prototype.
    lenData length.
  • Return value

    Return valueDescription
    1Specified field key exists in a field buffer.
    -1Specified field key does not exist in a field buffer. fberrno is set to the error code.

  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEBADFLDInvalid field.
  • Example

    #include “demo_fdl.h”
    . . .
    char buffer[100];
    long rcvlen;
    FLDLEN fldlen;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, OUTPUT, “cccc”, 0);
    
    fbget_tu(fbuf, INPUT, 1, buffer, &fldlen);
    printf(“Data: [%s]\n”, buffer) /* output: Data: [bbbb] */
    .....
  • Related functions

    fbput(), fbget(), fbget_tut(), fbgetval(), fbgetval_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetval_last_tu()

2.27. fbget_tut

The fbget_tut function converts the field data that corresponds to a specified field occurrence of a specified field key into a specified type and returns it. fbget_tut reads field data that corresponds to a field occurrence at the nth index of a field key.

Like fbget_tu(), fbget_tut() retrieves the field occurrence data of a specified field key. However, after retrieving the data, fbget_tut() converts the data to a specified type, while fbget_tu() does not.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbget_tut(FBUF *fbuf, FLDKEY fldkey, int nth, char *value, FLDLEN *len, 
                  int type)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to be retrieved from a field buffer.
    nthIndex of a field to be read.
    valuePointer to field data that has been read. If a field key is an integer or real type, use a variable appropriate for that type and perform type cast using the previously listed prototype.
    lenData length.
    type

    Field value type. Input options:

    - FB_CARRAY, FB_SHORT, FB_DOUBLE, FB_LONG, FB_STRING, FB_CHAR, FB_FLOAT, FB_INT

  • Return value

    Return valueDescription
    1Specified field key exists in a field buffer.
    -1Specified field key does not exist in a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEBADFLDInvalid field.
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    FBUF *fbuf;
    int ret, val=65;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbputt(fbuf, INPUT,  (char *)&val, 0, FB_INT);
    fbputt(fbuf, INTDATA, "1111", 0, FB_STRING);
    fbprint(fbuf);
    
    fbget_tut(fbuf, INTDATA, 0, (char *)&ret, &fldlen, FB_INT);
    printf("Field Data: [%d]\n", ret);
    /* output: Field Data: [1111] */
    .....
  • Related functions

    fbput(), fbget(), fbget_tu(), fbgetval(), fbgetval_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetval_last_tu()

2.28. fbget_unused

The fbget_unused function calculates and returns the size (in bytes) of unused fields in a field buffer allocated by fballoc() or tpalloc().

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    long fbget_unused(FBUF *fbuf)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
  • Return value

    Returns the size of unused memory in an allocated field buffer in bytes.

  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    long ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “1111”, 0);
    ret = fbget_unused (fbuf);
    printf(“Unused Buffer Size: [%d]\n”, ret);
    
    /* output: Unused Buffer Size: [1000] */
    . . .
  • Related functions

    fbcalcsize(), fbget_fbsize(), fbget_used()

2.29. fbget_used

The fbget_used function calculates and returns the size (in bytes) of the fields currently used in a field buffer allocated by fballoc() or tpalloc().

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    long fbget_used(FBUF *fbuf)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
  • Return value

    Returns the size of the memory currently used by an allocated field buffer in bytes.

  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    long ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “1111”, 0);
    ret = fbget_used(fbuf);
    printf(“Used Buffer Size: [%d]\n”, ret);
    
    /* output: Used Buffer Size: [24] */
    . . .
  • Related functions

    fbcalcsize(), fbget_fbsize(), fbget_unused()

2.30. fbgetf

The fbgetf function sequentially returns the field data stored in a field buffer allocated by fballoc() or tpalloc().

fbgetf() is similar to the fbget() function, however, fbgetf() uses the location of a following field in order to improve processing time. In Microsoft Visual Basic, fbget() takes 400 seconds to get 20,000 pieces of field data while fbgetf() took only 2.5 seconds.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbgetf(FBUF *fbuf, FLDKEY fldkey, char *loc, int *fldlen, int *pos)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to be retrieved from a field buffer.
    locPointer to field data that has been successively read.
    fldlenData length.
    posPointer to the location of the following field data to be gotten. pos must be specified for each field key that uses fbgetf(), and pos must be initialized to 0 before calling fbgetf().
  • Return value

    Return valueDescription
    1Function call is successful.
    -1

    Function call failed. fberrno is set to the error code.

  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
  • Example

    #include “demo_fdl.h”
    . . .
    int ret, int0_pos, str0_pos, fldlen;
    char str0[30];
    FBUF *fbuf;
    
    if ((fbuf = fballoc(20000, 1000000)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    int0_pos = str0_pos = 0;
    while(1)
    {
        ret = fbgetf(fbuf, STR0, (char *)str0, (int *)&fldlen, &str0_pos);
        if(ret < 0)
        {
            printf(“FBERROR at STR0:%d\n”, fberror);
            break;
         }
         ret = fbgetf(fbuf, INT0, (char *)&int0, (int *)&fldlen, &int0_pos);
         if(ret < 0)
         {
            . . . .
         }
         . . . .
    }
    . . . .
  • Related functions

    fbget(), fbgetval(), fbget_tu(), fbgetvals(), fbgetvali(), fbgetvalt(), fbgetvall_tu()

2.31. fbgetlen

The fbgetlen function returns the length of the data in a field occurrence of a specified field key.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbgetlen(FBUF *fbuf, FLDKEY fldkey, int nth)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to be retrieved from a field buffer.
    nthIndex of a field to be read.
  • Return value

    Return valueDescription
    Field data lengthFunction call is successful.
    -1

    Function call failed. fberrno is set to the error code.

  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    int ret;
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    if(fbgetlen(fbuf, INPUT, 1)  <  0)
    {
          ......
    }
    ......
  • Related functions

    fbget_fbsize(), fbget_used(), fbget_unused(), fbcalcsize()

2.32. fbgetnth

The fbgetnth function returns the sequence of a field that contains specified field data stored in a specified field key. If data has been stored multiple times for a field, only the first number in a sequence will be returned.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbgetnth(FBUF *fbuf, FLDKEY fldkey, char *value, FLDLEN fldlen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of the data to be retrieved from a field buffer.
    valuePointer to field data that has been retrieved. If a field key is an integer or real type, use a variable appropriate for that type and perform type casting by using the prototype mentioned above.
    fldlenData length. If the type of a specified field key is not FB_CARRAY, '0' can be specified.
  • Return value

    Return valueDescription
    Field occurrence of the specified dataField occurrence of a specified field key exists in a field buffer.
    -1Field occurrence of a specified field key does not exist in a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    int occ;
    FBUF *fbuf;
    .....
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, “ddddd”, 0);
    fbput(fbuf, INPUT, “eeeee”, 0);
    fbput(fbuf, OUTPUT, “cccc”, 0);
    occ = fbgetnth(fbuf, INPUT, “eeee”, 0);
    printf(“Occurrence: [%d]\n”, occ); /* output: Occurrence: [3] */
    .....
  • Related functions

    fbfldcount(), fbkeyoccur(), fbgetntht()

2.33. fbgetntht

The fbgetntht function returns a field occurrence for specified data that is stored in a specified field key.

If the data type of fromtype and the field type of fldkey are different, fbgetntht() will convert the data type of value into the field type of fldkey and return the field occurrence that has identical value, fldlen, and field type values. The first field data occurrence that matches value will be returned.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbgetntht(FBUF *fbuf, FLDKEY fldkey, char *value, FLDLEN fldlen, int fromtype)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of a field occurrence to be retrieved from a field buffer.
    valuePointer to field data that has been read. If a field key is an integer or real type, use a variable appropriate for that type and perform type casting by using the prototype mentioned above.
    fldlenData length. If the type of the specified field key is not FB_CARRAY, '0' can be specified.
    fromtype

    Data type. Input options:

    - FB_CARRAY, FB_SHORT, FB_DOUBLE, FB_LONG, FB_STRING, FB_CHAR, FB_FLOAT, FB_INT

  • Return value

    Return valueDescription
    Field sequence of specified dataField occurrence of a specified field key exists in a field buffer.
    -1Field occurrence of a specified field key does not exist in a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
  • Example

    #include “demo_fdl.h”
    . . .
    int occ, val;
    FBUF *fbuf;
    .....
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    val = 1111;
    fbput(fbuf, INPUT,  "aaaa", 0);
    fbput(fbuf, INPUT,  "dddd", 0);
    fbput(fbuf, INPUT,  “1111”, 0);
    fbput(fbuf, OUTPUT, "cccc", 0);
    
    occ=fbgetntht(fbuf, INPUT, (char *)&val, 0, FB_INT);
    printf("Occurrence: [%d]\n", occ); /* Occurrence: [2] */
    . . .
  • Related functions

    fbfldcount(), fbkeyoccur(), fbgetnth()

2.34. fbgetval

The fbgetval function returns field data that corresponds to a specified field occurrence (nth) in a specified field key.

Like fbget_tu(), fbget_val() retrieves the value for a specified field key at a specified position. However, fbgetval() returns the field value as a pointer, while fbget_tu stores the data in a common character buffer. The pointer within a buffer returned by fbgetval can be used to refer to but not modify the buffer. An address returned by fbgetval() is valid unless the buffer is modified. In addition, this value does not have to match a user-specified parameter type. The accuracy of this value is not guaranteed, and a system error can occur if fbgetval() refers to a value by casting long or double type.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbgetval(FBUF *fbuf, FLDKEY fldkey, int nth, FLDLEN *fldlen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of data to be retrieved from a field buffer.
    nthIndex of a field to be read.
    fldlenLength of data
  • Return value

    Return valueDescription
    Pointer to the dataField occurrence of the specified field key exists in a field buffer.
    NULLField occurrence of the specified field key does not exist in a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    
    char *ptr;
    long rcvlen;
    FLDLEN fldlen;
    FBUF *fbuf;
    
    fbuf = fballoc(10, 100);
    .......
    
    fbput(fbuf, INPUT, "aaaa", 0);
    fbput(fbuf, INPUT, "bbbb", 0);
    
    ptr=fbgetval(fbuf, INPUT, 0, &fldlen);
    printf("Data: [%s]\n", ptr);    /* output: Data: [aaaa] */
    printf("len = %d\n", fldlen);   /* len = 4 */
    .....
  • Related functions

    fbput(), fbget(), fbgetval(), fbgetvalt(), fbgetval_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetval_last_tu()

2.35. fbgetvali

The fbgetvali function converts the field data that corresponds to the specified field occurrence into an integer and then returns the value. The field data can only be converted into an integer. If the data cannot be converted into an integer (e.g. "aaaa"), 0 is returned.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbgetvali (FBUF *fbuf, FLDKEY fldkey, int nth)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of data to be retrieved from a field buffer.
    nthIndex of a field to be read.
  • Return value

    Return valueDescription
    IntegerFunction call is successful. Data was successfully converted and an integer was returned.
    0Field occurrence of a specified field key does not exist in a field buffer, or an error occurred. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
  • Example

    #include “demo_fdl.h ”
    . . .
    
    int cnt;
    int vali;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    cnt=111;
    fbput(fbuf, TOTMON, (char *)&cnt, 0);
    fbput(fbuf, INPUT, "aaaa", 0);
    vali=fbgetvali(fbuf, TOTMON, 0);
    printf("Field Data: [%d]\n", vali);  /* output: Field Data: [111] */
     
    vali = fbgetvali(fbuf, INPUT, 0);
    printf("Field Data : [%d]\n", vali);  /* output: Field Data: [0] */
     
    fbfree(fbuf);
    .....
  • Related functions

    fbput(), fbget(), fbgetval(), fbgetvalt(), fbgetval_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetval_last_tu()

2.36. fbgetval_last_tu

The fbgetval_last_tu function returns the data of the last field occurrence of a field key specified by fldkey. It also returns the field occurrence value and the length of returned data.

fbgetval_last_tu is similar to the fbgetlast_tu() function. However, the data read by fbgetlast_tu() is returned as a parameter, while the data read by fbgetval_last_tu() is returned as return value. To use data, fbgetlast_tu() must move data to a local buffer in the program, while fbgetval_last_tu() can use data as a parameter of another function.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbgetval_last_tu(FBUF *fbuf, FLDKEY fldkey, int *nth, FLDLEN *fldlen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of the data to be retrieved from a field buffer.
    nthPointer to the last index with data.
    fldlenData length.
  • Return value

    Return valueDescription
    Pointer to the dataSpecified field key exists in a field buffer. (A char type pointer that contains the read data is returned.)
    NULLSpecified field key does not exist in a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    
    char     *ptr;
    long     rcvlen;
    int      i,occ ;
    FLDLEN   fldlen;
    FBUF     *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, “ddddd”, 0);
    fbput(fbuf, INPUT, “eeeee”, 0);
    fbput(fbuf, OUTPUT, “cccc”, 0);
    
    ptr = fbgetval_last_tu(fbuf, INPUT, &occ, &fldlen);
    printf(“Data: [%s], Occurrence: [%d]\n”, ptr, occ);
    /* output: Data: [eeeee], Occurrence: [3] */
    for (i = 0; i < occ; i++) {
        ptr = fbgetval(fbuf, INPUT, i, &fldlen);
        printf(“Data: [%s]\n”, ptr);
    }
    .....
  • Related functions

    fbput(), fbget(), fbgetval(), fbgetvalt(), fbgetval_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetval_last_tu(), fbgetlast_tu()

2.37. fbgetvall_tu

The fbgetvall_tu() function converts the field data that corresponds to a specified field occurrence (nth) in a specified field key to long type and then returns it. The field type of field data must be short, int, or long to be converted into long type. If the data type is not short, int, or long, fbgetvall_tu() returns 0.

fbgetvall_tu() is similar to fbgetval(), however, fbgetval() returns field data without converting the field type, while fbgetvall_tu() converts the data into long type.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    long fbgetvall_tu(FBUF *fbuf, FLDKEY fldkey, int nth)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of the data to be retrieved from a field buffer.
    nthIndex of a field to be read.
  • Return value

    Return valueDescription
    Field dataFunction call is successful. Field data is converted into long type and returned.
    0Specified field key does not exist in a field buffer or the field type is not short, int, or long. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBETYPEInvalid type not supported by Tmax. The field is not a short, int, or long type.
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    long lval;
    short sval;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    sval = 111;
    fbput(fbuf, INPUT, (char *)&sval, 0);
    lval = fbgetvall_tu(fbuf, INPUT, 0);
    
    printf(“Field Data: [%ld]\n”, lval); /* output: Field Data: [111] */
    .....
  • Related functions

    fbput(), fbget(), fbgetval(), fbgetvalt(), fbgetval_tu(), fbgetvals_tu(), fbgetval_last_tu()

2.38. fbgetvals

The fbgetvals function converts the field data of a specified field occurrence into a string and then returns the value. If field data that corresponds to a specified field occurrence does not exist, NULL will be returned.

fbgetvals() is similar to fbgetval(), however, fbgetval() returns field data without converting its field type, while fbgetvals() converts the data into a string.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbgetvals (FBUF *fbuf, FLDKEY fldkey, int nth)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of data to be retrieved from a field buffer.
    nthIndex of a field to be read.
  • Return value

    Return valueDescription
    Field dataFunction call is successful. The data was successfully converted and a string was returned.
    NULLField occurrence of a specified field key does not exist in a field buffer, or an error occurred. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
  • Example

    #include “demo_fdl.h”
    . . .
    char *ptr;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    ptr = fbgetvals(fbuf, INPUT, 0);
    printf(“Field Data: [%s]\n”, ptr);
    /* output: Field Data: [aaaa] */
    ......
  • Related functions

    fbput(), fbget(), fbgetval(), fbgetvalt(), fbgetval_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetval_last_tu()

2.39. fbgetvals_tu

The fbgetvals_tu function returns the field data of a specified field occurrence (nth) in a specified field key.

fbgetvals_tu() is similar to fbgetval(). fbgetval() returns field data without converting a field type, while fbgetvals_tu() returns field data only if it is a string type.

If field data that corresponds to a specified field occurrence does not exist, a blank string(" ") will be returned while fbgetvals() will return NULL. While fbgetvals() can be used on all field data types, fbgetvals_tu() can be used if the type of field data is a string. If the field data type is not a string, fbgetvals_tu() will return a blank string (" ").

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbgetvals_tu(FBUF *fbuf, FLDKEY fldkey, int nth)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of the data to be retrieved from a field buffer.
    nthIndex of a field to be read.
  • Return value

    Return valueDescription
    Field dataFunction call is successful.
    Blank string(" ")Field occurrence of a specified field key does not exist in a field buffer, or an error occurred. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    char *ptr;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    ptr = fbgetvals_tu(fbuf, INPUT, 1);
    printf(“Field Data: [%s]\n”, ptr); /* output: Field Data: [bbbb] */
    .....
  • Related functions

    fbget(), fbgetval(), fbgetvalt(), fbgetvals(), fbgetval_tu(), fbgetvall_tu(), fbgetval_last_tu()

2.40. fbgetvalt

The fbgetvalt function converts the field data that corresponds to a specified field occurrence of a specified field key into a specified type (totype) and returns it.

fbgetvalt() is similar to the fbget_tut() function. However, while the data read by fbget_tut() is returned by its own parameter, the data read by fbgetvalt() is returned by its own return value. Therefore, fbget_tut() must move data to a local buffer within the program but fbgetvalt() can immediately use the parameter of other functions.

fbgetvalt() is also similar to fbgetval(). However, while fbgetval() directly reads field data, fbgetvalt() can convert field data to a specified type and read it. Unlike fbgetval(), fbgetvalt() follows a user-defined-type parameter so it performs type casting for long or double types to return a value.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbgetvalt(FBUF *fbuf, FLDKEY fldkey, int nth, FLDLEN *len, int totype)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of the data to be retrieved from a field buffer.
    nthIndex of a field to be read.
    lenData length.
    totype

    Field value type. Input options: FB_CARRAY, FB_SHORT , FB_DOUBLE , FB_LONG , FB_STRING, FB_CHAR, FB_FLOAT , FB_INT

  • Return value

    Return valueDescription
    Data pointerFunction call is successful. (The char type pointer where the read data is stored will be returned.)
    NULLData for a specified field key does not exist in a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
  • Example

    #include “demo_fdl.h”
    . . .
    
    int *ptr;
    long rcvlen;
    FLDLEN fldlen;
    FBUF *fbuf;
    Int totype;
    Int val = 111;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, (char *)&val, 0, FB_INT);
    
    ptr = fbgetvalt(fbuf, INPUT, 2, &fldlen, FB_INT);
    printf(“Data: [%d]\n”, ptr); /* output: Data: [111] */
    .....
  • Related functions

    fbput(), fbget(), fbgetval(), fbgetval_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetval_last_tu()

2.41. fbinit

The fbinit function initializes a field buffer allocated by tpalloc() or fballoc(). To use fbinit(), memory must first be allocated for a field buffer. When fbinit is called, existing data in the field buffer will be deleted.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbinit(FBUF *fbuf, FLDLEN buflen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    buflenSize of a field buffer to be allocated to memory and initialized
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed to initialize a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    FBUF *fbuf;
    int ret;
    long size;
    size = fbcalcsize(10, 100);
    
    if ((fbuf = (FBUF *)tpalloc(“FIELD”, NULL, size)) == NULL) {
        printf(“tpalloc failed, errno = %d\n”, tperrno);
        ........
    }
    ret = fbinit(fbuf, size);
    printf(“fbinit, ret : [%d]\n”, ret); /* fbinit, ret: [1] */
    ........
  • Related functions

    fbcalcsize(), tpalloc(), fballoc()

2.42. fbinsert

The fbinsert function stores specified data to a specified field occurrence in a specified field key of a field buffer allocated by fballoc() or tpalloc(). fbinsert stores data pointed to by the value in the nth field occurrence of fldkey in fbuf.

A field key and field sequential numbers must be specified in this parameter. As a result, the fbinsert function can be useful for storing data in a specific location in a field buffer. When field data is sequentially stored, a user must manually increase the nth parameter. When multiple field data is stored in a field key, field data is inserted in the field sequential number. Data can then be stored in a specified field sequential number.

Generally, fbinsert saves data to pass it to other processes in a field buffer. When saving data to a field key, increment a field occurrence to store a field value to a specified position. If a field key has multiple field occurrences, the value of the last occurrence will be valid, and the occurrence of the next field key will be incremented by one.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbinsert(FBUF *fbuf, FLDKEY fldkey, int nth, char *value, int fldlen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of the data to be stored in a field buffer
    nthIndex of a field to be stored.
    valuePointer to field data that will be saved. If a field key is an integer or real type, use a variable appropriate for that type and perform type cast using a previously listed prototype.
    fldlenData length. If the type of a specified field key is not FB_CARRAY, '0' can be specified.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed to save data in a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error. nth is larger than the current field occurrence value and a field key is a carray type.
    FBETYPEInvalid type. Type is not supported in Tmax.
  • Example

    #include “demo_fdl.h”
    . . .
    long rcvlen, ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbinsert(fbuf, INPUT, 0, “aaaa”, 0);
    fbinsert (fbuf, INPUT, 1, “bbbb”, 0);
    fbinsert (fbuf, INPUT, 2, “cccc”, 0);
    .....
  • Related functions

    fbput(), fbchg_tu(), fbget_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu()

2.43. fbisfbuf

The fbisfbuf function is required for allocating memory for a field buffer before saving field data. fbisfbuf() checks the validity of a specified field buffer.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbisfbuf(FBUF *fbuf)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer to be checked.
  • Return value

    Return valueDescription
    1Specified field buffer is valid.
    0Specified field buffer is invalid. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    FBUF *fbuf;
    int ret;
    
    if ((fbuf = (FBUF *)tpalloc(“FIELD”, NULL, 0)) == NULL) {
        printf(“tpalloc failed, errno = %d\n”, tperrno);
        ........
    }
    ret = fbisfbuf(fbuf);
    printf(“ret : [%d]\n”, ret); /* output : ret : [1] */
    . . .
  • Related functions

    fballoc(), tpalloc()

2.44. fbispres

The fbispres function checks whether field data in a specified field occurrence (nth) exists.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbispres(FBUF *fbuf, FLDKEY fldkey, int nth)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key to check if field data exists in a field buffer.
    nthIndex of a field to be checked.
  • Return value

    Return valueDescription
    1Specified field occurrence contains data.
    0Specified field occurrence does not contain data. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    int ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ......
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    ret = fbispres(fbuf, INPUT, 1);
    printf(“Field Occ: [%d]\n”, ret); /* output: Field Occ: [1] */
    . . .
  • Related functions

    fbgetnth(), fbfldcount(), fbkeyoccur()

2.45. fbkeyoccur

The fbkeyoccur function returns the number of fields of a specified field key. Unlike fbfldcount(), fbkeyoccur() returns the total number of fields, while fbfldcount() returns the number of all currently available fields starting from 1.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbkeyoccur(FBUF *fbuf, FLDKEY fldkey)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key that contains fields to be counted
  • Return value

    Return valueDescription
    The number of fieldsData of a specified field key exists in a field buffer.
    0Data of a specified field key does not exist in a field buffer. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    int cnt;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, OUTPUT, “cccc”, 0);
    cnt = fbkeyoccur(fbuf, INPUT);
    printf(“Field Count: [%d]\n”, cnt);
    /* output: Field Count: [2] */
    .....
  • Related functions

    fbgetnth(), fbfldcount()

2.46. fbmake_fldkey

The fbmake_fldkey function is not defined in a field definition file(***.f). However, it can be used to dynamically create a new field key in the program.

To create a field key, a field type and a unique field number are required. The two can be specified as parameters, and a field key will be generated and returned after executing this function. To create the same field key as an existing field key, specify the already existing number in a field number. To save data in a generated field key and pass the data to another process, the same field key as a generated field key (their type and number should be identical) should be created in the process, too.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    FLDKEY fbmake_fldkey(int type, int no)
  • Parameter

    ParameterDescription
    typeField key type to be created
    no

    Field numbers needed to create a field key:

    - FB_CARRAY, FB_SHORT, FB_DOUBLE, FB_LONG, FB_STRING, FB_CHAR, FB_INT, FB_FLOAT

  • Return value

    Creates a field key by associating a field type and a field number, and then returns a field key.

  • Example

    #include “demo_fdl.h”
    . . .
    FLDKEY fkey;
    
    fkey = fbmake_fldkey(FB_STRING, 101);
    printf(“Field Key : [%d]\n”, fkey);
    /* output : Field Key : [469762149] */
    . . .
  • Related functions

    fbget_fldkey()

2.47. fbnext_tu

The fbnext_tu function returns the next field key and field data in a field buffer. This function returns all the field keys and field data of a field buffer in sequence from a starting field key that is specified in fldkey. To read the first field key first, the starting field key to be specified should be FIRSTFLDKEY.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbnext_tu(FBUF *fbuf, FLDKEY *fldkey, int *nth, char *value, int *len)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyPointer to the field key of the next field
    nthSequential number of the next field.
    valuePointer to field data of the next field. If value is not NULL, field data of the next field will be copied to value. If value is NULL as there is no next field, the value will not change, and only fldkey and nth will be changed.
    lenPointer to the length of field data. It checks if there is enough space to store field data in a buffer. If there is enough space, the length of the value where the data of the next field is saved will be stored.
  • Return value

    Return valueDescription
    1Function call is successful. (A value of fldkey, nth, value, len, and etc. is returned as a pointer.)
    0Function call failed.
    -1Error occurred when the function call was being executed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h”
    . . .
    char data[100];
    long rcvlen;
    int i, occ, nth, fc, len;
    
    FLDKEY fkey;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbput(fbuf, INPUT, “dddd”, 0);
    fbput(fbuf, INPUT, “eeee”, 0);
    fbput(fbuf, INPUT, “cccc”, 0);
    
    len = 4;
    for(fkey = FIRSTFLDKEY;fc = fbnext_tu(fbuf, &fkey , &occ, data, &len) > 0;
    
    len = sizeof(data))
    printf(“fkey = %ld Data: [%s], Occurrence: [%d] len [%d]\n”, fkey, data, occ, 
    len);
    
    /* output: fkey = 469762149 Data: [aaaa], Occurrence: [0] len [4]
      output: fkey = 469762149 Data: [bbbb], Occurrence: [0] len [4]
      output: fkey = 469762149 Data: [dddd], Occurrence: [0] len [4]
      output: fkey = 469762149 Data: [eeee], Occurrence: [0] len [4]
      output: fkey = 469762149 Data: [cccc], Occurrence: [0] len [4] */
    . . .
  • Related functions

    fbput(), fbget(), fbgetval(), fbgetvalt(), fbgetval_tu(), fbgetvals_tu(), fbgetvall_tu(), fbgetval_last_tu(), fbgetlast_tu()

2.48. fbprint

The fbprint function prints out the data in a field buffer in a standard output. It is also used to display the data on the screen.

The output format is as follows.

fkey = 469762149, fname = INPUT, type = string, value = 5555 fkey = 469762149, 
fname = INPUT, type = string, value = 7777 fkey = 469762149, fname = INPUT, 
type = string, value = 3333 fkey = 469762149, fname = INPUT, type = string, 
value = 8888
  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbprint(FBUF *fbuf)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Error occurred when the function was being executed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBEINVALInput parameter error.
    FBEBADFBA field buffer is invalid. Therefore, it is required to use another buffer which is properly allocated to memory.
  • Example

    #include “demo_fdl.h”
    . . .
    FBUF *fbuf;
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “5555”, 0);
    fbput(fbuf, INPUT, “7777”, 0);
    fbput(fbuf, INPUT, “3333”, 0);
    fbput(fbuf, INPUT, “8888”, 0);
    fbprint(fbuf);
    ......
  • Related functions

    fbfprintf()

2.49. fbput

The fbput function adds a new field in a field buffer allocated by fballoc() or tpalloc().

When adding a field to the field key specified by a parameter of the function, if a field does not exist in the field key, a field of the first field sequential number will be created. If one or more fields already exist, a field with an automatically increased sequential number will be created and its value will be saved in the field as field data. Note that the field sequence automatically increases and thus a user does not need to consider sequential numbers to save data.

If a data type of value is char *, but the field type of a field key is not a string, declare a variable appropriate for the field type to save data, and perform type casting to call the function. Even though the prototype is defined as follows, data such as FB_INT, FB_LONG, and FB_FLOAT can be saved by adding a field to a field key.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbput(FBUF *fbuf, FLDKEY fldkey, char *value, FLDLEN len)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of a field to be created
    valueData to be stored in a created field
    lenData length. If the type of the specified field key is not FB_CARRAY, '0' can be specified.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
  • Example

    #include “demo_fdl.h”
    . . .
    long rcvlen, ret;
    FBUF *fbuf;
    int ival = 1000;
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INTDATA, (char *)&ival, 0);
  • Related functions

    fbinsert(), fbchg_tu(), fbget_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu()

2.50. fbputt

The fbputt function adds a new field to a field buffer allocated by fballoc() or tpalloc(). Before adding a field to a field buffer, the user-defined data type of a value is converted into a field key that will be used to save the field.

fbputt() is similar to fbput(). While fbput() saves data into a created field without conversion, fbputt() can convert the data type into the field key type if the data type is different from the field type.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbputt(FBUF *fbuf, FLDKEY fldkey, char *value, FLDLEN len, int type)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of a field to be created
    valueData to be saved in a created field
    lenData length. If the type of the specified field key is not FB_CARRAY, '0' can be specified.
    type

    Type of field value. It is converted into field key type before the data is saved in the field. Options are:

    - FB_CARRAY, FB_SHORT, FB_DOUBLE, FB_LONG, FB_STRING, FB_CHAR, FB_INT, FB_FLOAT

  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
  • Example

    #include “demo_fdl.h”
    . . .
    long rcvlen, ret;
    FBUF *fbuf;
    int ival;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    ival = 1111;
    fbputt(fbuf, INPUT, “aaaa”, 0, FB_STRING);
    /* Specify the FB_INT type to insert ival(1111),which is int type, into the INPUT field key (string type). */
    fbputt(fbuf, INPUT, (char *)&ival, 0, FB_INT);
    ….
    fbprint(fbuf);
    fbfree(fbuf);
    ……
    /* output :    fkey = 469762149, fname = NAME, type = string, value = aaaa
                   fkey = 469762149, fname = NAME, type = string, value = 1111  */
    .....
  • Related functions

    fbinsert(), fbchg_tu(), fbget_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu()

2.51. fbrealloc

The fbrealloc function re-allocates a field buffer by increasing memory capacity when the size of the buffer is not enough.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    FBUF *fbrealloc(FBUF *fbuf, int ncount, int nlen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    ncountNumber of fields to store in memory.
    nlenTotal size of fields in bytes.
  • Return value

    Return valueDescription
    Pointer to memoryFunction call is successful.
    NULLFunction call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBEOSOperating system or system error (memory allocation failure, Tmax connection failure (e.g. service call, send, recv, etc))
    FBEINVALInput parameter error.
  • Example

    #include “demo_fdl.h“
    . . .
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n“, fberror);
        ........
    }
    printf(“Buffer Size: [%ld]\n“, fbget_fbsize(fbuf));
    /* output: Buffer Size: [1024] */
    if ((fbuf = (FBUF *)fbrealloc(fbuf, 1000, 150)) == NULL) {
        printf(“fbrealloc failed, errno = %d\n“, fberror);
        ........
    }
    
    printf(“Buffer Size: [%ld]\n”fbget_fbsize(fbuf));
    /* output: Buffer Size: [4158] */
  • Related functions

    fballoc(), tpalloc(), fbget_fbsize(), fbget_used(), fbget_unused()

2.52. fbread

The fbread function reads data from a specified file stream and loads it in a field buffer. The function reads data from a file stream specified in iop, and loads it in a field buffer allocated by fballoc() or tpalloc().

The file stream used in fbread() should specify a file created by calling fbwrite(). The file is used to load data from another process into a field buffer of the current process.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbread(FBUF *fbuf, FILE *iop)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    iopFile stream from which to read data.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1

    Function call failed. fberrno is set to the error code.

  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBEINVALInput parameter error.
    FBEOSOperating system or system error (memory allocation failure, Tmax connection failure (e.g. service call, send, recv, etc))
  • Example

    #include “demo_fdl.h”
    . . .
    int ret;
    FILE *iop;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    iop = fopen(“sample.dat”, “r”);
    ret = fbread(fbuf, iop);
    
    if (ret == 1)
       fbprint(fbuf);
    fclose(iop)
    ......
  • Related functions

    fbwrite()

2.53. fbsnull

The fbsnull function checks whether or not the member variable in a structure mapped to a field sequential number of a specified field key is NULL.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbsnull(char *cstruct, char *cname, int nth, char *stname)
  • Parameter

    ParameterDescription
    cstructPerforms type casting to change the struct type variable into a (char *) type.
    cnameName of a member variable.
    nthSequential number of a field.
    stnameString that contains the name of structure defined in VIEW.
  • Return value

    Return valueDescription
    1Field data of a specified field sequential number is NULL.
    0Field data of a specified field sequential number is not NULL.
    -1Error occurred while executing the function. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEBADSTRUCTInvalid structure. This error generally occurs when a structure type is not recognized by Tmax or the structure definition file is incorrectly compiled.
  • Example

    #include “demo_fdl.h”
    #include “demo_sdl.h”
    . . .
    int val = 1000, ret;
    struct demo temp;
    char *cstruct;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    if(tpstart((TPSTART_T *)NULL) == NULL){
        printf(tpstart error\n”);
        ........
    }
    cstruct = (char *)&temp;
    if(fbstinit(cstruct, “demo”) < 0){
         ........
    }
    fbput(fbuf, INPUT, “aaaa”, 0);
    if(fbftos(fbuf, cstruct, “demo”) < 0){
         ........
    }
    ret = fbsnull(cstruct, “demodata”, 0, “demo”);
    if(ret < 0) {
         printf(“fbsnull failed\n”);
         ........
    }
    else if(ret == 0)
         printf(“This occurrence is not null\n”);
    else
         printf(“This occurrence is null\n”);
    ........
  • Related functions

    fbgetlen(), fbstinit(), fbstelinit(), fbinit()

2.54. fbstelinit

The fbstelinit function initializes the member variables of a structure to NULL. If the data type of a member variable is an integer, it will be initialized to 0, and if the type is a string, it will be initialized to NULL.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbstelinit(char *cstruct, char *cname, char *stname)
  • Parameter

    ParameterDescription
    cstructPerform type casting for a struct type variable to a (char *) type.
    cnameString that indicates the member variable in the struct, or perform type casting to a (char *) type.
    stnameString that contains the name of structure defined in VIEW.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to the following value:

    Error codeDescription
    FBEBADSTRUCT

    Invalid structure. This error generally occurs when a structure type is not recognized by Tmax or the structure definition file is incorrectly compiled.

  • Example

    #include “demo_fdl.h”
    #include “demo_sdl.h”
    . . .
    cstruct demo temp;
    char *cstruct;
    if(tpstart((TPSTART_T *)NULL) == NULL) {
         printf(“tpstart failed\n”);
         ......
    }
    cstruct = (char *)&temp;
    if(fbstelinit(cstruct, “demodata”, “demo”) < 0) {
         ......
    }
    ......
  • Related functions

    fbstinit(), fbinit(), fbsnull()

2.55. fbstinit

The fbstinit function initializes a specified struct variable. While fbstelinit() properly initializes each member variable in ta specified struct, fbstinit() initializes the whole struct at once. It is recommended to use fbstelinit() to initialize a member variable, and fbstinit() to initialize a structure.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbstinit(char *cstruct, char *stname)
  • Parameter

    ParameterDescription
    cstructPerforms type casting to change a struct type variable into a (char *) type.
    stnameString that contains the name of a structure defined in VIEW.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBEBADSTRUCTInvalid structure. This error generally occurs when a structure type is not recognized by Tmax or the structure definition file is incorrectly compiled.
  • Example

    #include “demo_fdl.h”
    #include “demo_sdl.h”
    . . .
    cstruct demo temp;
    char *cstruct;
    if(tpstart((TPSTART_T *)NULL) == NULL) {
         printf(“tpstart failed\n”);
         ......
    }
    cstruct = (char *)&temp;
    if(fbstinit(cstruct, “demo”) < 0) {
         ......
    }
    ......
  • Related functions

    fbstelinit(), fbinit(), fbsnull()

2.56. fbstof

Unlike fbftos(), the fbstof function sends data stored in a C struct buffer(stname) to a matching field buffer. The struct file(VIEW definition file) which is slightly different from general struct files(***.s) should be defined first. The field key within a structure file should be mapped one to one onto a member variable of a structure to be specified. For information about VIEW definition file, refer to fbftos().

In these cases given below, the value in a C structure is not copied into a field buffer with fbstof() which is different from fbftos():

  • When the value in a C structure has the same value as a value specified in the NULL item of a VIEW file.

  • When the value in a C structure field to be copied into a field buffer has the same value as a default value.

This, therefore, means that when copying a value in a C structure using fbftos() without any value stored in a field buffer, the value specified in the NULL item of the VIEW file will be copied. When trying to copy the value in a field buffer using fbftof() without any value stored in a C structure or after saving it with the same value that is specified in a NULL item, it won't be copied in a field buffer at all.

When trying to copy a value in a C structure using fbftos() without defining a value in the NULL item of a VIEW file and saving the value in a field buffer, a default value will be copied. When trying to copy a value into a field buffer using fbstof() without saving the value in a C structure, or when copying a value after storing the same value as the default value, no value can be copied.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbstof(FBUF *fbuf, char *cstruct, int mode, char *stname)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    cstructPerforms type casting to change a struct type variable into a (char *) type.
    mode

    Transmits data to a field buffer. The fbstof() function has functional differences depending on its mode. The modes below work completely the same as the each mode of fbbufop(), so refer to fbbufop() if more information is required.

    The following values can be specified for a mode.

    • FBUPDATE : If the FBUPDATE mode is specified, and a member variable of a structure is specified to NULL, the data will be ignored, and will not be transmitted to a field buffer.

    • FBJOIN

    • FBOJOIN

    • FBCONCAT

    stnameString that contains the name of structure defined in VIEW.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEINVALInput parameter error.
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
    FBEBADSTRUCTInvalid structure. This error generally occurs when a structure type is not recognized by Tmax or a structure definition file is incorrectly compiled.
    FBEMALLOCSystem error. Failed to allocate memory for a field buffer.
  • Example

    #include “demo_fdl.h”
    #include “demo_sdl.h”
    . . .
    int ret, fdllen, val = 1000;
    struct demo temp;
    FBUF *fbuf;
    Char *cstruct;
    
    if(tpstart((TPSTART_T *)NULL) == -1) {
        printf(“tpstart failed\n”);
        ........
    }
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    cstruct = (char *)&temp;
    if(fbstinit((char *)&temp, “demo”) < 1)  {
        printf(“fbstinit failed, errno = %d\n”, fberror);
        ........
    }
    
    strcpy(temp.demodata, “aaaa”);
    temp.num = 1000;
    if(fbstof(fbuf, cstruct, FBUPDATE, “demo”) < 0) {
    ........
    }
    ........
  • Related functions

    fbftof(), fbbufop(), fbstinit(), fbstelinit(), fbsnull()

2.57. fbstrerror

In the event of a field buffer operation, the fbstrerror function returns error details to a string.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbstrerror(int fberror)
  • Parameter

    ParameterDescription
    fberrorIf an error occurs when performing an API function related to a field buffer, an error code will be set to the variable fberror. Details of the error can be displayed as a string by specifying the value of fberror as an input parameter of the function. All kinds of errors that can occur here are defined in <fbuf.h>, which is a header file related to FDL.
  • Return value

    Return valueDescription
    StringFunction call is successful. (Details about the error code are returned as a string.)
    NULLFunction call failed.
  • Example

    #include “demo_fdl.h”
    . . .
    int ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    ret = fbget(fbuf, INPUT, “aaaa”, 0);
    if( ret < 0 )
        printf(“ret = %d , fberror = %s[%d]\n”, ret, fbstrerror(fberror) , fberror);
    /* output : ret = -1, fberror = not found[6] */
    . . .
  • Related functions

    fberror()

2.58. fbtypecvt

The fbtypecvt function converts the field data type specified in fromval from fromtype to totype, and then returns the data.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    char *fbtypecvt(FLDLEN *tolen, int totype, char *fromval, int fromtype, 
                    FLDLEN fromlen)
  • Parameter

    ParameterDescription
    tolenPointer to the length of converted data
    totype

    Data can be converted into one of the following types:

    - FB_CARRAY,FB_SHORT, FB_DOUBLE, FB_LONG, FB_STRING, FB_CHAR, FB_INT, FB_FLOAT

    fromvalPointer to data to be converted.
    fromtypeData type of fromval.
    fromlenDefault size of a type specified in fromtype.
  • Return value

    Return valueDescription
    Pointer to the converted dataFunction call is successful.
    NULLFunction call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error. (If it is FB_CARRAY type, the length of the data should be specified to prevent this error.)
    FBETYPEInvalid type. Type is not supported in Tmax.
    FBEBADFLDInvalid field. This error generally occurs when a field key that was not compiled with the fdlc utility is used.
  • Example

    #include “demo_fdl.h”
    . . .
    int tolen, totype, fromtype, fromlen;
    long vall;
    FBUF *fbuf;
    char *ptr;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
          printf(“fballoc failed, errno = %d\n”, fberror);
          ........
    }
    
    vall = 1111;
    fromlen = sizeof(long);
    
    fbput(fbuf, TOTMON,(char *)&vall, 0);
    ptr = fbtypecvt(&tolen, FB_STRING, (char *)&vall, FB_LONG, fromlen);
    
    printf(“Converted string = %s\n”, ptr);
    /* output Converted string = 1111 */
    ......
  • Related functions

    fbget_fldname(), fbget_fldno(), fbget_fldtype(), fbget_strfldtype()

2.59. fbupdate

The fbupdate function updates the field value for a field key in a field buffer allocated by the fballoc() or tpalloc() function at a specified position. Generally the function is used to replace the data that was passed from the other processes in a field buffer.

When saving data using the same field key, it is necessary to specify the field key and the field occurrence to update the field value at a specified position. If one field key has several field sequences, the field value of the last defined occurrence will be valid because its data will have been replaced.

The fbupdate() functions works the same as fbchg_tu(). While fbchg_tu() automatically adds a new field and saves data if there is no field occurrences for a specified field key, fbupdate() will experience an error, and FBENOENT will be set to fberror.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbupdate(FBUF *fbuf, FLDKEY fldkey, int nth, char *value, int fldlen)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    fldkeyField key of a field to be updated.
    nthIndex of a field to be changed. If a field key is an integer type or a real type, perform type casting into char * type, as the parameter will be char * type.
    valuePointer to field data that has been read. If a field key is an integer or real type, use a variable appropriate for that type and perform type casting by using the prototype mentioned above.
    fldlenIn general, the length of a field does not have to be specified. If the field key is FB_CARRAY type, it is necessary to specify the field data length in bytes.
  • Return value

    Return valueDescription
    1Function call is successful.
    -1

    Function call failed. fberrno is set to the error code.

  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBENOENTSpecified field key is not available in a field buffer because it is not defined in FDLFILE (Environment variable: default value is tmax.fdl).
    FBENOSPACEInsufficient space to store or copy data to a field buffer.
    FBEINVALInput parameter error.
    FBETYPEInvalid type. Type is not supported in Tmax.
  • Example

    #include “demo_fdl.h”
    . . .
    long rcvlen, ret;
    FBUF *fbuf;
    char buf[20];
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    fbinsert(fbuf, INPUT, 0, “aaaa”, 0);
    ret = fbupdate(fbuf, INPUT, 0, “bbbbb”, 0);
    fbget (fbuf, INPUT, buf, 0);
    printf(“ret = [%d] INPUT = %s \n”, ret, buf);
    /* output: “ret = 1 INPUT = bbbbbb” */
    .....
  • Related functions

    fbinsert(), fbput(), fbchg_tu(), fbegt(), fbget_tu(), fbgetval(), fbgetval_last_tu(), fbgetvals_tu(), fbgetvall_tu()

2.60. fbwrite

The fbwrite function stores contents of a field buffer allocated by fballoc() or tpalloc() into the file stream specified in iop.

The data to be stored in a file stream includes binary data. This function is used for passing the data in a field buffer to another process through a file stream. The data stored by the fbwrite() function can also be loaded by the fbread() function.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int fbwrite(FBUF *fbuf, FILE *iop)
  • Parameter

    ParameterDescription
    fbufPointer to a field buffer allocated by fballoc() or tpalloc().
    iopPointer to a file stream to store data
  • Return value

    Return valueDescription
    1Function call is successful.
    -1Function call failed. fberrno is set to the error code.
  • Error

    fberrno is set to one of the following values:

    Error codeDescription
    FBEINVALInput parameter error.
    FBEOSOperating system or system error (memory allocation failure, Tmax connection failure (e.g. service call, send, recv, etc))
  • Example

    #include “demo_fdl.h”
    . . .
    int ret;
    FILE *iop;
    FBUF *fbuf;
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    iop = fopen(“sample.dat”, “w”);
    fbput(fbuf, INPUT, “aaaa”, 0);
    fbput(fbuf, INPUT, “bbbb”, 0);
    fbwrite(fbuf, iop);
    fclose(iop)
    ......
  • Related functions

    fbread()

2.61. getfberrno

The getberrono function returns an error code when an error occurrs while performing an API function related to a field buffer. To see the error message of the returned error code, use fbstrerror() with this function as an input parameter. getfberrno() has no input parameter.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int getfberrno(void)
  • Return value

    Returns the value that is currently specified in fberror.

  • Example

    #include “demo_fdl.h”
    . . .
    int ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    
    ret = fbget(fbuf, INPUT, “aaaa”, 0);
    if( ret < 0 )
        printf(“ret = %d , error = %s[%d]\n”, ret, fbstrerror(getfberrno()) , 
                 getfberrno());
    
    /* output : ret = -1, error = not found[6] */
    . . .
  • Related functions

    fbstrerror(), getfberror()

2.62. getfberror

The getfgerror function returns an error code when an error occurrs while performing an API function related to a field buffer.

To see the error message of the returned error code, use fbstrerror() with this function as an input parameter. getfberrno() has no input parameter.

  • Prototype

    #include <fbuf.h>
    #include <atmi.h>
    int getfberror(void)
  • Return value

    Returns the value that is currently specified in fberror.

  • Example

    #include “demo_fdl.h”
    . . .
    int ret;
    FBUF *fbuf;
    
    if ((fbuf = fballoc(10, 100)) == NULL) {
        printf(“fballoc failed, errno = %d\n”, fberror);
        ........
    }
    ret = fbget(fbuf, INPUT, “aaaa”, 0);
    if( ret < 0 )
        printf(“ret = %d , error = %s[%d]\n”, ret, fbstrerror(getfberror()) , 
                getfberror());
    /* output : ret = -1, error = not found[6] */
    . . .
  • Related functions

    fbstrerror(), getfberror()