annotate online.c @ 12:43631b72021f noffle

[svn] Fixed bug: multiple line headers of posted articles were truncated
author enz
date Sat, 15 Apr 2000 11:09:20 +0100
parents 04124a4423d4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
1 /*
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
2 online.c
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
3
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
4 $Id: online.c 3 2000-01-04 11:35:42Z enz $
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
5 */
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
6
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
7 #include <unistd.h>
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
8 #include "common.h"
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
9 #include "config.h"
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
10 #include "log.h"
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
11
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
12 static void
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
13 fileOnline( Str s )
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
14 {
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
15 snprintf( s, MAXCHAR, "%s/lock/online", Cfg_spoolDir() );
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
16 }
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
17
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
18 Bool
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
19 Online_true( void )
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
20 {
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
21 FILE *f;
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
22 Str file;
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
23
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
24 fileOnline( file );
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
25 if ( ! ( f = fopen( file, "r" ) ) )
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
26 return FALSE;
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
27 fclose( f );
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
28 return TRUE;
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
29 }
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
30
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
31 void
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
32 Online_set( Bool value )
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
33 {
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
34 FILE *f;
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
35 Str file;
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
36
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
37 fileOnline( file );
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
38 if ( value )
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
39 {
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
40 if ( ! ( f = fopen( file, "a" ) ) )
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
41 {
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
42 Log_err( "Could not create %s", file );
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
43 return;
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
44 }
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
45 fclose( f );
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
46 Log_inf( "NOFFLE is now online" );
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
47 }
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
48 else
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
49 {
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
50 if ( unlink( file ) != 0 )
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
51 {
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
52 Log_err( "Cannot remove %s", file );
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
53 return;
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
54 }
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
55 Log_inf( "NOFFLE is now offline" );
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
56 }
04124a4423d4 [svn] Initial revision
enz
parents:
diff changeset
57 }