home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 302.lha / Arp_Prog_v1.3 / Programmers_manual.pp / Programmers_manual
Text File  |  1980-12-03  |  18KB  |  595 lines

  1.  
  2.  
  3.  
  4.            AmigaDOS Replacement    Project    V1.1 (REL2)
  5.  
  6.  
  7.                  AmigaDOS Replacement
  8.                  Project V1.1 (REL2)
  9.  
  10.  
  11.                    ABSTRACT
  12.  
  13.  
  14.  
  15.       An overview of the new functions and support materials
  16.       available to programmers using ARP, including    a discussion
  17.       of calling arp.library from the C language.
  18.  
  19.  
  20.  
  21.       NOTE - THIS V1.1 MANUAL HAS BEEN INCLUDED WITH THE V1.3 ARP
  22.       PROGRAMMERS SUPPORT RELEASE UNMODIFIED.
  23.  
  24.       PLEASE SEE THE FILES IN THE SUBDIRECTORY "NEW_MANUAL" FOR
  25.       ALL FUNCTIONAL CHANGES FROM THE V1.1 RELEASE!
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.                  CONTENTS
  75.  
  76.        Current Status of ARP................................  1
  77.  
  78.        1.  Changes to old functions.............................  1
  79.        1.1    GADS()..........................................  1
  80.        1.2    FileRequest()...................................  1
  81.  
  82.        2.  New Functions........................................  2
  83.        2.1    Process    Control    and Resident....................  2
  84.        2.2    Date functions..................................  3
  85.        2.3    Misc functions..................................  3
  86.  
  87.        3.  Language Support.....................................  3
  88.        3.1    C Language Support..............................  4
  89.        3.2    Modula II support...............................  7
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.                   - i -
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.        ARP Prog    Manual       V1.1    Software (REL2)      February 27, 1988
  137.  
  138.  
  139.  
  140.        Current Status of ARP
  141.  
  142.        This release meets our first goal in producing ARP. It is
  143.        now possible for    users of the Amiga to work in a    practically
  144.        BCPL free environment, allowing programmers to write
  145.        software    free of    BCPL headaches.     This release of the
  146.        library (arp.library) introduces    what we    feel are important
  147.        advances    and standards for the Amiga, including new process
  148.        control functions and a resident    program    standard.  Old
  149.        functions have been enhanced, the GADS()    argument parser    now
  150.        supports    a new template type which allows the user to enter
  151.        any number of arguments,    and the    FileRequest() has been very
  152.        greatly enhanced, it now    sports a parent    gadget,    and
  153.        provides    much more programmer control than previously. It is
  154.        beautiful.
  155.  
  156.  
  157.        1.  Changes to old functions
  158.  
  159.        Only GADS() and FileRequest() received significant
  160.        enhancements.  Both of these are    completely compatible with
  161.        older code.
  162.  
  163.        1.1  GADS()
  164.  
  165.        The only    change to GADS() is the    introduction of    a new
  166.        template    type which allows any number of    arguments to be
  167.        placed on the command line.  It consists    of the usual slash
  168.        followed    by three periods (/...).  On return from GADS(),
  169.        the array element which corresponds to the multiarged type
  170.        will be a pointer to another array of character pointers    (
  171.        *(**char)) which    contain    the actual arguments entered by    the
  172.        user.  This array is guranteed to be null terminated.  See
  173.        the GADS    manual page for    more information.  Note    that the
  174.        ugly and    limited    ",,,," construct is still supported if you
  175.        are into    commas.
  176.  
  177.        1.2  FileRequest()
  178.  
  179.        FileRequest has been greatly enhanced and extended in this
  180.        release.     You can now alter FileRequest's window, add or
  181.        subtract    your own gadgets, handle gadget    events relating    to
  182.        your own    gadgets, and so    on.  The FileRequester structure
  183.        has been    changed, however old code using    the old
  184.        FileRequester structure will still work as long as you set
  185.        the old fr_Flags    variable to zero as warned.  See the
  186.        FileRequest() manual page and arpbase.[ih] for more
  187.        information.
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.                  Page 1
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.        ARP Prog    Manual       V1.1    Software (REL2)      February 27, 1988
  203.  
  204.  
  205.  
  206.        2.  New Functions
  207.  
  208.        Many new    functions have been added in this release. Perhaps
  209.        the most    important are the process control functions and    the
  210.        date functions.    The date functions support international
  211.        date formats for    both input and output, and were    provided by
  212.        Ken Salmon.
  213.  
  214.        2.1  Process Control and Resident
  215.  
  216.        arp.library now has a background    process    spawner    which
  217.        should eliminate    any future need    for programs to    call
  218.        Execute(). You can set many options with    this function
  219.        including stdio handles,    or you can specify a flag which
  220.        will create a new interactive environment for the process.
  221.        Note that this function creates new CLI style processes as
  222.        its default action, and it may be called    from Workbench
  223.        programs.  It also searches the Resident    list first, and    so
  224.        may be used to run multiple copies of the same code, and    it
  225.        automatically takes advantage of    stack settings using the
  226.        new ResidentProgramTag.
  227.  
  228.         The    spawner    will not execute BCPL programs.    This would
  229.        have been done if it were reasonably possible to    do so, but
  230.        it was not.  However, now that most of the ARP command
  231.        replacements are    done this should not be    an issue, since    any
  232.        disk which has arp.library will also have the command
  233.        replacements. The spawner will return an    error code to you,
  234.        at which    point you can inform the user, or attempt to
  235.        execute the BCPL    program    using Execute(), and all its
  236.        attendent problems.
  237.  
  238.         The    spawner    causes processes to automatically clean    up
  239.        after themselves, this includes closing all stdio handles
  240.        and freeing stack and possibly also data    memory,    if that    was
  241.        allocated by the    startup    code, so there is no reason for
  242.        your program to hang around waiting for child exits,
  243.        although    you can    if you wish to.     For more information, see
  244.        the ASyncRun() manual page.
  245.  
  246.        2.1.1  Resident programs     This release introduces a method
  247.        for creating shared text    processes on the Amiga.     The code
  248.        for these processes in the past has had to be reentrant,    and
  249.        that is still the simplest case.     ARP provides a    method for
  250.        specifying that a separate data segment should be allocated
  251.        if your program is resident, and    you can    then copy the data
  252.        to the new data segment,    and use    that, thus preserving a
  253.        clean slate for the next    execution.  The    compiler startup
  254.        code is responsible for initializing the    data segment.  This
  255.        was done    to keep    the support routines as    general    as
  256.        possible, the actual data copying is extremely short, as    a
  257.  
  258.  
  259.  
  260.                  Page 2
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.        ARP Prog    Manual       V1.1    Software (REL2)      February 27, 1988
  269.  
  270.  
  271.  
  272.        look at the arprescrt0.s    source will demonstrate.
  273.  
  274.         Users now have a program to    install    processes as
  275.        Resident    as well    as a program to    execute    these processes.
  276.        Hopefully more people will take advantage of the    new
  277.        resident    standard and write more    of this    low overhead
  278.        software.  For more informtion, see the manual page for
  279.        Resident    in the users manual, and the AddResidentPrg() and
  280.        LoadPrg() etc., functions in the    programmers manual.
  281.  
  282.        2.2  Date functions
  283.  
  284.        These date functions provide a method for converting between
  285.        AmigaDOS    datestamps and strings and vice-versa.    These
  286.        functions provide a wide    variety    of international date
  287.        format input and    output conversions. You    must specify the
  288.        conversion you want.  The ARP standard has been to accept
  289.        the value of the    dateformat environment variable    as set by
  290.        users. If this is undefined, default to the current AmigaDOS
  291.        convention.  You    must check this    variable yourself, the
  292.        StrtoStamp() and    StamptoStr() functions will not    do this    for
  293.        you.  For more information see the manual pages for these
  294.        two functions, as well as the DateTime struct in
  295.        arpbase.[ih].
  296.  
  297.        2.3  Misc functions
  298.  
  299.        The following utility functions have been added in V34:
  300.  
  301.       - PreParse() - prepare a string for PatternMatch()
  302.  
  303.       - LMult(), LDiv(), LMod() - LONG multiply divide and
  304.         modulus routines.
  305.  
  306.       - TackON() - add a filename to a pathname.
  307.  
  308.       - BaseName() - return    a pointer to the BaseName of a
  309.         PathName.
  310.  
  311.  
  312.        3.  Language Support
  313.  
  314.        Support is provided in the form of header files and linkable
  315.        libraries or pragma files for Aztec C, Lattice C    TDI Modula
  316.        II, and of course assembler.
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.                  Page 3
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.        ARP Prog    Manual       V1.1    Software (REL2)      February 27, 1988
  335.  
  336.  
  337.  
  338.        3.1  C Language Support
  339.  
  340.        Startup code which automatically    opens arp.library and
  341.        initializes IntuitionBase and GfxBase as    well as    ArpBase    is
  342.        provided    for both Lattice and Manx.  We have attempted to
  343.        keep filename conventions and header file proliferations    to
  344.        a minimum, and have succeeded pretty well so far, so the
  345.        discussion which    follows    applies    pretty well to both
  346.        compilers.  Differences are noted where they are
  347.        significant.  The general goals have been to minimize the
  348.        overall impact on the compiler user, and    to make    the code we
  349.        supply assemble/compile with the    usual tools provided by
  350.        each manufacturer.  So, for example, the    Manx code still
  351.        uses the    two functions cli_parse() and wb_parse() to do
  352.        pretty much the same things as they did before, while
  353.        Lattice code remains in _main().    Each compilers workbench
  354.        interface is unchanged, and the normal default CLI command
  355.        line processing should appear the same or very similar.
  356.  
  357.         The    differences are    mostly in the use of GADS() to do
  358.        CLI parsing, and    in the use of the ARP tracking functions to
  359.        allocate    memory,    although we also provide some resident
  360.        support code that provides very extended    capabilities.
  361.  
  362.        3.1.1  How to linkup with ARP  The easiest way to link up
  363.        with arp    is to use the arp 'wrapper' which we supply for
  364.        both Lattice and    Manx compilers.     This code opens
  365.        arp.library, and    initializes GfxBase and    IntuitionBase as
  366.        valid pointers from the values in ArpBase.  To use this ARP
  367.        wrapper,    simply link with arp.lib (Lattice users    should also
  368.        use the arpc.o instead of the usual c.o as the first module
  369.        in their    blink command lines), and then with your compiler
  370.        libraries.  Here    are sample link    lines for Manx and Lattice:
  371.  
  372.        ln program.o -larp -lc
  373.  
  374.        blink arpc.o prog.o to prog lib arp.lib lc.lib amiga.lib
  375.  
  376.        If you prefer to    use the    OpenLibrary() call, then instead of
  377.        the above command lines,    simply include the library file
  378.        a.lib in    your usual link    command    line.
  379.  
  380.        3.1.2  GADS  The    use of GADS() to handle    the program
  381.        arguments from the CLI command line introduces some
  382.        differences.  argc will be the number of    arguments actually
  383.        entered,    and argv[0] will be the    program    name, as usual,    but
  384.        the actual arguments may    or may not be in successive array
  385.        positions in argv, and the actual element in the    argv array
  386.        may be a    boolean    value (if a /S was used), a pointer to
  387.        character (as usual) or itself the base of another argv
  388.        style array (if the new /... template type is used).  (The
  389.  
  390.  
  391.  
  392.                  Page 4
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.        ARP Prog    Manual       V1.1    Software (REL2)      February 27, 1988
  401.  
  402.  
  403.  
  404.        default template, which consists    simply of a series of
  405.        commas, does provide for    standard C processing of command
  406.        line arguments.)
  407.  
  408.         To supply your own template, set the global    variable
  409.        CLI_Template to point to    the string containing your
  410.        template.  You can provide an extended help message by
  411.        setting the global variable CLI_Help to what you    wish to
  412.        display if the user asks    for more help:
  413.  
  414.        char    *CLI_Template =    "FROM/A,TO,OPT/K";
  415.        char    *CLI_Help = "This is an    extra help string";
  416.  
  417.        See the GADS manual page    and some of the    short example
  418.        programs    in the demos directory.     Note that you will not    get
  419.        error returns from GADS() using the default startup code,
  420.        the startup code    handles    those on its own, displaying the
  421.        GADS() error message and    aborting the program.
  422.  
  423.        3.1.3  Exiting under ARP     It is *not* recommended that you
  424.        call the    ArpExit() function from    C, this    could possibly
  425.        bypass allocations that your compiler library has made on
  426.        your behalf, and    cause problems with open files or
  427.        unreleased memory. The recommended way to exit from a
  428.        program using ARP, whether or not you are using the supplied
  429.        startup code, is    to use exit() or to simply fall    off the    end
  430.        of the world.  If you are not using the arp startup code    you
  431.        should first CloseLibrary(ArpBase), if you are using the    arp
  432.        startup code you    should not CloseLibrary(ArpBase).
  433.  
  434.        3.1.4  Availabilty of source  All the source code to the
  435.        startup code is provided, so you    can see    exactly    what it
  436.        does and    modify it should you need to.  In each case it was
  437.        assembled using the native tools    supplied by the
  438.        manufacturer.
  439.  
  440.        3.1.5  Creating shared text (resident) programs in C  At    the
  441.        time this is written we still have not been able    to
  442.        succesfully assemble resident startup code for Lattice.
  443.        This appears to be a limitation of the lattice supplied asm.
  444.        The lattice compiler is very capable of taking advantage    of
  445.        this, and lattice has been very helpful,    but we still do    not
  446.        have the    support    for resident code and Lattice.
  447.  
  448.         Manx users can take    advantage of the shared    code and
  449.        stack setting capabilities of the resident code standard    as
  450.        follows.
  451.  
  452.       - 1) Use the +b option to the    C compiler for all the
  453.         modules in the program.
  454.  
  455.  
  456.  
  457.  
  458.                  Page 5
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.        ARP Prog    Manual       V1.1    Software (REL2)      February 27, 1988
  467.  
  468.  
  469.  
  470.       - 2) You must    use the    rstart.o or rstart32.o as the first
  471.         module in your linker command line,    and you    should also
  472.         link with res.lib or res32.lib.
  473.  
  474.        The default stack has been set to 10240 for the rstart
  475.        modules.     If this is too    high or    too low, you can change    the
  476.        arprescrt0.s file and reassemble.  Manx has promised support
  477.        for the ARP resident standard with their    4.0 release, but
  478.        currently the only way to set the stack is to reassemble.
  479.  
  480.        3.1.5.1    Programming using Resident  You    do not have to
  481.        write re-entrant    code using the ARP resident standard.
  482.        arp.library and the startup code    cooperate to make copies of
  483.        your data and bss segments, so you may feel free    to alter
  484.        static global data without being    concerned about    not being
  485.        able to be resident.  The only problems that you    are likely
  486.        to have involve pre-compiled references from data to data,
  487.        and only    if these are not read-only.
  488.  
  489.         As an example, consider the    following:
  490.  
  491.        BYTE    buffer1[100];
  492.        BYTE    buffer2[100];
  493.  
  494.        struct b {
  495.            BYTE *b1, *b2;
  496.        };
  497.  
  498.        struct b example = {
  499.            &buffer[0],
  500.            &buffer[1]
  501.        };
  502.  
  503.        In the above example, the references to buffer[0] and
  504.        buffer[1] in struct b are a reference from data (the struct
  505.        b data) back to other data (the buffer data).  When these
  506.        data references are cloned by the resident startup code,
  507.        they will still refer to    the same memory    location, they are
  508.        not relocated.  That means that any writes to buffer[0] or
  509.        buffer[1] using the addresses stored in the structure will
  510.        change the original copy    of the data, and therefore result
  511.        in a checksum error being reported the next time    the
  512.        resident    program    is run.
  513.  
  514.         The    solution to this is to perform run-time
  515.        initialization of data such as this.  Note that this applies
  516.        only to data that is going to be    written. Data which is not
  517.        altered is data you don't have to worry about at    all.  The
  518.        most likely candidates for run-time initialization in Amiga
  519.        programs    are MenuItem structures    and Menu structures.  I
  520.        have my own version of the MicroEmacs that has been floating
  521.  
  522.  
  523.  
  524.                  Page 6
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.        ARP Prog    Manual       V1.1    Software (REL2)      February 27, 1988
  533.  
  534.  
  535.  
  536.        around which uses Amiga windows and menus, and is not at    all
  537.        careful about altering static data.  I converted    this to    run
  538.        resident    using only four    loops (one for each menu) in about
  539.        a half an hour.    Now each invocation of the Editor uses only
  540.        4000 bytes of stack (instead of the 20000 I use at the CLI),
  541.        and it uses no more memory for its code,    either in a ramdisk
  542.        or in memory.  Since the    actual program is 35,644 bytes,    I
  543.        save about 50,000 bytes each time the program is    invoked.
  544.        Not bad for a half an hours work.
  545.  
  546.         You    can tell if you    are running as a resident launched
  547.        program if you examine the global long __fromdisk__.  This
  548.        variable    will be    non-zero (-1) when you are not resident.
  549.  
  550.        3.2  Modula II support
  551.  
  552.        We have not yet received    a Modula II support package from
  553.        anyone.    No one directly    involved with ARP speaks Modula    II,
  554.        so we are dependent on contributors for support for this
  555.        language.  The MII support materials we do provide are from
  556.        the first release, and cover only the first release
  557.        functions.  These were contributed by Martin Taillefer.
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.                  Page 7
  591.  
  592.  
  593.  
  594.  
  595.