;       SCCSID = @(#)d_enum.asm	6.1 91/02/15
;       SCCSID = @(#)d_enum.asm	6.2 90/01/22
; ****************************************************************************
; *									     *
; *			  IBM/Microsoft Confidential			     *
; *									     *
; *		    Copyright (c) IBM Corporation  1987, 1990		     *
; *		    Copyright (c) Microsoft Corp.  1987, 1990		     *
; *			      All Rights Reserved			     *
; *									     *
; ****************************************************************************
;***  D_ENUM.ASM - API stub routine DosEnumAttribute
;
;       Member of API library
;
;       library routine for API simulator
;
;       Called from dos 5.x and OS/2 applications
;
;       Special Information
;               none
;
;       Modification History
;

;/********************** START OF SPECIFICATIONS *********************/
;/*                                                                  */
;/* SUBROUTINE NAME: DosEnumAttribute                                */
;/*                                                                  */
;/* DESCRIPTIVE NAME: Dos Enumerate Attribute                        */
;/*                                                                  */
;/* FUNCTION: Enumerates extended attributes for a file              */
;/*                                                                  */
;/*                                                                  */
;/* NOTES:    Real Mode Only                                         */
;/*           Simulates OS/2 call from DOS 5.x environment           */
;/*                                                                  */
;/* ENTRY POINT: DosEnumAttribute                                    */
;/*    DosEnumAttribute(RefType, FileRef, EntryNum, EnumBuf,         */
;/*                 EnumBufSize, EnumCnt, InfoLevel, 0)              */
;/*                                                                  */
;/*                                                                  */
;/*    LINKAGE: Call Far                                             */
;/*                                                                  */
;/* INPUT: Stack Frame in form of:                                   */
;/*                                                                  */
;/*     PUSH  WORD   RefType - Type of reference                     */
;/*     PUSH@ OTHER  FileRef - Handle or name                        */
;/*     PUSH  DWORD  EntryNum - Starting entry in EA list            */
;/*     PUSH@ OTHER  EnumBuf - Data buffer                           */
;/*     PUSH  DWORD  EnumBufSize - Data buffer size                  */
;/*     PUSH@ DWORD  EnumCnt - Count of entries to return            */
;/*     PUSH  DWORD  InfoLevel - Level of information requested      */
;/*     PUSH  DWORD  0 - Reserved                                    */
;/*                                                                  */
;/* EXIT-NORMAL:   AX = 0                                            */
;/*                                                                  */
;/* EXIT-ERROR:    AX = Errorcode                                    */
;/*       may return error code from Dos 5.x, OS/2                   */
;/*                                                                  */
;/* EFFECTS:  AX, all other registers preserved                      */
;/*                                                                  */
;/* INTERNAL REFERENCES: none                                        */
;/*                                                                  */
;/*    ROUTINES: none                                                */
;/*                                                                  */
;/* EXTERNAL REFERENCES:                                             */
;/*                                                                  */
;/*    ROUTINES:                                                     */
;/*              __api_begin                                         */
;/*              __api_end                                           */
;/*              __api_getvrsn                                       */
;/*********************** END OF SPECIFICATIONS **********************/

include basemaca.inc
include dos2equ.inc
include error.inc
include api.inc

        EXTRN   __api_begin:near
        EXTRN   __api_end:near
        EXTRN   _api_getvrsn:near

        title   DOSENUMATTRIBUTE

_TEXT   segment byte public 'CODE'

        assume  CS:_TEXT, DS:nothing

        public  DOSENUMATTRIBUTE

RefType         equ     [bp + 34]
FileRef         equ     [bp + 30]
EntryNum        equ     [bp + 26]
EnumBuf         equ     [bp + 22]
EnumBufSize     equ     [bp + 18]
EnumCnt         equ     [bp + 14]
InfoLevel       equ     [bp + 10]
Reserved0       equ     [bp +  6]          ;@@ Reserved dword = 0


DOSENUMATTRIBUTE proc    far
; check validity of reserved words
        call    __api_begin     ; init bp and save bp,ds,bx,cx,dx,si,di,es
                                ; required to save: bp,ds,es,bx,cx,dx,di,si
        call    _api_getvrsn
        cmp     ax,0A14h        ; is it 10.20 or above, okay
        jae     chkRes
        cmp     ax,040Ah        ; is it below 4.10, not okay
        jb      deErr
        cmp     ax,0A00h        ; is it above 10.00, not okay
        ja      deErr

chkRes:
        mov     ax,ERROR_INVALID_PARAMETER ; Prepare error code
        mov     bx,Reserved0            ; reserved words not zeros
        or      bx,Reserved0+2
        jnz     enumret                 ; then return error

; set up for INT21

        push    ss                      ; pointer to ParmPkt
        pop     ds
        mov     si,bp                   ; offset of ParmPkt
        add     si,6
        mov     ah, D2_EnumExtAtt       ; enumerate extended attributes
        xor     al,al                   ; reserved
        int     21h
        jmp     enumret

deErr:
        mov     ax,ERROR_INVALID_FUNCTION ; Prepare error code

enumret:                                ; Invalid reserved word exit
        call    __api_end       ; check sigs & restore es,di,si,dx,cx,bx,ds,bp
        ret     30                      ; Return to User and Lose Parms

DOSENUMATTRIBUTE endp

_TEXT   ends

        end

