I am working with a vendor API that is available in either C or Java and is used to administer a set of services. Using the C API, I have written a number of small command line applications that I run from Perl test scripts to determine the state of the service, restart it etc. This has worked well enough but now I want to drive the C code direcly from the Perl test scripts.

My plan is to take only the functionality that I need and to build and maintain a C DLL and then run h2xs against the header to produce the Perl module. Once the compiler project is set up, I can keep the C libary up to date by adding functionality when the need arises and simply generate the latest module.

I would like to know whether any monk has produced (or knows about) an easy to follow example which will get me started. It would also be great if I could get advice on the best practice for writing C code such that h2xs had minimum of problems. I have been looking at the perlxs and perlxstut documentation in addition to the h2xs documentation but I really want a worked example to start me off. Laziness or intelligent re-use: you decide!


In reply to Wanted: Idiots guide to h2xs by inman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.