view src/online.c @ 494:372f8b55506e noffle

[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing', which optionally postpones adding a message ID to the upstream server. If this is done, post-locally must be off. This is to deal with an upstream server troubling Jan. It usually (but not always) rejects posts with a Noffle message ID. I have changed Jan's original option of 'add-message-id-if-missing' for consistency with 'replace-messageid' and added the manual page entry. See SourceForge feature request 1513395.
author bears
date Wed, 12 Jul 2006 20:26:41 +0100
parents 125d79c9e586
children
line wrap: on
line source

/*
  online.c

  $Id: online.c 60 2000-05-09 22:28:38Z uh1763 $
*/

#if HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#include <unistd.h>
#include "common.h"
#include "configfile.h"
#include "log.h"
#include "online.h"
#include "portable.h"

static void
fileOnline( Str s )
{
    snprintf( s, MAXCHAR, "%s/lock/online", Cfg_spoolDir() );
}

Bool
Online_true( void )
{
    FILE *f;
    Str file;

    fileOnline( file );
    if ( ! ( f = fopen( file, "r" ) ) )
        return FALSE;
    fclose( f );
    return TRUE;
}

void
Online_set( Bool value )
{
    FILE *f;
    Str file;

    fileOnline( file );
    if ( value )
    {
        if ( ! ( f = fopen( file, "a" ) ) )
        {
            Log_err( "Could not create %s", file );
            return;
        }
        fclose( f );
        Log_inf( "NOFFLE is now online" );
    }
    else
    {
        if ( unlink( file ) != 0 )
        {
            Log_err( "Cannot remove %s", file );
            return;
        }
        Log_inf( "NOFFLE is now offline" );
    }
}