hminlib
Each program developed with hminlib uses the routines within the library to set up communication links with HyperMesh and to transfer data to HyperMesh using a specific protocol. When writing a translator, all low-level communication issues are automatically handled by hminlib. Essentially, the structure of each external translator program is designed to allow for efficient communication between the external program and HyperMesh.
In order to write a translator, you must perform certain programming tasks; a specific series of C functions must be defined which follow the structure of hminlib. All programs that rely on hminlib must begin execution by initializing hminlib. Initialization allocates memory required by hminlib, opens required files, and prepares hminlib to be used. The next function performed by the external program transfers control of the program to hminlib. Once hminlib has received control of the program, it begins calling functions that you define. The purpose of these user-defined functions is to read data from a file which is in the appropriate format, translate the data to a format HyperMesh can understand, and finally, communicate the translated information to HyperMesh.
The dynamic block functions provide an easy-to-use interface that allows you to allocate and free dynamically allocated blocks of memory, without worrying about low-level programming issues. In this case, a dynamic block is an entity that, once created, is capable of storing items of a user-defined size. As more items are added to the block, the block automatically acquires more memory to store those elements. After items are stored, the dynamic block interface also allows you to retrieve pointers into the block to access the previously stored items.
Before a dynamic block can be used, it must be created. To create a dynamic block, you must call HM_dynamicblockallocate(). This function requires you to pass the type of block being created and the size of the items stored. The function returns a void pointer that points to the dynamic block. You must store the pointer returned from the allocate function, as it is used for all successive calls to the dynamic block routines.
Once the block is created, the next step is to store items in the block. This is accomplished by making a call to the function HM_dynamicblockadd(). Call this function for each item to be added and returns a void pointer that points to the memory allocated for that item. This pointer is then used directly, and the appropriate information is placed into the block.
Information stored in a block may be accessed by using the function HM_dynamicblockgetpointer() which returns a pointer to any previously stored item. With the use of the pointer returned, information stored in the item can be accessed or modified.
The final important point when using blocks is that once a block is created, it should be destroyed. This is accomplished by calling HM_dynamicblockfree(). However, once this function is called, the block is no longer available, and the memory allocated for the block is freed.