TutSetFileCloseFunc


Name

TutSetFileCloseFunc — sets the function to use when closing a file

Synopsis

T_BOOL TutSetFileCloseFunc(close_func) 
T_FILE_CLOSE_FUNC close_func; 

Arguments

close_func — function to use when closing a file

Return Values

TRUE if successful, FALSE otherwise.

Diagnostics

None

Description

TutSetFileCloseFunc allows you to specify a function used to close a file when the process is done with it.

The default close function is fclose. If NULL is specified for close_func, the default is used for subsequent close file operations.

Caution

None

See Also

TutSetFileOpenFunc, TutSetFileReadFunc, TutFileTraverse

Examples

This example uses TutSetFileCloseFunc to perform post-processing on a data file:

static T_PTR find_name(t_file, arg) 
T_FILE t_file; 
T_PTR arg; 
{ 
 
  if (t_file->file == (FILE *)arg) { 
    return t_file->fname; 
  } 
 
  return NULL; 
 
} /* find_name */ 
 
static T_BOOL close_func(file) 
FILE *file; 
{ 
  T_STR fname; 
 
  fname = TutFileTraverse(find_name, file); 
  if (fname == NULL) { 
    /* error */ 
  } 
  fclose(file); 
  TutOut("Closing file %s\n", fname); 
  postprocess_file(fname);   /* user provided function */ 
   
} 
 
. 
. 
. 
TutSetFileCloseFunc(close_func); 
. 
. 
. 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com