8 #include "secToolFileIO.h"
12 #include <utilities/SecCFWrappers.h>
17 void _printcfmsg(FILE *ff
, CFDictionaryRef formatOptions
, CFStringRef format
, ...)
20 va_start(args
, format
);
21 CFStringRef message
= CFStringCreateWithFormatAndArguments(kCFAllocatorDefault
, formatOptions
, format
, args
);
23 CFStringPerformWithCString(message
, ^(const char *utf8String
) { fprintf(ff
, utf8String
, ""); });
28 int SOSLogSetOutputTo(char *dir
, char *filename
) {
32 pathlen
= strlen(dir
) + strlen(filename
) + 2;
34 snprintf(path
, pathlen
, "%s/%s", dir
, filename
);
35 outFile
= fopen(path
, "a");
36 } else if(dir
|| filename
) {
46 void closeOutput(void) {
47 if(outFile
!= stdout
) {
53 int copyFileToOutputDir(char *dir
, char *toCopy
) {
54 char *bname
= basename(toCopy
);
57 copyfile_state_t cpfilestate
= copyfile_state_alloc();
59 status
= snprintf(destpath
, 256, "%s/%s", dir
, bname
);
60 if(status
< 0 || status
> 256) return -1;
62 int retval
= copyfile(toCopy
, destpath
, cpfilestate
, COPYFILE_ALL
);
64 copyfile_state_free(cpfilestate
);