
/*****************************************************************************
**
**  This program is free software; you can redistribute it and/or
**  modify it, however, you cannot sell it.
**
**  This program is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**
**  You should have received a copy of the license attached to the
**  use of this software.  If not, visit www.shmoo.com/osiris for
**  details.
**
*****************************************************************************/

/*****************************************************************************
**
**  File:    host_brief.c
**  Date:    August 18, 2002
**
**  Author:  Brian Wotring
**
**  Purpose: structure representing a host that can be transported in a message.
**
******************************************************************************/

#include "libosirism.h"

void wrap_host_brief( OSI_HOST_BRIEF *host )
{
    if( host != NULL )
    {
        host->enabled          = HTONLL( host->enabled );
        host->type	           = HTONLL( host->type );

        host->file_log_enabled  = HTONLL( host->file_log_enabled );
        host->archive_databases = HTONLL( host->archive_databases );

        host->notify_enabled   = HTONLL( host->notify_enabled );
        host->notify_always    = HTONLL( host->notify_always );

        host->schedule_start   = HTONLL( host->schedule_start );
        host->schedule_period  = HTONLL( host->schedule_period );
        
        host->config_count   = HTONLL( host->config_count );
        host->database_count = HTONLL( host->database_count );
    }
}

void unwrap_host_brief( OSI_HOST_BRIEF *host )
{
    if( host != NULL )
    {
        host->enabled          = NTOHLL( host->enabled );
        host->type  	       = NTOHLL( host->type );

        host->file_log_enabled  = NTOHLL( host->file_log_enabled );
        host->archive_databases = NTOHLL( host->archive_databases );

        host->notify_enabled   = NTOHLL( host->notify_enabled );
        host->notify_always    = NTOHLL( host->notify_always );

        host->schedule_start   = NTOHLL( host->schedule_start );
        host->schedule_period  = NTOHLL( host->schedule_period );
        
        host->config_count   = NTOHLL( host->config_count );
        host->database_count = NTOHLL( host->database_count );    
    }
}

void osi_set_host_brief_defaults( OSI_HOST_BRIEF *host_brief )
{
    if( host_brief != NULL )
    {
        memset( host_brief, 0, sizeof( OSI_HOST_BRIEF ) );
        
        host_brief->enabled = 1;
        host_brief->type = OSI_HOST_TYPE_GENERIC;

        host_brief->file_log_enabled  = 0;
        host_brief->archive_databases = 1;

        host_brief->notify_enabled   = 0;
        host_brief->notify_always    = 0;

        host_brief->schedule_start = 0;
        host_brief->schedule_period = 1440;   /* 24 hours. */
        
        memset( host_brief->session_key, 0, sizeof( host_brief->session_key ) );
    }
}
