Annotation of os2sdk/demos/examples/dynlink/dynlib.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * dynlib.c
        !             3:  *
        !             4:  *   Created 17 August 1987 by Kevin Ruddell for Microsoft Corp
        !             5:  *
        !             6:  * Dynamic link library demo module with non-shared data.
        !             7:  *
        !             8:  */
        !             9: 
        !            10: /*
        !            11:  * NB - The variable _acrtused must be declared in one of the modules of the
        !            12:  *     dll.  The C compiler generates this symbol as an extern to ensure
        !            13:  *     that the runtime library startup module crt0 will be pulled in by the
        !            14:  *     linker.  Declaring _acrtused will keep this unwanted code out.
        !            15:  *
        !            16:  * NB - To be made part of the named data segment, variables at the external
        !            17:  *     level must be declared static or they must be initialized or both.
        !            18:  *
        !            19:  */
        !            20: 
        !            21: /*
        !            22:  * NB - This version must be compiled with the -Asnu compiler option.
        !            23:  *     s => short code pointers
        !            24:  *     n => near data pointers
        !            25:  *     u => upon function entry, DS is saved, then made to point to the named
        !            26:  *          data segment.  DS is restored on exit from the function.
        !            27:  *
        !            28:  */
        !            29: 
        !            30: #include <doscalls.h>
        !            31: 
        !            32: int _acrtused=0;
        !            33: unsigned id=0;             /* process-unique identifier                     */
        !            34: unsigned far * pcount=0;    /* pointer to the shared process count          */
        !            35: 
        !            36: void far pascal            /* This routine is called during per-process     */
        !            37: init_id(pc)                /* initialization to pass the pointer to the     */
        !            38: unsigned far * pc;         /* shared count and to set the non-shared id.    */
        !            39: {
        !            40:     pcount = pc;
        !            41:     id = *pc;
        !            42: }
        !            43: 
        !            44: void far pascal            /* This routine is called by the process to show */
        !            45: printdata()                /* on the screen the current values of the       */
        !            46:                            /* non-shared id and the shared count.           */
        !            47: {
        !            48:     static char beg[]="I am number ";
        !            49:     static char mid[]=".  There are ";
        !            50:     static char end[]=" processes attached.\r";
        !            51:     char c;
        !            52:     int Written;
        !            53: 
        !            54:     DOSWRITE(1, beg, sizeof(beg)-1, &Written);
        !            55:     c = id + '0';
        !            56:     DOSWRITE(1, &c, sizeof(char), &Written);
        !            57:     DOSWRITE(1, mid, sizeof(mid)-1, &Written);
        !            58:     c = *pcount + '0';
        !            59:     DOSWRITE(1, &c, sizeof(char), &Written);
        !            60:     DOSWRITE(1, end, sizeof(end)-1, &Written);
        !            61: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.