/* ********************************************************************************* *
 * vcd_exports : header file that is used to export/import things from the library   *
 * --------------------------------------------------------------------------------- *
 * Copyright(c)2002      Laurens H. Koehoorn <lhksoft@users.sourceforge.net>         *
 *                                                                                   *
 * This program is free software; you can redistribute it and/or modify it under the *
 * terms of the GNU General Public License as published by the Free Software Foun-   *
 * dation; either version 2 of the License, or (at your option) any later version.   *
 *                                                                                   *
 * 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. See the GNU General Public License for more details.          *
 *                                                                                   *
 * You should have received a copy of the GNU General Public License along with this *
 * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,    *
 * Suite 330, Boston, MA 02111-1307 USA                                              *
 * ********************************************************************************* */
#ifndef __VCD_EXPORTS_H__
#define __VCD_EXPORTS_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#pragma pack( push, vcdExports, 1)
// aligning at 1-byte

typedef struct _vcdxbuild_options_ {
  char                 xmlFile[MAX_PATH]; // full path to XML file that should be processed
  enum _image_type_ {
    IMG_BINCUE = 0,
    IMG_CDRDAO,
    IMG_NRG
  }                    img_type;          // (-i, --image-type=TYPE)
                                          // specify image type for output (default : IMG_BINCUE)
  char                 cue[MAX_PATH];     // (-c, --cue-file=FILE) -- specify cue file for output (default: '.\videocd.cue')
  char                 bin[MAX_PATH];     // (-b, --bin-file=FILE) -- specify bin file for output (default: '.\videocd.bin')
                                             // (--cdrdao-file=FILE) -- specify cdrdao-style image filename base
                                             // used, when (img_type==IMG_CDRDAO) -->> TOC in 'cue', IMG_BASE in 'bin'
                                             // (--nrg-file=FILE) -- specify nrg-style image filename
                                             // used, when (img_type==IMG_NRG) -->> NRG in 'bin', 'cue' is ignored

  BOOL                 sec2336;           // (--sector-2336) -- use 2336 byte sectors for output (default : 'No'=FALSE)
                                             // NRG always uses 2336-aligned sectors
  BOOL                 version;           // (-V, --version) -- display version and copyright information and exit

  enum _verbosity_ {
    VERBOSE_INFO = 0,
    VERBOSE_DEBUG,
    VERBOSE_SILENT
  }                    verbose;           // SILENT shows only PROGRESS, WARNINGS, ERRORS (and ASSERTIONs ifdef _DEBUG)

  BOOL                 progress;          // (-p, --progress), TRUE if you want progess-output
  // Following are only valid for the 'lkVCDxBuild'-frontend
  BOOL                 gui_mode;          // (--gui) -- enable GUI mode, ala hvr-style ('progress' must be set to TRUE)
  BOOL                 want_help;         // [-?, -h, --help]
  BOOL                 show_usage;        // [-u, --usage]
  unsigned             unknown;           // amount of invalid command-line parameters (currently not implemented)
} vcdxbuild_options_t, *lp_vcdxbuild_options; // should be 'sizeof()=816', using packing to 1bytes alignment

typedef struct _w32Msg_Progress_ {
  char                 reserved;          // always should be '\0' ('zero') --> this to prevent a msg-handler would treate this struct as a string...
  enum _progress_type_ {
    PGS_INVALID = 0,
    PGS_SCAN,
    PGS_WRITE
  }                    type;              // 0 = INVALID, 1 = SCAN, 2 = WRITE
  const char*          user_data;         // something like which is being currently operated at
  unsigned             percentage;        // result of formula's (see below) (type is an unsigned integer)
  union _u_progress_ {
    struct _s_scan_ { // valid if 'type'==1 (scan)
      long          length;            // total length
      long          cur_pos;           // current position
      long          cur_pack;          // (like current frame in the MPeG)
    }            scan_s;      // formula to get percentage : (cur_pos / length * 100)
    struct _s_write_ { // valid if 'type'==2 (write)
      long          sectors_written;
      long          total_sectors;     // total sectors of the image
      int           in_track;          // current track of the image
      int           total_tracks;      // total tracks at the cd_image
    }            write_s;     // formula to get percentage : (sectors_written / total_sectors * 100)
  }                    progress_u;
} progress_w32_t; // this struct will be send to the owner-application in case of 'LOG_PROGRESS' messages

