8 #include "secToolFileIO.h" 
  12 #include <utilities/SecCFWrappers.h> 
  17 void _printcfmsg(FILE *ff
, CFDictionaryRef formatOptions
, CFStringRef format
, ...) CF_FORMAT_FUNCTION(3, 4); 
  19 void _printcfmsg(FILE *ff
, CFDictionaryRef formatOptions
, CFStringRef format
, ...) 
  22     va_start(args
, format
); 
  23     CFStringRef message 
= CFStringCreateWithFormatAndArguments(kCFAllocatorDefault
, formatOptions
, format
, args
); 
  25     CFStringPerformWithCString(message
, ^(const char *utf8String
) { fprintf(ff
, "%s", utf8String
); }); 
  30 int SOSLogSetOutputTo(char *dir
, char *filename
) { 
  34         pathlen 
= strlen(dir
) + strlen(filename
) + 2; 
  36         snprintf(path
, pathlen
, "%s/%s", dir
, filename
); 
  37         outFile 
= fopen(path
, "a"); 
  38     } else if(dir 
|| filename
) { 
  48 void closeOutput(void) { 
  49     if(outFile 
!= stdout
) { 
  55 int copyFileToOutputDir(char *dir
, char *toCopy
) { 
  56     char *bname 
= basename(toCopy
); 
  59     copyfile_state_t cpfilestate 
= copyfile_state_alloc(); 
  61     status 
= snprintf(destpath
, 256, "%s/%s", dir
, bname
); 
  62     if(status 
< 0 || status 
> 256) return -1; 
  64     int retval 
= copyfile(toCopy
, destpath
, cpfilestate
, COPYFILE_ALL
); 
  66     copyfile_state_free(cpfilestate
);