WindSpring   |    +1 408-452-7400
Resources -> Code Samples
Code Samples

The sample application below may be used as a reference to understand how to use DMTools APIs to develop, modify or integrate applications that leverage the capabilities of WindSpring's patented mobile data optimization technologies.

Application code:
compression code sample

Commentary of the Code:
Line 4 includes the file API header definitions used in declarations for DMT file operation.

Line 5 shows special declarations for DMT file operation. The DMT_FILE represents an instance of a DMT miniaturized file.

Line 19 shows how to perform an operation on a DMT file. Open the file using the dmt_fopen() function. A null value returned denotes a problem, such as file does not exist at specified location or the user does not have the correct permission to open the file in the mode specified. The first parameter specifies the file type (QS encoded, QP encoded or unencoded, i.e. not a DMT file). XX_TYPE allows the dmt_file_api library to determine the file type. This parameter is ignored for operations on existing DMT encoded files. Here, the actual file type overrides this parameter. (These parameter values are defined in dmt_file_api.h). The second parameter is a character array containing the file name. The third parameter is the mode of operation – “r” for read, “r+”, “w” or “a” for writing, and the special DMT modes “s” for seed and “e” for encode.

Line 21 shows how to seek to a specific location in the DMT stream using dmt_fseek. The first parameter is the instance of a DMT_FILE that was retuned by prior call to dmt_fopen function call.

Line 23 shows how to use the dmt_ftell to obtain the current filepointer position.

Line 25 does a read from a DMT stream. The return value is the number of bytes read from the stream. This could be less than the value requested if there aren’t enough bytes available.

Line 27 writes the text “something” at the current filepointer position.

Line 32 closes the DMT file. Each file successfully opened must be closed prior to exiting the application. Note: Do not use the fcloseall() C function call, as that will close internal DMT working files without properly closing any open DMT files.

To learn more about our 30 day evaluation and licensing agreements email us.

WindSpring, Inc.     © 2014