Next Previous Contents

12.3 Text Protocol Server - printing output

The code for printing out the datas can be find in src/server/print.c. Printing out information contained in data structures is essentially simpler than parsing and reading in input datas. All the functions for printing the data structures have three parameters. The first one is a file handle of an opened output stream. The second parameter is a pointer to the data structure to print. The last one is a pseudoparameter of Surprise error system. The only exception is function print_errors which has only two parameters. The value returned by functions is zero if no error occured and negative otherwise. All the functions directly print out data structures in the language used by SurpriseServer which is described in section Description of Text Protocol API.

There are two macros for printing out the data structures: writestr(fh,str) simply prints out to the opened descriptor fh string str; writebuf(fh,buf,fstr,...) is capable of printing out formated out (the format string is fstr and is followed by other parameters, buf provides a buffer for transiently allocated string).

print_errors(int,ERR_PARAM)

This function prints out the errors and frees them from memory. This function is the only output function not using neither macro writestr nor macro writebuf.

int print_final(int, struct final *, ERR_PARAM)

This function prints out struct final. This function calls print_disk and print_parameter.

int print_resources(int, struct resources *, ERR_PARAM)

This function prints out struct resources. This function calls print_disk, print_filesystem and print_parameter.

int print_disk(int, struct disk_info *, ERR_PARAM)

This function prints out struct disk_info. This function calls print_parameter and print_partition.

int print_parameter(int struct user_parameter *, ERR_PARAM)

This function prints out struct user_parameter. The function prints out user parameters of all the five types. This function does not call any of SurpriseServer output functions.

int print_filesystem(int, struct fs_pars *, ERR_PARAM)

This function prints out struct fs_pars. This function calls only print_parameter.

int print_partition(int struct user_partition *, ERR_PARAM)

This function prints out struct user_partition. This function calls print_directory and print_parameter.

int print_directory(int struct user_directory *, ERR_PARAM)

This function prints out struct user_directory. This function does not call any of SurpriseServer output functions.


Next Previous Contents