Annotation of os2sdk/demos/examples/infoseg/infoseg.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Example of DOSGETINFOSEG usage
        !             3:  *
        !             4:  * Gets the local and global data segments and displays some of their contents
        !             5:  *
        !             6:  * Copyright (C) Microsoft Corp. 1986
        !             7:  */
        !             8: 
        !             9: #include "doscalls.h"
        !            10: 
        !            11: struct gdtinfoarea{
        !            12:         unsigned long   time;
        !            13:         unsigned long   milliseconds;
        !            14:         unsigned char   hours;
        !            15:         unsigned char   minutes;
        !            16:         unsigned char   seconds;
        !            17:         unsigned char   hundreths;
        !            18:         unsigned        timezone;
        !            19:         unsigned        timer_interval;
        !            20:         unsigned char   day;
        !            21:         unsigned char   month;
        !            22:         unsigned        year;
        !            23:         unsigned char   day_of_week;
        !            24:         unsigned char   major_version;
        !            25:         unsigned char   minor_version;
        !            26:         unsigned char   revision_number;
        !            27:         unsigned char   current_screen_group;
        !            28:         unsigned char   max_num_of_screengrps;  
        !            29:         unsigned char   huge_selector_shift_count;
        !            30:         unsigned char   protect_mode_indicator;
        !            31:        unsigned        foreground_process_id;
        !            32:         unsigned char   dynamic_variation_flag;
        !            33:         unsigned char   maxwait;
        !            34:         unsigned        minimum_timeslice;
        !            35:         unsigned        maximum_timeslice;
        !            36:        unsigned        boot_drive;
        !            37:        unsigned char   reserved[32];
        !            38:  };
        !            39: 
        !            40: 
        !            41:  struct ldtinfoarea{
        !            42:         unsigned        current_process_pid;
        !            43:         unsigned        parent_pid;
        !            44:         unsigned        priority_of_current_thread;
        !            45:         unsigned        thread_id_of_current_thread;
        !            46:         unsigned        screen_group;
        !            47:         unsigned        subscreen_group;
        !            48:         unsigned        current_process_is_in_fg;
        !            49:  };
        !            50: 
        !            51: main()
        !            52: {
        !            53:        struct gdtinfoarea *gdt;
        !            54:        struct ldtinfoarea *ldt;
        !            55:        unsigned gdt_handle, ldt_handle;
        !            56:        
        !            57:        /* get the infoseg handles */
        !            58:        DOSGETINFOSEG(&gdt_handle, &ldt_handle);
        !            59:        
        !            60:        /* convert the handles into far pointers */
        !            61:        gdt = (struct gdtinfoarea *)((long)gdt_handle << 16);
        !            62:        ldt = (struct ldtinfoarea *)((long)ldt_handle << 16);
        !            63:        
        !            64:        /* display the contents of the segments */
        !            65:        printf("This is thread %u of process %u\n",
        !            66:                ldt->thread_id_of_current_thread,
        !            67:                ldt->current_process_pid);
        !            68:        printf("The current time is %u:%2u:%2u.%2u\n",
        !            69:                gdt->hours, gdt->minutes, gdt->seconds, gdt->hundreths);
        !            70: }

unix.superglobalmegacorp.com

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