PreviousNext

Description of Sample Program

The thradd program has a similar structure to the sample XDS programs in the previous topic. Therefore, only a short general outline of the program is given here. The thread specifics are described in detail in the next topic.

The static descriptors for the fixed tree (that is, /C=it/O=sni/OU=ap) are declared in the thradd.h header file. Listings of both the thradd.c application and the thradd.h header file are included in later topics.

The main routine scans the command-line options, initializes the XDS workspace and, if working in adding mode, binds to the default GDS server without credentials, adds the fixed tree of upper nodes, and then unbinds from the directory.

The program then binds to the default GDS server without credentials. Each line of the input file is processed in turn by a while loop (until the end of file is reached). The while loop contains two for loops. The first for loop creates a separate thread for each line of the input file, up to a maximum of MAX_THREAD_NO of threads.

The add_or_remove( ) procedure, which adds or removes an entry to/from the directory, is the starting point of each thread's processing.

The second for loop waits for termination of the threads and then releases the resources used by the threads.

When the entire input file has been processed, thradd closes the connection to the GDS server and, if working in removing mode, removes the fixed tree of upper nodes (that is, /C=it/O=sni/OU=ap).

Finally, the XDS workspace is closed.

The figure below shows the program flow.


Program Flow for the thradd Sample Program