[fpc-pascal] Wrapping libInkLevel

A.J. Venter ajventer at direq.org
Thu Jul 7 21:22:18 CEST 2005


Hi,
I've been trying to create a wrapper for libinklevel, h2pas with a fairly
standard set of options ran fine, the wrapper compiled once I commented a
double-definition for PInk_level, but on trying to use it, it throws a stack
exception:

I include the translated header file below, maybe somebody could point out
what's wrong ? I've spent some time trying to debug it but to no avail (I'm
also pretty sure that model is meant to be a Pchar);

TIA
A.J.


unit inklevel;
interface

{
  Automatically converted by H2Pas 0.99.16 from inklevel.h
  The following command line parameters were used:
    -p
    -T
    -S
    -c
    -D
    -l
    libinklevel.so
    inklevel.h
}

const
  External_library='libinklevel.so'; {Setup as you need}

{ Pointers to basic pascal types, inserted by h2pas conversion program.}
Type
  PLongint  = ^Longint;
  PSmallInt = ^SmallInt;
  PByte     = ^Byte;
  PWord     = ^Word;
  PDWord    = ^DWord;
  PDouble   = ^Double;

{Type
Pink_level  = ^ink_level;}
{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}



{$ifndef INKLEVEL_H}
{$define INKLEVEL_H}
{$ifdef DEBUG}
{$include <stdio.h> /* for the debug printfs */}
{$endif}



const
   PARPORT = 1;
   USB = 2;

   RESPONSE_INVALID = 0;
   ONE_COLOR_FOUND = 1;
   ONE_BLACK_COLOR_FOUND = 2;
   TWO_COLORS_FOUND = 3;
   TWO_PHOTO_COLORS_FOUND = 4;
   THREE_COLORS_FOUND = 5;
   FOUR_COLORS_FOUND = 6;
   SIX_COLORS_FOUND = 7;
   SEVEN_COLORS_FOUND = 8;

   OK = 0;
   ERROR = -(1);
   DEV_PARPORT_INACCESSIBLE = -(2);
   DEV_LP_INACCESSIBLE = -(3);
   COULD_NOT_GET_DEVICE_ID = -(4);
   DEV_USB_LP_INACCESSIBLE = -(5);
   UNKNOWN_PORT_SPECIFIED = -(6);
   NO_PRINTER_FOUND = -(7);
   NO_DEVICE_CLASS_FOUND = -(8);
   NO_CMD_TAG_FOUND = -(9);
   PRINTER_NOT_SUPPORTED = -(10);
   NO_INK_LEVEL_FOUND = -(11);
   COULD_NOT_WRITE_TO_PRINTER = -(12);
   COULD_NOT_READ_FROM_PRINTER = -(13);
   COULD_NOT_PARSE_RESPONSE_FROM_PRINTER = -(14);
   MODEL_NAME_LENGTH = 100;
type
   Pink_level = ^Tink_level;
   Tink_level = record
        model : array[0..(MODEL_NAME_LENGTH)-1] of byte;
        _type : word;
        black : word;
        color : word;
        cyan : word;
        magenta : word;
        yellow : word;
        photo : word;
        photocyan : word;
        photomagenta : word;
        photoyellow : word;
     end;


function get_ink_level(port:longint; portnumber:longint;
level:Pink_level):longint;cdecl;external External_library;


const
   BUFLEN = 1024;
   NR_TAGS = 15;
   OLD = 1;
   NEW = 2;
{$endif}

implementation


end.

-------------------------------------------------------




More information about the fpc-pascal mailing list