/*
 * Portions of this file Copyright 1999-2005 University of Chicago
 * Portions of this file Copyright 1999-2005 The University of Southern California.
 *
 * This file or a portion of this file is licensed under the
 * terms of the Globus Toolkit Public License, found at
 * http://www.globus.org/toolkit/download/license.html.
 * If you redistribute this file, with or without
 * modifications, you must include this notice in the file.
 */


#ifndef _SECURECOUNTERSERVICE_INTERNAL_SKELETON_H_
#define _SECURECOUNTERSERVICE_INTERNAL_SKELETON_H_

#include "globus_common.h"

EXTERN_C_BEGIN

#include "SecureCounterService.h"

GlobusDebugDeclare(SECURECOUNTERSERVICE);

extern globus_module_descriptor_t SecureCounterService_module;
#define SECURECOUNTERSERVICE_MODULE &SecureCounterService_module

#define SECURECOUNTERSERVICE_INFO  1
#define SECURECOUNTERSERVICE_DEBUG 2
#define SECURECOUNTERSERVICE_TRACE 4
#define SECURECOUNTERSERVICE_WARN  8
#define SECURECOUNTERSERVICE_ERROR 16

#define SecureCounterServiceDebugPrintf(LEVEL, MESSAGE) \
    GlobusDebugPrintf(SECURECOUNTERSERVICE, LEVEL, MESSAGE)

#define SecureCounterServiceDebugEnter() \
    SecureCounterServiceDebugPrintf(SECURECOUNTERSERVICE_TRACE, \
                       ("[%s] Entering\n", _globus_func_name))

#define SecureCounterServiceDebugExit() \
    SecureCounterServiceDebugPrintf(SECURECOUNTERSERVICE_TRACE, \
                       ("[%s] Exiting\n", _globus_func_name))

enum
{
    SECURECOUNTERSERVICE_ERROR_TYPE_INVOKE_FAILED = 1024,
    SECURECOUNTERSERVICE_ERROR_RETURNED_UNKNOWN_FAULT,
    SECURECOUNTERSERVICE_ERROR_NOT_IMPLEMENTED
};

#define SecureCounterServiceErrorInvokeFailed(result, message)               \
    globus_error_put(                                           \
        globus_error_construct_error(                           \
            SECURECOUNTERSERVICE_MODULE,                       \
            (result ? globus_error_get(result) : NULL),         \
            SECURECOUNTERSERVICE_ERROR_TYPE_INVOKE_FAILED,     \
            __FILE__,                                           \
            _globus_func_name,                                  \
            __LINE__,                                           \
            "Operation invocation failed: %s", message))

#define SecureCounterServiceErrorReturnedUnknownFault(opname)                 \
     globus_error_put(                                           \
         globus_error_construct_error(                           \
             SECURECOUNTERSERVICE_MODULE,                       \
             NULL,                                               \
             SECURECOUNTERSERVICE_ERROR_RETURNED_UNKNOWN_FAULT, \
             __FILE__,                                           \
             _globus_func_name,                                  \
             __LINE__,                                           \
             "Operation %s returned unknown fault", opname))

#define SecureCounterServiceErrorNotImplemented(opname)                       \
     globus_error_put(                                           \
         globus_error_construct_error(                           \
             SECURECOUNTERSERVICE_MODULE,                       \
             NULL,                                               \
             SECURECOUNTERSERVICE_ERROR_NOT_IMPLEMENTED,        \
             __FILE__,                                           \
             _globus_func_name,                                  \
             __LINE__,                                           \
             "Operation %s Unimplemented", opname))
        
EXTERN_C_END

#endif
