kjb_fprintf - Writes a formatted string to a stream.


#include "l/l_sys_io.h"

Example compile flags (system dependent):
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 

long kjb_fprintf
	FILE *fp,
	const char *format_str,


The formating options are similar to the standard ones, except that the standard ones are not very standard! Thus the KJB library routine provides some semblence of platform independent IO. This routine works together with the rest of the KJB library to implement 1) paging (controlled via user options) and 2) flushing of all files when stderr is written to. This second feature reduces the confusion that sometimes occur when one is expecting output from stdout before an error message, but might not see it because it is still in the output buffer. We always flush stdout before writting to stderr. There are additional formatting options available. %S takes no arguement. It produces the string "System error message is: " followed by the error message from the last unsuccessful system call. %F takes a file pointer, and prints the file name as specified by the user (or internal to the code). %D does the same with a file descriptor. %P is similar to %F, except that the complete path is provided instead. The option %t (truncate) is similar to %s, exept that if a field width is given, either by a numeric constant or a *, then if that field width would be overrun, then we form a string of the form "<str> ...". "t" is short for trucated. The option %q is similar to %t, except that quotes are added arround the string. Finally, the option %R converts an integer to the return enum symbols defined as part of Return_status, or simply the integer itself, if the integer is not one of those values. For example, if the integers has the value ERROR, then "ERROR" is printed. This options is obviously mostly for debugging. This function is not re-entrant (i.e., not thread-safe).


ERROR on failure and the number of characters printed on success.




This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.


Kobus Barnard


Kobus Barnard


set_low_level_io_options , kjb_read_exact , kjb_read , kjb_read_2 , safe_pipe_write , kjb_write , kjb_write_2 , kjb_fread_exact , kjb_fread , kjb_fread_2 , kjb_fwrite , kjb_fwrite_2 , kjb_safe_fflush , kjb_fflush , kjb_ioctl , set_blocking , set_no_blocking , stdin_get_line , fget_line , dget_line , fput_line , kjb_mkdir , kjb_mkdir_2 , kjb_unlink , kjb_unlink_2 , kjb_rmdir , kjb_fopen , kjb_freopen , kjb_fdopen , kjb_fclose , kjb_realpath , get_fd_name , get_user_fd_name , kjb_fseek , kjb_ftell , kjb_fputs , kjb_fgetc , kjb_fputc , pso , p_stderr , pdo , kjb_vfprintf , is_file , is_directory , fp_get_path_type , get_path_type , get_file_size , fp_get_byte_size , get_file_age , stream_younger , stream_older , get_file_mod_time , kjb_isatty , print_underlined , start_stdout_shadow , stop_stdout_shadow , start_stderr_shadow , stop_stderr_shadow , enable_stdout , disable_stdout , kjb_glob , kjb_simple_glob