typedef struct _w32Msg_Version_ {
  char                 reserved;          // should be '\0', see as above -- if !0, we're dealing with a real string
  const char*          full;
  const char*          library;           // 'lkVCDimager' or 'lkVCDxBuild'
  const char*          major;             // 'x.0'
  const char*          minor;             // '7'
  const char*          micro;             // '10'
  const char*          platform;          // 'win32'
} version_w32_t; // this struct could be send to the owner-applic in case of 'LOG_VERSION' messages

#pragma pack( pop, vcdExports)
// back to 'normal' byte-alignement (which is usually 8bytes)

#ifndef lkVCDimager_internal
// 'lkVCDimager_internal' : you should _NOT_ define this value in your importing application, unless you don't want the following things
// 'lkVCDimager_internal' : internal definition of the library

typedef enum { // these are used as WPARAM parameter in case a message is send
  LOG_DEBUG = 1,
  LOG_INFO,      // 2
  LOG_WARN,      // 3
  LOG_ERROR,     // 4
  LOG_ASSERT,    // 5
  LOG_PROGRESS,  // 6
  LOG_VERSION    // 7
} log_level_t; // used to direct output, without using preceding type (e.g. 'info:' in case of informational logging)


// Exported Function(s) :
// ----------------------
  // library versions <= 3.0.7.10 :
  // int lkVCDxBuild(HWND pOwner, const char* msgString, lp_vcdxbuild_options lpOptions);
typedef int (*lp_lkVCDxBuild)(HWND, const char*, lp_vcdxbuild_options);

  // library versions >= 4.0.7.10 :
  // int lkVCDxBuild(HWND pOwner, const char* msgString, lp_vcdxbuild_options lpOptions, BOOL* lpWantCancel=NULL);
typedef int (*lp_lkVCDxBuild_4)(HWND, const char*, lp_vcdxbuild_options, BOOL*);

/* If you enter '0' (zero) for the HWND param, the functions will do a call to 'GetActiveWindow()'
   to get a HWND of the window which currently is active at the desktop, to ensure that the
   message send will be directed correctly.
   Though it is strongly recomended to supply the HWND yourself!

   Some Explanations :
   ===================
    pOwner       : will be used for sending the logging-messages to the owning application
    msgString    : unique message-identifier, which will be used to obtain a registred msg-id
                   (shouldn't be empty!) : the sending-message is identified by this id.
                   The ID will be retrieved via 'UINT uniqueHandle = RegisterWindowMessage( msgString );'
                   Your application should do the same action to retain this handle, then add
                   'ON_REGISTERED_MESSAGE' to your Message_Map to handle this message.
                   (see 'lkTest' for how to do it)
    lpWantCancel : if valid and set to TRUE (during run-time), will cancel any scan/write
                   operation and returns an errorlevel after normal function-termination.                    If used, it should be initially set to FALSE...
                   Can be NULL (if not implied) otherwise it should be a valid ptr to a dynamic
                   BOOLean. The ptr shouldn't go out of scope during runtime of the function

    Return values of 'lkVCDxBuild', if launched via 'lkVCDimager'
       -1 : wrong parameters
        0 : succesfull operation
        1 : error in xml- and/or vcd- processing (also when 'lpWantCancel' wend to TRUE)
        2 : exception occured, resulting in _memory leaks_
            As from rel. 4.0.7.10, assertions will _NOT_ occur, to see if they still are there,
            you must link the library in _DEBUG configuration and do lots of tryouts...

   For developpers who are not familiarized with C++ :
   ===================================================
    HWND is a 32-bit unsigned integer representing the hWindow (handle to the active window)
      (VB : 'ByValue As Long')
    BOOL is a 32-bit unsigned integer that usual is TRUE (0x00000001) or FALSE (0x00000000)
      (VB : 'Long')
    an enum represents a 32-bit signed integer (VB : 'ByValue As Long')
    LPCTSTR (const char*) should be called in VB like 'ByValue As String'
    VB users should do 'propper' conversion if they want to fill a VB-String into a C-array of char
    sizeof(MAX_PATH) = 260 (at MAC it is actually 256, but for compliance with the size
      of the struct used here, it always should be '260' - also at MAC)
    VB users must be sure that the length of Long = 4bytes (Long _MUST_ be 32-bits)
    sizeof(vcdxbuild_options_t) == 816 bytes (using 1-byte memory alignement)
    in VB, the param 'lp_vcdxbuild_options' would be 'ByRef As vcdxbuild_options_t'
*/


#endif // !defined(lkVCDimager_internal)

#endif // __VCD_EXPORTS_H__


Valid XHTML 1.0! Laurens Koehoorn
Last Validated: 2002/10/30