Announcement

Collapse
No announcement yet.

Translating C Header files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Translating C Header files

    I'm starting to translate a C header file to PB INC and I can see some kind of directives XLATON / XLATOFF.

    They're always commented out in this header with /* --- */ pairs but I'm curious as to what they were/are for?

    Quick web search yields next to nothing. Has anyone encountered them and have any background?

    George

  • #2
    Never seen them before but would guess it is a translation flag of sorts.

    ------------------
    Andre Smit

    Comment


    • #3
      Isn't that for an excel addin?


      ------------------
      http://www.hellobasic.com

      [This message has been edited by Edwin Knoppert (edited May 11, 2007).]
      hellobasic

      Comment


      • #4
        Just ignore it and see what happens?
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          They're always commented out in this header with /* --- */ pairs but I'm curious as to what they were/are for?
          Just comments.


          ------------------
          Website: http://com.it-berater.org
          SED Editor, TypeLib Browser, COM Wrappers.
          Forum: http://www.forum.it-berater.org
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            blocked out comments like
            Code:
            /* Comments below are only for later readable notes
            comment
            comment
            commmentttttttt
            next line ends comments
            */
            ------------------
            Engineer's Motto: If it aint broke take it apart and fix it

            "If at 1st you don't succeed... call it version 1.0"

            "Half of Programming is coding"....."The other 90% is DEBUGGING"

            "Document my code????" .... "WHYYY??? do you think they call it CODE? "

            Comment


            • #7
              OK guys, thanks for the replies. I have been ignoring them, as I said I was curious, especially when web searches also yielded nothing.

              George

              Comment


              • #8
                OK, I'm back. I'm stumped by this typedef, what on earth is being done here with the colons?

                George

                Code:
                typedef  struct _RXFNC_FLAGS {         ' fl
                   unsigned rxfferr  : 1;              ' Invalid call to routine.
                   unsigned rxffnfnd : 1;              ' Function not found.
                   unsigned rxffsub  : 1;              ' Called as a subroutine
                }  RXFNC_FLAGS ;

                Comment


                • #9
                  Assigning default values. Ignore them. You will have to initialize
                  the values by hand.



                  ------------------
                  Website: http://com.it-berater.org
                  SED Editor, TypeLib Browser, COM Wrappers.
                  Forum: http://www.forum.it-berater.org
                  Forum: http://www.jose.it-berater.org/smfforum/index.php

                  Comment


                  • #10
                    The guys here will correct me if I am wrong, but basically
                    Code:
                    typedef  struct _RXFNC_FLAGS {         ' fl
                       unsigned rxfferr  : 1;              ' Invalid call to routine.
                       unsigned rxffnfnd : 1;              ' Function not found.
                       unsigned rxffsub  : 1;              ' Called as a subroutine
                    }  RXFNC_FLAGS ;
                    would equate to in PB
                    Code:
                    TYPE RXFNC_FLAGS
                       rxfferr AS LONG              ' Invalid call to routine.
                       rxffnfnd AS LONG              ' Function not found.
                       rxffsub AS LONG              ' Called as a subroutine
                    END TYPE 
                    
                    FUNCTION
                       rxfferr = 1              ' Invalid call to routine.
                       rxffnfnd = 1              ' Function not found.
                       rxffsub = 1              ' Called as a subroutine
                    END FUNCTION
                    OR at least thats my $0.02 from what I know

                    ------------------
                    Engineer's Motto: If it aint broke take it apart and fix it

                    "If at 1st you don't succeed... call it version 1.0"

                    "Half of Programming is coding"....."The other 90% is DEBUGGING"

                    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                    Comment


                    • #11
                      Code:
                      TYPE RXFNC_FLAGS
                         rxfferr AS DWORD
                         rxffnfnd AS DWORD
                         rxffsub AS DWORD
                      END TYPE 
                      
                      DIM MyFlags AS RXFNC_FLAGS
                      
                      MyFlags.rxfferr = 1
                      MyFlags.rxffnfnd = 1
                      MyFlags.rxffsub = 1

                      ------------------
                      Website: http://com.it-berater.org
                      SED Editor, TypeLib Browser, COM Wrappers.
                      Forum: http://www.forum.it-berater.org
                      Forum: http://www.jose.it-berater.org/smfforum/index.php

                      Comment


                      • #12
                        Uh, guys, those are for setting up BIT flags. It would be easier
                        to see if you saw a code sample but I don't have one handy.



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

                        Comment


                        • #13
                          Hi Paul,

                          You're right on, I finally got a search to turn up a decent description of their definition at(http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/language/ref/clrc03defbitf.htm)

                          At least now I can map it properly, I hope ;-)

                          George

                          Comment


                          • #14
                            OK, I'm back for help. I've made my 1st cut at converting the C Header to a PB INC file and am working through the testing, but not too successfully.

                            I've made successful calls to the DLL to invoke the REXX interpreter, but now I'm hung on passing parameters to it. I'm consistently GPF'ing.

                            If I set NumArgs=0 to say no params, all is well. Once I make it non zero it fails, so the problem is obviously in the 2nd parameter to the call, an array of arguments.

                            I've done all kinds of playing around to no avail. Perhaps someone can see something stupid I'm missing. In the REXX Doc. the 2nd argument is described as:
                            ArgList (PRXSTRING) - input

                            is an array of RXSTRING structures that are the Rexx program arguments.

                            Here's my skeleton code with the appropriate INC declarations pasted in. I know it can't be executed (unless you happen to have ooREXX installed), I'm just hoping someone can see something.

                            George
                            --------
                            [CODE]
                            #COMPILE EXE
                            #DIM ALL

                            TYPE RXSTRING ' REXX string
                            StrLength AS LONG ' length of string
                            StrPointer AS BYTE POINTER ' pointer to string
                            END TYPE

                            %RXCOMMAND = 0 ' Program called as Command

                            ' Main Entry Point to the REXX Interpreter

                            DECLARE FUNCTION RexxStart CDECL LIB "REXX.DLL" ALIAS "RexxStart" ( _
                            BYVAL ArgCount AS LONG, _ ' Num of args passed to rexx
                            ArgList() AS RXSTRING, _ ' Array of args passed to rexx
                            ProgramName AS ASCIIZ, _ ' [d:][path] filename[.ext]
                            InStore() AS RXSTRING, _ ' Loc of rexx proc in memory
                            EnvName AS LONG, _ ' ASCIIZ initial environment.
                            CallTye AS LONG, _ ' type (command,subrtn,funct)
                            Exits AS LONG, _ ' SysExit env. names & codes
                            ReturnCode AS INTEGER, _ ' Ret code from if numeric
                            Result AS LONG _ ' Retvalue from the rexx proc
                            ) AS LONG
                            '------------------
                            ' Original C header descriptions
                            '/*** Structure for external interface string (RXSTRING) */
                            '
                            'typedef struct _RXSTRING { /* rxstr */
                            ' ULONG strlength; /* length of string */
                            ' PCH strptr; /* pointer to string */
                            '} RXSTRING;
                            '
                            'APIRET APIENTRY RexxStart (
                            ' LONG, /* Num of args passed to rexx */
                            ' PRXSTRING, /* Array of args passed to rex */
                            ' PSZ, /* [d:][path] filename[.ext] */
                            ' PRXSTRING, /* Loc of rexx proc in memory */
                            ' PSZ, /* ASCIIZ initial environment.*/
                            ' LONG , /* type (command,subrtn,funct) */
                            ' PRXSYSEXIT, /* SysExit env. names & codes */
                            ' PSHORT, /* Ret code from if numeric */
                            ' PRXSTRING ); /* Retvalue from the rexx proc */
                            '
                            'typedef APIRET (APIENTRY *PFNREXXSTART)(LONG, PRXSTRING, PSZ, PRXSTRING,
                            ' PSZ, LONG, PRXSYSEXIT, PSHORT,
                            ' PRXSTRING);
                            '
                            '------------------
                            MACRO MAKERXSTRING(rxstr, rxdata) = rxstr.StrPointer= VARPTR(rxdata): rxstr.StrLength = LEN(RTRIM$(rxdata))

                            FUNCTION PBMAIN () AS LONG
                            DIM CallRC AS LONG
                            DIM NumArgs AS LONG
                            DIM args(3) AS RXSTRING
                            DIM Arg1 AS STRING * 32
                            DIM Arg2 AS STRING * 32
                            DIM Arg3 AS STRING * 32
                            DIM ScriptName AS ASCIIZ * 32

                            ScriptName = "ListArgs.CMD"
                            NumArgs = 3
                            Arg1 = "111111": Arg2 = "2222222": Arg3 = "33333333"
                            MAKERXSTRING(Args(0), Arg1): MAKERXSTRING(Args(1), Arg2): MAKERXSTRING(Args(2), Arg3)

                            CallRc = RexxStart(NumArgs, Args(), ScriptName, BYVAL 0, 0, %RXCOMMAND, 0, 0, 0)
                            PRINT "CallRC="; STR$(CallRc)
                            WAITKEY$
                            END FUNCTION
                            [CODE]

                            Comment


                            • #15
                              OK, I got it to work. My DECLARE had the 2nd operand as
                              ArgList() as RXSTRING, removing the () did the trick, but just what was PB assuming because of the ()? What did it do with the Args() operand in the FUNCTION CALL statement?

                              George

                              Comment


                              • #16
                                >but just what was PB assuming because of the ()?

                                It was assuming you wanted to pass the address of a proprietary PB array descriptor.

                                I think that's in the help file somewhere. If it's not, well, trust me , PB compilers have worked like that since at least 1991, and I've used them all. (Even the 16-bit Windows compiler). (No longer available).

                                There is essentially zero chance any 'standard' function will want the address of a PB array descriptor. How you should read "array" parameters is to consider it a list of values laid end-to-end in contiguous memory. Using PB arrays, however, is a really good way to get a [generic] array of values into contiguous memory, end-to-end. (Now that I KNOW is in the help file).

                                MCM


                                Michael Mattias
                                Tal Systems (retired)
                                Port Washington WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                • #17
                                  Thanks Michael, sometimes it seems there's nothing PB related that you can't answer.

                                  George
                                  (heading back to the never-ending DLL interface port I'm on)

                                  Comment

                                  Working...
                                  X