Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dtmsglogopenfile(3) [hpux man page]

DtMsgLogOpenFile(library call)											    DtMsgLogOpenFile(library call)

NAME
DtMsgLogOpenFile -- opens a log file SYNOPSIS
#include <Dt/MsgLog.h> FILE* DtMsgLogOpenFile( const char* type, char** filename_return); DESCRIPTION
The DtMsgLogOpenFile function calls fopen to open a log file with type open mode. If fopen opens a log file successfully and returns a non- NULL filename_return, DtMsgLogOpenFile calls malloc to allocate space for filename_return. DtMsgLogOpenFile then copies the log file name to filename_return. The caller must use the free function to release the space allocated for filename_return, if it is not NULL. The caller must also close the file pointer returned by DtMsgLogOpenFile. Use caution in doing this because stderr may be returned. For a description of the algorithm used to determine the log file to open, see DtMsgLogMessage(3). Note that if a log file cannot be opened, filename_return will be set to NULL. ARGUMENTS
type Specifies the file open flag. See fopen(3) for more information. filename_return Specifies the variable to receive the returned log file name. ENVIRONMENT VARIABLES
None. RESOURCES
None. ACTIONS
/MESSAGES None. ERRORS
/WARNINGS None. EXAMPLES
The following code fragment opens the log file, logs the log file name, closes the file, and frees the space allocated for the file name. char * log_file; FILE * fp = DtMsgLogOpenFile ("a+", &log_file); if (log_file) { DtMsgLogMessage (argv[0], DtMsgLogInformation, "The log file name is: %s", log_file); free (log_file); } if (fp && fp != stderr) fclose (fp); RETURN VALUE
If DtMsgLogMessage completes successfully, it returns a pointer to the opened log file. If it cannot open a log file, it returns stderr. FILES
None. SEE ALSO
DtMsgLogMessage(3), DtMsgLogSetHandler(3) DtMsgLogOpenFile(library call)

Check Out this Related Man Page

fopen(3UCB)					     SunOS/BSD Compatibility Library Functions					       fopen(3UCB)

NAME
fopen, freopen - open a stream SYNOPSIS
/usr/ucb/cc[ flag ... ] file ... #include <stdio.h> FILE *fopen( file, mode); const char *file, *mode; FILE *freopen(file, mode, iop); const char *file, *mode; register FILE *iop; DESCRIPTION
The fopen() function opens the file specified by file and associates a stream with it. If the open succeeds, fopen() returns a pointer to be used to identify the stream in subsequent operations. The file argument points to a character string that contains the name of the file to be opened. The mode argument is a character string having one of the following values: r open for reading w truncate or create for writing a append: open for writing at end of file, or create for writing r+ open for update (reading and writing) w+ truncate or create for update a+ append; open or create for update at EOF The freopen() function opens the file specified by file and associates the stream pointed to by iop with it. The mode argument is used just as in fopen(). The original stream is closed, regardless of whether the open ultimately succeeds. If the open succeeds, freopen() returns the original value of iop. The freopen() function is typically used to attach the preopened streams associated withstdin, stdout, and stderr to other files. When a file is opened for update, both input and output can be performed on the resulting stream. Output cannot be directly followed by input without an intervening fseek(3C) or rewind(3C). Input cannot be directly followed by output without an intervening fseek(3C) or rewind(3C). An input operation that encounters EOF will fail. RETURN VALUES
The fopen() and freopen() functions return a NULL pointer on failure. USAGE
The fopen() and freopen() functions have transitional interfaces for 64-bit file offsets. See lf64(5). SEE ALSO
open(2), fclose(3C), fopen(3C), freopen(3C), fseek(3C), malloc(3C), rewind(3C), lf64(5) NOTES
Use of these functions should be restricted to applications written on BSD platforms. Use of these functions with any of the system libraries or in multithreaded applications is unsupported. To support the same number of open files as the system, fopen() must allocate additional memory for data structures using malloc(3C) after 64 files have been opened. This confuses some programs that use their own memory allocators. The fopen() and freopen() functions differ from the standard I/O functions fopen(3C) and freopen(3C). The standard I/O functions distin- guish binary from text files with an additional use of 'b' as part of the mode, enabling portability of fopen(3C) and freopen(3C) beyond SunOS 4.x systems. SunOS 5.10 22 Jan 1993 fopen(3UCB)
Man Page