サンプル ファイル auditfile_exit.c

次の .c サンプル コードは、AUDITFILE エミッタを呼び出すユーザー出口です。

/*******************************************************************************
 *
 * Copyright (C) 1984-2015 Micro Focus International Ltd.
 * All rights reserved.
 *
 ******************************************************************************/

#ifdef _WIN32

# define DLLEXPORT          __declspec(dllexport)

#else  /* _WIN32 */

# define DLLEXPORT

#endif /* _WIN32 */

#include <string.h>
#include <stdarg.h>
#include <stdio.h>

#include "mfaudit.h"

/******************************************************************************/
/*  AUDITFILE emitter exit                                                    */
/*                                                                            */
/*  AUDITFILE_EMITTER_EXIT(cobuns32_t function,                               */
/*                         cobuns8_t  *emitter_name,                          */
/*                         ...)                                               */
/*                                                                            */
/*  On input:                                                                 */
/*                                                                            */
/*      function        =   exit function                                     */
/*                                                                            */
/*      emitter_name    =   emitter instance name                             */
/*                                                                            */
/*      ...             =   dependent upon exit function                      */
/*                                                                            */
/*  On output:                                                                */
/*                                                                            */
/*      <nothing>                                                       */
/*                                                                            */
/*  Function returns:                                                         */
/*                                                                            */
/*      0               =   normal completion                                 */
/*      non-zero        =   dependent upon exit function                      */
/******************************************************************************/
DLLEXPORT cobrtncode_t
AUDITFILE_EMITTER_EXIT(
    cobuns32_t  function,
    cobuns8_t   *emitter_name,
    ...)
{
    va_list     args;
    cobuns8_t   *filename;

    va_start(args, emitter_name);

    switch(function)
    {
        case AUDITFILE_EXIT_FUNC_INIT:
            printf("Initialising emitter %s\n", emitter_name);
            break;

        case AUDITFILE_EXIT_FUNC_DEINIT:
            printf("De-initialising emitter %s\n", emitter_name);
            break;

        case AUDITFILE_EXIT_FUNC_FILE_ACTIVE:
            filename = (cobuns8_t *)va_arg(args, cobuns8_t *);
            printf("Emitter %s; active file %s\n", emitter_name, filename);
            break;

        case AUDITFILE_EXIT_FUNC_FILE_FULL:
            filename = (cobuns8_t *)va_arg(args, cobuns8_t *);
            printf("Emitter %s; full file %s\n", emitter_name, filename);
            break;

        case AUDITFILE_EXIT_FUNC_NO_FILES:
            printf("Emitter %s; no available files\n", emitter_name);
            break;

        default:
            printf("Emitter %s; unknown function %d\n", emitter_name, function);
            break;
    }

    va_end(args);
    return 0;
}