diff src/outgoing.c @ 463:95697d7c97a1 noffle

[svn] * src/outgoing.c,src/util.h,src/util.c: Create Utl_createDir() and Utl_writeFile() and rework outgoing.c to use them.
author bears
date Wed, 23 Jul 2003 10:31:01 +0100
parents 0137b5490cca
children
line wrap: on
line diff
--- a/src/outgoing.c	Wed Jul 23 10:26:49 2003 +0100
+++ b/src/outgoing.c	Wed Jul 23 10:31:01 2003 +0100
@@ -1,7 +1,7 @@
 /*
   outgoing.c
 
-  $Id: outgoing.c 529 2003-05-22 08:26:25Z bears $
+  $Id: outgoing.c 608 2003-07-23 09:31:01Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -46,37 +46,15 @@
               Cfg_spoolDir(), serv, msgId );
 }
 
-static void
-createDir( const char *serv )
-{
-    Str dir;
-    int r;
-
-    snprintf( dir, MAXCHAR, "%s/outgoing/%s", Cfg_spoolDir(), serv );
-    r = mkdir( dir, 0755 );
-    if ( r != 0 )
-        Log_dbg( LOG_DBG_NEWSBASE, "mkdir: %s", strerror( errno ) );
-}
-
 Bool
 Out_add( const char *serv, const char *msgId, const DynStr *artTxt )
 {
-    Str file;
-    FILE *f;
+    Str outDir;
 
-    fileOutgoing( file, serv, msgId );
-    if ( ! ( f = fopen( file, "w" ) ) )
-    {
-        createDir( serv );
-        if ( ! ( f = fopen( file, "w" ) ) )
-        {
-            Log_err( "Cannot open %s", file );
-            return FALSE;
-        }
-    }
-    fprintf( f, "%s", DynStr_str( artTxt ) );
-    fclose( f );
-    return TRUE;
+    Utl_cpyStr( outDir, Cfg_spoolDir() );
+    Utl_catStr( outDir, "/outgoing" );
+
+    return Utl_writeFile( outDir, serv, msgId, DynStr_str( artTxt ) );
 }
 
 Bool