Mercurial > noffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
462:de7f674d1224 | 463:95697d7c97a1 |
---|---|
1 /* | 1 /* |
2 outgoing.c | 2 outgoing.c |
3 | 3 |
4 $Id: outgoing.c 529 2003-05-22 08:26:25Z bears $ | 4 $Id: outgoing.c 608 2003-07-23 09:31:01Z bears $ |
5 */ | 5 */ |
6 | 6 |
7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
8 #include <config.h> | 8 #include <config.h> |
9 #endif | 9 #endif |
44 { | 44 { |
45 snprintf( file, MAXCHAR, "%s/outgoing/%s/%s", | 45 snprintf( file, MAXCHAR, "%s/outgoing/%s/%s", |
46 Cfg_spoolDir(), serv, msgId ); | 46 Cfg_spoolDir(), serv, msgId ); |
47 } | 47 } |
48 | 48 |
49 static void | |
50 createDir( const char *serv ) | |
51 { | |
52 Str dir; | |
53 int r; | |
54 | |
55 snprintf( dir, MAXCHAR, "%s/outgoing/%s", Cfg_spoolDir(), serv ); | |
56 r = mkdir( dir, 0755 ); | |
57 if ( r != 0 ) | |
58 Log_dbg( LOG_DBG_NEWSBASE, "mkdir: %s", strerror( errno ) ); | |
59 } | |
60 | |
61 Bool | 49 Bool |
62 Out_add( const char *serv, const char *msgId, const DynStr *artTxt ) | 50 Out_add( const char *serv, const char *msgId, const DynStr *artTxt ) |
63 { | 51 { |
64 Str file; | 52 Str outDir; |
65 FILE *f; | |
66 | 53 |
67 fileOutgoing( file, serv, msgId ); | 54 Utl_cpyStr( outDir, Cfg_spoolDir() ); |
68 if ( ! ( f = fopen( file, "w" ) ) ) | 55 Utl_catStr( outDir, "/outgoing" ); |
69 { | 56 |
70 createDir( serv ); | 57 return Utl_writeFile( outDir, serv, msgId, DynStr_str( artTxt ) ); |
71 if ( ! ( f = fopen( file, "w" ) ) ) | |
72 { | |
73 Log_err( "Cannot open %s", file ); | |
74 return FALSE; | |
75 } | |
76 } | |
77 fprintf( f, "%s", DynStr_str( artTxt ) ); | |
78 fclose( f ); | |
79 return TRUE; | |
80 } | 58 } |
81 | 59 |
82 Bool | 60 Bool |
83 Out_first( const char *serv, Str msgId, DynStr *artTxt ) | 61 Out_first( const char *serv, Str msgId, DynStr *artTxt ) |
84 { | 62 { |