comparison online.c @ 0:04124a4423d4 noffle

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