next up previous contents
Next: Client API Up: Building a client program Previous: Building a client program   Contents


Structure of a client program

Since the client side of DIET is a library, a client program has to define a main function that uses DIET through function calls. The complete client-side interface is described in the files DIET_data.h (see Chapter 3) and DIET_client.h found in install_dir/include. Please refer to these two files for a complete and up-to-date API 4.1description, and include at least the latter at the beginning of your source code (DIET_client.h includes DIET_data.h):

#include <stdio.h>
#include <stdlib.h>

#include "DIET_client.h"

int main(int argc, char *argv[])
{
  diet_initialize(configuration_file, argc, argv);
  // Successive DIET calls ...
  diet_finalize();
}

The client program must open its DIET session with a call to diet_initialize, which parses the configuration file to set all options and get a reference to the DIET Master Agent. The session is closed with a call to diet_finalize, which frees all resources associated with this session on the client. Note that memory allocated for all INOUT and OUT arguments brought back onto the client during the session is not freed during diet_finalize; this allows the user to continue to use the data, but also requires that the user explicitly free the memory. The user must also free the memory he or she allocated for IN arguments.


next up previous contents
Next: Client API Up: Building a client program Previous: Building a client program   Contents
The DIET Team - Ven 18 nov 2011 18:13:39 PST