     1                                  ;TITLE	EXTATTR- Extended Attributes
     2                                  ;NAME	EXTATTR
     3                                  ;
     4                                  ; Get or Set Extended Attributes by handle
     5                                  ;
     6                                  ;
     7                                  ;   GetSetEA
     8                                  ;   Set_Output
     9                                  ;   Search_EA
    10                                  ;   Copy_QEA
    11                                  ;   Set_one_EA
    12                                  ;   Get_one_EA
    13                                  ;   Get_Value
    14                                  ;   GSetDevCdpg
    15                                  ;   Get_max_EA_size
    16                                  ;
    17                                  ;   Revision history
    18                                  ;
    19                                  ;	   A000   version 4.00  Jan. 1988
    20                                  ;
    21                                  ;
    22                                  ;
    23                                  ;
    24                                  ;
    25                                  ;
    26                                  ;
    27                                  
    28                                  [list -]
    28          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <3> [list -]
     3                              <2> 
     4                              <2> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <2> ; (no prior section) ; DOSSTART		ENDS
     6                              <2> 
     7                              <2> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <2> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <2> 
    10                              <2> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <2> ; (no prior section) ; CONSTANTS	ENDS
    12                              <2> 
    13                              <2> addsection DATA, align=2 PUBLIC class=DATA
    14                              <2> ; (no prior section) ; DATA		ENDS
    15                              <2> 
    16                              <2> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <2> ; (no prior section) ; TABLE		ENDS
    18                              <2> 
    19                              <2> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <2> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <2> 
    22                              <2> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <2> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <2> 
    25                              <2> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <2> 
    27                              <2> addsection LAST, align=16 PUBLIC class=LAST
    28                              <2> ; (no prior section) ; LAST		ENDS
    29                              <2> 
    30                              <2> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <1> 
     9                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
    10                              <1> 
    11                              <1> section LAST
    12                              <1> ; (no prior section) ; LAST		ENDS
    34                                  
    35                                  [list +]
    36                                  section DOSCODECODE
    37                                  [list -]
    37          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    37          ******************       warning: out: BPB.INC... [-w+user]
    37          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    37          ******************       warning: out: DEVSYM.INC... [-w+user]
    45                                  ;.sall
    46                                  
    47                                  
    48                                  ;	I_need	XA_from,BYTE		;AN000;
    49                                  
    50                                  ;	I_need	XA_TABLE,BYTE		;AN000;
    51                                  ;	I_need	XA_TEMP,WORD		;AN000;
    52                                  ;	I_need	XA_COUNT,WORD		;AN000;
    53                                  ;	I_need	XA_DEVICE,BYTE		;AN000;
    54                                  	I_need	XA_TYPE,BYTE		;AN000;
    55                                  	I_need	SAVE_ES,WORD		;AN000;
    56                                  	I_need	SAVE_DI,WORD		;AN000;
    57                                  	I_need	SAVE_DS,WORD		;AN000;
    58                                  	I_need	SAVE_SI,WORD		;AN000;
    59                                  	I_need	SAVE_CX,WORD		;AN000;
    60                                  	I_need	SAVE_BX,WORD		;AN000;
    61                                  ;	I_need	XA_handle,WORD		;AN000;
    62                                  ;	I_need	CPSWFLAG,BYTE		;AN000;
    63                                  ;	I_need	XA_PACKET,BYTE		;AN000;
    64                                  ;	I_need	MAX_EA_SIZE,WORD	;AN000;
    65                                  ;	I_need	MAX_EANAME_SIZE,WORD	;AN000;
    66                                  ;	I_need	THISSFT,DWORD		;AN000;
    67                                  ;IF DBCS				;AN000;
    68                                  ;	I_need	DBCS_PACKET,BYTE	;AN000; 				;AN000;
    69                                  ;ENDIF					;AN000; 				;AN000;
    70                                  										;AN000;
    71                                  										;AN000;
    72                                  										;AN000;
    73                                  										;AN000;
    74                                  										;AN000;
    75                                  BREAK <GetSet_EA get or set extended attributes by handle>			;AN000;
    76                                  										;AN000;
    77                                  ;      Input: [XA_type] = function code, (e.g., get,set)			;AN000;
    78                                  ;	      [ThisSFT] points to SFT						;AN000;
    79                                  ;	      ES:BP points to drive parameter block				;AN000;
    80                                  ;	      [XA_from] = By_Create or By_EA					;AN000;
    81                                  ;	      [SAVE_ES]:[SAVE_DI]  points to get/set list			;AN000;
    82                                  ;	      [SAVE_DS]:[SAVE_SI]  points to get query list			;AN000;
    83                                  ;	      [SAVE_CX] = size of buffer
    84                                  ;	      [XA_device]= 1 device, 0 file					;AN000;
    85                                  ;	      [XA_handle] for device						;AN000;
    86                                  ;	Function: Get or Set extended attributes by handle			;AN000;
    87                                  ;	Output: carry set: error						;AN000;
    88                                  ;		carry clear: extended attributes are successfully get/set	;AN000;
    89                                  ;			     extended attribute cluster may be created		;AN000;
    90                                  ;										;AN000;
    91                                  ;										;AN000;
    92                                  ;										;AN000;
    93                                  										;AN000;
    94                                  										;AN000;
    95                                  procedure   GetSet_XA,near					   ;AN000;
    95          ******************       warning: proc GetSet_XA... [-w+user]
    96                                  	ASSUME	DS:NOTHING,ES:NOTHING,SS:DOSGROUP
    97                                  
    98                                  
    99 00000000 36C43E[0000]            	LES    DI,[ss:SAVE_DI]  ;AN000;;FT. ES:DI -> query list
   100                                  ;;	MOV    [SAVE_BX],2	       ;AN000;;FT. size returned
   101                                  ;;	XOR    DX,DX		       ;AN000;;FT. dx=0, codepage id
   102                                  
   103                                  XA_type equ XA_TYPE	; NASM port label
   104 00000005 36803E[0000]02          	CMP    byte [ss:XA_type],2	       ;AN000;;FT. get EA  ?
   105 0000000B 7526                    	JNZ    eaname		       ;AN000;;FT. no
   106                                  getEAs: 			       ;AN000;
   107 0000000D 36833E[0000]00          	CMP    word [ss:SAVE_CX],0	       ;AN000;;FT. get max data size
   108 00000013 7508                    	JNZ    notmax		       ;AN000;;FT. no
   109                                  ;;	CALL   Get_max_EA_size	       ;AN000;;FT.
   110                                  
   111 00000015 B90200                  	MOV    CX,2		       ;AN000;;FT. FAKE FAKE..............
   112 00000018 732F                    	JNC    set_user_cx	       ;AN000;;FT.
   113 0000001A EB39                    	JMP    OKexit		       ;AN000;;FT. error
   114 0000001C 90                      	nop	; identicalise
   115                                  notmax:
   116 0000001D 36833E[0000]01          	CMP    word [ss:SAVE_CX],1	       ;AN000;;FT. buffer size =1   ?
   117 00000023 7503                    	JNZ    goodsiz		       ;AN000;;FT. no
   118                                  extattr_errout:			       ;AN000;
   119 00000025 EB2E                    	JMP    insuff_space	       ;AN000;;FT. no error
   120 00000027 90                      	nop	; identicalise
   121                                  goodsiz:			       ;AN000;
   122 00000028 26C7050000              	MOV    WORD PTR [ES:DI],0      ;AN000;FT. FAKE FAKE ...............
   123 0000002D B90200                  	MOV    CX,2		       ;AN000;FT. FAKE FAKE ...............
   124 00000030 EB17                    	JMP    set_user_cx	       ;AN000;FT. FAKE FAKE ...............
   125 00000032 90                      	nop	; identicalise
   126                                  
   127                                  ;	SUB    [SAVE_CX],2	       ;AN000;;FT. minus count size
   128                                  ;	CMP    [SAVE_SI],-1	       ;AN000;;FT. get all ?
   129                                  ;	JNZ    getsome		       ;AN000;;FT. no
   130                                  ;	PUSH   CS		       ;AN000;;FT. ds:si-> EA entry addr
   131                                  ;	POP    DS		       ;AN000;;FT.
   132                                  ;	INC    DI		       ;AN000;;FT.
   133                                  ;	INC    DI		       ;AN000;;FT. es:di -> address after count
   134                                  ;	MOV    SI,OFFSET XA_TABLE wrt DOSGROUP  ;AN000;FT.
   135                                  ;	MOV    CX,XA_COUNT	       ;AN000;;FT. cx= number of EA entries
   136                                  ;;;;;;
   137                                  ;getone:
   138                                  ;	CALL   GET_ONE_EA	       ;AN000;;FT. get EA
   139                                  ;	JC     setout		       ;AN000;;FT. insufficient memory
   140                                  ;	INC    DX		       ;AN000;;FT. next EA ID
   141                                  ;	LOOP   getone		       ;AN000;;FT. next one
   142                                  ;setout:			       ;AN000;
   143                                  ;	CALL   Set_Output	       ;AN000;;FT.
   144                                  ;	OR     CX,CX		       ;AN000;;FT.
   145                                  ;	JNZ    extattr_errout	       ;AN000;;FT.
   146                                  ;
   147                                  ;	JMP    OKexit		       ;AN000;;FT.
   148                                  eaname:
   149 00000033 36803E[0000]03          	CMP    byte [ss:XA_type],3	       ;AN000;;FT. get EA name?`
   150 00000039 7403                    	JZ     geteaname	       ;AN000;;FT. yes
   151 0000003B EB15                    	JMP    setea		       ;AN000;;FT.
   152 0000003D 90                      	nop	; identicalise
   153                                  geteaname:
   154                                  ;	MOV    [SAVE_SI],-1	       ;AN000;;FT. make get all
   155 0000003E 36833E[0000]00          	CMP    word [ss:SAVE_CX],0	       ;AN000;;FT. get max data size
   156 00000044 75D7                    	JNZ    notmax		       ;AN000;;FT. no
   157 00000046 B90200                  	MOV    CX,2		       ;AN000;;FT. FAKE FAKE ......................
   158                                  ;;	MOV    CX,[MAX_EANAME_SIZE]    ;AN000;;FT. get name size
   159                                  set_user_cx:			       ;AN000;
   160 00000049 E8(0000)                	invoke get_user_stack	       ;AN000;;FT. get user stack
   161 0000004C 894C04                  	MOV    [SI + user_CX],CX	       ;AN000;;FT.
   162 0000004F EB04                    	JMP    OKexit		       ;AN000;;FT. exit
   163 00000051 90                      	nop	; identicalise
   164                                  
   165                                  getsome:			       ;AN000;
   166                                  ;	LDS    SI,DWORD PTR [SAVE_SI]  ;AN000;;FT.
   167                                  ;	LODSW			       ;AN000;;FT.
   168                                  ;	MOV    CX,AX		       ;AN000;;FT. cx=number of query entries
   169                                  ;	JCXZ   setout		       ;AN000;;FT. yes
   170                                  ;	STOSW			       ;AN000;;FT. es:di -> EA
   171                                  ;get_next_EA:			       ;AN000;
   172                                  ;	PUSH   DS		       ;AN000;;FT. save ds:si
   173                                  ;	PUSH   SI		       ;AN000;;FT.	es:di
   174                                  ;	PUSH   ES		       ;AN000;;FT.
   175                                  ;	PUSH   DI		       ;AN000;;FT.
   176                                  ;	CALL   Search_EA	       ;AN000;;FT. search query EA from table
   177                                  ;	JC     EAnotFound	       ;AN000;;FT. EA not found
   178                                  ;	PUSH   ES		       ;AN000;;FT.
   179                                  ;	POP    DS		       ;AN000;;FT.
   180                                  ;	MOV    SI,DI		       ;AN000;;FT. ds:si -> found EA
   181                                  ;	POP    DI		       ;AN000;;FT. es:di -> buffer
   182                                  ;	POP    ES		       ;AN000;;FT.
   183                                  ;	CALL   GET_ONE_EA	       ;AN000;;FT. copy to buffer
   184                                  ;	POP    SI		       ;AN000;;FT.
   185                                  ;	POP    DS		       ;AN000;;FT.
   186                                  ;	JC     setfinal 	       ;AN000;;FT. memory not enough
   187                                  ;	MOV    AL,[SI.QEA_NAMELEN]     ;AN000;;FT.
   188                                  ;	XOR    AH,AH		       ;AN000;;FT.
   189                                  ;	ADD    AX,QEA_NAME	       ;AN000;;FT.
   190                                  ;	ADD    SI,AX		       ;AN000;;FT. ds:si -> next query entry
   191                                  ;testend:			       ;AN000;
   192                                  ;	LOOP   get_next_EA	       ;AN000;;FT. do next
   193                                  ;setfinal:			       ;AN000;
   194                                  ;	LDS    SI,DWORD PTR [SAVE_SI]  ;AN000;;FT.
   195                                  ;	MOV    DX,[SI]		       ;AN000;;FT.
   196                                  ;	SUB    DX,CX		       ;AN000;;FT. dx= returned count
   197                                  ;	JMP    setout		       ;AN000;;FT.
   198                                  ;EAnotFound:			       ;AN000;
   199                                  ;	POP    DI		       ;AN000;;FT. restore regs
   200                                  ;	POP    ES		       ;AN000;;FT.
   201                                  ;	POP    SI		       ;AN000;;FT.
   202                                  ;	POP    DS		       ;AN000;;FT.
   203                                  ;
   204                                  ;	CALL   COPY_QEA 	       ;AN000;;FT. copy query EA to buffer
   205                                  ;	JC     setfinal 	       ;AN000;;FT. not enough memory
   206                                  ;	JMP    testend		       ;AN000;;FT.
   207                                  setea:				       ;AN000;
   208 00000052 EB01                    	JMP    OKexit		       ;AN000;;FT. FAKE FAKE ..........
   209 00000054 90                      	nop	; identicalise
   210                                  ;	LDS    SI,DWORD PTR [SAVE_DI]  ;AN000;;FT.
   211                                  ;	LODSW			       ;AN000;;FT.
   212                                  ;	MOV    CX,AX		       ;AN000;;FT. cx=number of query entries
   213                                  ;	OR     CX,CX		       ;AN000;;FT. cx=0 ?
   214                                  ;	JZ     OKexit		       ;AN000;;FT. yes
   215                                  ;set_next:			       ;AN000;
   216                                  ;	CALL   Search_EA	       ;AN000;;FT.
   217                                  ;	JNC    toset		       ;AN000;;FT.
   218                                  ;set_reason:			       ;AN000;
   219                                  ;	CLC			       ;AN000;;FT. clear acrry
   220                                  ;	MOV    [SI.EA_RC],AL	       ;AN000;;FT. set reason code
   221                                  ;	DEC    CX		       ;AN000;;FT. end of set ?
   222                                  ;	JZ     OKexit		       ;AN000;;FT. yes
   223                                  
   224                                  ;	MOV    AL,[SI.EA_NAMELEN]      ;AN000;;FT.
   225                                  ;	XOR    AH,AH		       ;AN000;;FT.
   226                                  ;	ADD    AX,[SI.EA_VALLEN]       ;AN000;;FT.
   227                                  ;	ADD    SI,EA_NAME	       ;AN000;;FT.
   228                                  ;	ADD    SI,AX		       ;AN000;;FT. es:di -> next EA entry
   229                                  ;	JMP    set_next 	       ;AN000;;FT.
   230                                  ;toset: 			       ;AN000;
   231                                  ;	CALL   SET_ONE_EA	       ;AN000;;FT. set it
   232                                  ;	JMP    set_reason	       ;AN000;;FT.
   233                                   insuff_space:			       ;AN000;;FT.
   234                                  ;	MOV    AX,error_not_enough_memory	 ;AN000;FT. insufficient memory err
   235                                  ;	STC					 ;AN000;
   236                                  OKexit: 					 ;AN000;
   237 00000055 C3                      	return					 ;AN000;
   238                                  
   239                                  EndProc GetSet_XA				 ;AN000;
   240                                  
   241                                  
   242                                  ; Input: [SAVE_ES]:[SAVE_DI] points to buffer
   243                                  ;	 [SAVE_BX]= returned size
   244                                  ;	 DX= returned count
   245                                  ; Function: set returned size and count 					;AN000;
   246                                  ; Output: none
   247                                  										;AN000;
   248                                  ;procedure   Set_Output,NEAR							 ;AN000;
   249                                  ;	ASSUME	CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:DOSGROUP			;AN000;
   250                                  ;										;AN000;
   251                                  ;	LES    DI,DWORD PTR [SAVE_DI]  ;FT. es:di -> count			;AN000;
   252                                  ;	MOV    [ES:DI],DX	       ;FT.					;AN000;
   253                                  ;	MOV    BX,[SAVE_BX]	       ;FT. cx=size returned			;AN000;
   254                                  ;	invoke get_user_stack	       ;FT. get user stack			;AN000;
   255                                  ;	MOV    [SI.user_CX],BX	       ;FT.					;AN000;
   256                                  ;	return			       ;FT.					;AN000;
   257                                  ;										;AN000;
   258                                  ;EndProc Set_Output								 ;AN000;
   259                                  
   260                                  
   261                                  ; Input: DS:SI= query EA addr							;AN000;
   262                                  ; Function: search the EA							;AN000;
   263                                  ; Output: carry clear
   264                                  ;	 DX= EA ID (0 codpage, 1  Filetype, etc.)
   265                                  ;	 ES:DI points to found entry
   266                                  ;	  carry set, not found, AL= reason code 				;AN000;
   267                                  										;AN000;
   268                                  ;procedure   Search_EA,NEAR							 ;AN000;
   269                                  ;	ASSUME	CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:DOSGROUP			;AN000;
   270                                  ;										;AN000;
   271                                  ;	PUSH   CX				 ;FT. save entry count		;AN000;
   272                                  ;	MOV    AL,EARCNOTFOUND			 ;FT. preset error code 	;AN000;
   273                                  ;	MOV    BL,[SI.QEA_NAMELEN]		 ;FT.	     ?			;AN000;
   274                                  ;	CMP    [XA_TYPE],4			 ;FT. set    ?			;AN000;
   275                                  ;	JNZ    gettyp				 ;FT. no			;AN000;
   276                                  ;	MOV    BL,[SI.EA_NAMELEN]		 ;FT.	     ?			;AN000;
   277                                  ;gettyp:
   278                                  ;	OR     BL,BL				 ;FT.				;AN000;
   279                                  ;	JZ     not_found			 ;FT.				;AN000;
   280                                  ;	PUSH   CS				 ;FT. ds:si-> EA entry addr	;AN000;
   281                                  ;	POP    ES				 ;FT.				;AN000;
   282                                  ;	MOV    DI,OFFSET XA_TABLE wrt DOSGROUP	 ;FT.				;AN000;
   283                                  ;	MOV    CX,XA_COUNT			 ;FT. cx= number of EA entries	;AN000;
   284                                  ;	XOR    DX,DX				 ;FT. dx=0, codepage id 	;AN000;
   285                                  ;
   286                                  ;start_find:
   287                                  ;	PUSH   CX				 ;FT. save entry count		;AN000;
   288                                  ;	MOV    CL,BL				 ;FT.				;AN000;
   289                                  ;	XOR    CH,CH				 ;FT. get name len		;AN000;
   290                                  ;	PUSH   SI				 ;FT.				;AN000;
   291                                  ;	PUSH   DI				 ;FT.				;AN000;
   292                                  ;	CMP    [XA_TYPE],4			 ;FT. set    ?			;AN000;
   293                                  ;	JNZ    gettyp2				 ;FT. no			;AN000;
   294                                  ;	ADD    SI,EA_NAME			 ;FT.				;AN000;
   295                                  ;	JMP    short updi			 ;FT.				;AN000;
   296                                  ;gettyp2:
   297                                  ;	ADD    SI,QEA_NAME			 ;FT. compare EA names		;AN000;
   298                                  ;updi:
   299                                  ;	ADD    DI,EA_NAME			 ;FT.				;AN000;
   300                                  ;	REP    CMPSB				 ;FT.				;AN000;
   301                                  ;	POP    DI				 ;FT.				;AN000;
   302                                  ;	POP    SI				 ;FT.				;AN000;
   303                                  ;	POP    CX				 ;FT.				;AN000;
   304                                  ;	JNZ    not_matched			 ;FT. name not matched		;AN000;
   305                                  ;	MOV    AL,EARCDEFBAD			 ;FT. preset error code 	;AN000;
   306                                  ;	PUSH   SI				 ;FT.				;AN000;
   307                                  ;	PUSH   DI				 ;FT.				;AN000;
   308                                  ;	CMPSB					 ;FT. compare type		;AN000;
   309                                  ;	JNZ    not_matched2			 ;FT. type not matched		;AN000;
   310                                  ;	CMPSW					 ;FT. compare flags		;AN000;
   311                                  ;	JNZ    not_matched2			 ;FT. flag not matched		;AN000;
   312                                  ;	POP    DI				 ;FT.				;AN000;
   313                                  ;	POP    SI				 ;FT. found one 		;AN000;
   314                                  ;	JMP    SHORT found_one			 ;FT.				;AN000;
   315                                  ;not_matched:
   316                                  ;	DEC    CX				 ;FT. end of table		;AN000;
   317                                  ;	JZ     not_found			 ;FT. yes			;AN000;
   318                                  ;	MOV    AL,[ES:DI.EA_NAMELEN]		 ;FT.				;AN000;
   319                                  ;	XOR    AH,AH				 ;FT.				;AN000;
   320                                  ;
   321                                  ;	ADD    DI,EA_NAME			 ;FT.				;AN000;
   322                                  ;	ADD    DI,AX				 ;FT. es:di -> next EA entry	;AN000;
   323                                  ;	INC    DX				 ;FT. increment EA ID		;AN000;
   324                                  ;	JMP    start_find			 ;FT.				;AN000;
   325                                  ;not_matched2:
   326                                  ;	POP    DI				 ;FT.				;AN000;
   327                                  ;	POP    SI				 ;FT.				;AN000;
   328                                  ;	JMP    not_matched			 ;FT.				;AN000;
   329                                  ;not_found:
   330                                  ;	STC					 ;FT.				;AN000;
   331                                  ;found_one:
   332                                  ;	POP    CX				 ;FT.				;AN000;
   333                                  ;	return					 ;FT.				;AN000;
   334                                  										;AN000;
   335                                  ;EndProc Search_EA								 ;AN000;
   336                                  										;AN000;
   337                                  ; Input: ES:DI= buffer address							;AN000;
   338                                  ;	 DS:SI= EA entry address
   339                                  ;	 [SAVE_CX]= buffer size
   340                                  ;	 AL = reason code
   341                                  ; Function: move one query entry to buffer					;AN000;
   342                                  ; Output: carry clear
   343                                  ;	    DS:SI points to next entry
   344                                  ;	    ES:DI points to next entry
   345                                  ;	    [SAVE_CX],[SAVE_BX], updated					       ;AN000;
   346                                  ;	  carry set, insufficient memory error					;AN000;
   347                                  										;AN000;
   348                                  ;procedure   COPY_QEA,NEAR							 ;AN000;
   349                                  ;	ASSUME	CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:DOSGROUP			;AN000;
   350                                  ;										;AN000;
   351                                  ;	PUSH   CX				 ;FT.				;AN000;
   352                                  ;	MOV    DL,AL				 ;FT.				;AN000;
   353                                  ;	MOV    CX,EA_NAME -EA_TYPE		 ;FT.				;AN000;
   354                                  ;
   355                                  ;	MOV    BL,[SI.QEA_NAMELEN]		 ;FT.				;AN000;
   356                                  ;	XOR    BH,BH				 ;FT.				;AN000;
   357                                  ;	ADD    CX,BX				 ;FT. cx= query EA size 	;AN000;
   358                                  ;	CMP    CX,[SAVE_CX]			 ;FT. > buffer size		;AN000;
   359                                  ;	JA     sizeshort2			 ;FT. yes			;AN000;
   360                                  ;	PUSH   CX				 ;FT.				;AN000;
   361                                  ;	LODSB					 ;FT. move type 		;AN000;
   362                                  ;	STOSB					 ;FT.				;AN000;
   363                                  ;	LODSW					 ;FT.				;AN000;
   364                                  ;	STOSW					 ;FT. move flag 		;AN000;
   365                                  ;	MOV    AL,DL				 ;FT. move RC			;AN000;
   366                                  ;	STOSB					 ;FT.				;AN000;
   367                                  ;
   368                                  ;	LODSB					 ;FT. move name len		;AN000;
   369                                  ;	MOV    CL,AL				 ;FT.				;AN000;
   370                                  ;	STOSB					 ;FT.				;AN000;
   371                                  ;	XOR    AX,AX				 ;FT. zero value length 	;AN000;
   372                                  ;	STOSW					 ;FT.				;AN000;
   373                                  ;	OR     CL,CL				 ;FT.				;AN000;
   374                                  ;	JZ     zeroname 			 ;FT.				;AN000;
   375                                  ;	XOR    CH,CH				 ;FT.				;AN000;
   376                                  ;
   377                                  ;	REP    MOVSB				 ;FT. move EA to buffer 	;AN000;
   378                                  ;zeroname:
   379                                  ;	POP    CX				 ;FT.				;AN000;
   380                                  ;	ADD    [SAVE_BX],CX			 ;FT. bx=bx+entry size		;AN000;
   381                                  ;	SUB    [SAVE_CX],CX			 ;FT. update buffer size	;AN000;
   382                                  ;	CLC					 ;FT.				;AN000;
   383                                  ;	JMP    SHORT okget2			 ;FT.				;AN000;
   384                                  ;
   385                                  ;sizeshort2:
   386                                  ;	MOV    AX,error_not_enough_memory	 ;FT.  error			;AN000;
   387                                  ;	STC					 ;FT.				;AN000;
   388                                  ;okget2:
   389                                  ;	POP    CX				 ;FT.				;AN000;
   390                                  ;	return				    ;FT.				;AN000;
   391                                  ;										;AN000;
   392                                  ;EndProc COPY_QEA								 ;AN000;
   393                                  										;AN000;
   394                                  ; Input: ES:DI= found EA entry addr						;AN000;
   395                                  ;	 DS:SI= source EA entry address
   396                                  ;	 DX= EA ID (0 codpage, 1  Filetype, etc.)
   397                                  ; Function: set one EA								;AN000;
   398                                  ; Output: carry clear
   399                                  ;	    EA set
   400                                  ;	  carry set, AL= reason code						;AN000;
   401                                  										;AN000;
   402                                  ;procedure   SET_ONE_EA,NEAR							 ;AN000;
   403                                  ;	ASSUME	CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:DOSGROUP			;AN000;
   404                                  ;										;AN000;
   405                                  ;	PUSH   CX				 ;FT.				;AN000;
   406                                  ;	MOV    AL,EARCDEFBAD			 ;FT.  prseet error code	;AN000;
   407                                  ;	MOV    BX,[SI.EA_VALLEN]		 ;FT.				;AN000;
   408                                  ;	CMP    BX,[ES:DI.EA_VALLEN]		 ;FT.  length equal ?		;AN000;
   409                                  ;	JNZ    notset				 ;FT.  no			;AN000;
   410                                  ;	PUSH   DS				 ;FT.				;AN000;
   411                                  ;	PUSH   SI				 ;FT.				;AN000;
   412                                  ;	MOV    AL,[SI.EA_NAMELEN]		 ;FT.				;AN000;
   413                                  ;	XOR    AH,AH				 ;FT.				;AN000;
   414                                  ;	ADD    SI,EA_NAME			 ;FT.				;AN000;
   415                                  ;	ADD    SI,AX				 ;FT.				;AN000;
   416                                  ;	CMP    DX,0				 ;FT.				;AN000;
   417                                  ;	JNZ    set_filetyp			 ;FT.				;AN000;
   418                                  ;	LODSW					 ;FT.				;AN000;
   419                                  ;	CMP    [XA_DEVICE],0			 ;FT. device ?			;AN000;
   420                                  ;	JZ     notdevice			 ;FT. no			;AN000;
   421                                  ;	OR     AX,AX				 ;FT. code page 0 ?		;AN000;
   422                                  ;	JZ     NORM0				 ;FT. yes			;AN000;
   423                                  ;
   424                                  ;	CALL   GSetDevCdPg			 ;FT.				;AN000;
   425                                  ;	JNC    welldone 			 ;FT.				;AN000;
   426                                  ;	CMP    [CPSWFLAG],0			 ;FT. code page matching on	;AN000;
   427                                  ;	JZ     NORM0				 ;FT. no			;AN000;
   428                                  ;	invoke SAVE_WORLD			 ;FT. save all regs		;AN000;
   429                                  ;	LDS    SI,[THISSFT]			 ;FT. ds:si -> sft		;AN000;
   430                                  ;	LDS    SI,[SI.sf_devptr]		 ;FT. ds:si -> device header	;AN000;
   431                                  ;	MOV    BP,DS				 ;FT. save all regs		;AN000;
   432                                  ;	invoke Code_Page_Mismatched_Error	 ;FT.				;AN000;
   433                                  ;	CMP    AL,0				 ;FT. ignore ?			;AN000;
   434                                  ;	JZ     NORM1				 ;FT.				;AN000;
   435                                  ;	invoke RESTORE_WORLD			 ;FT. save all regs		;AN000;
   436                                  ;NORM0:
   437                                  ;	MOV    AL,EARCDEVERROR			 ;FT.				;AN000;
   438                                  ;	STC					 ;FT.				;AN000;
   439                                  ;	JMP    SHORT sdone			 ;FT.				;AN000;
   440                                  ;NORM1:
   441                                  ;	invoke RESTORE_WORLD			 ;FT. save all regs		;AN000;
   442                                  ;	JMP    SHORT welldone			 ;FT.				;AN000;
   443                                  ;notdevice:
   444                                  ;	LDS    SI,[THISSFT]			 ;FT.				;AN000;
   445                                  ;	MOV    [SI.sf_CodePage],AX		 ;FT. set codepege		;AN000;
   446                                  ;	JMP    SHORT welldone			 ;FT.
   447                                  ;set_filetyp:
   448                                  ;	LODSB					 ;FT.				;AN000;
   449                                  ;	LDS    SI,[THISSFT]			 ;FT. set filtype		;AN000;
   450                                  ;	MOV    [SI.sf_ATTR_HI],AL		 ;FT.				;AN000;
   451                                  ;
   452                                  ;welldone:
   453                                  ;	XOR    AL,AL				 ;FT.  success			;AN000;
   454                                  ;sdone:
   455                                  ;	POP    SI				 ;FT.				;AN000;
   456                                  ;	POP    DS				 ;FT.				;AN000;
   457                                  ;notset:
   458                                  ;	POP    CX				 ;FT.				;AN000;
   459                                  ;	 return 				  ;FT.				 ;AN000;
   460                                  										;AN000;
   461                                  ;EndProc SET_ONE_EA								 ;AN000;
   462                                  										;AN000;
   463                                  ; Input: ES:DI= buffer address							;AN000;
   464                                  ;	 DS:SI= EA entry address
   465                                  ;	 [SAVE_CX]= buffer size available
   466                                  ;	 [SAVE_BX]= size returned
   467                                  ;	 DX= EA ID (0 codpage, 1  Filetype, etc.)
   468                                  ; Function: move one EA entry to the buffer					;AN000;
   469                                  ; Output: carry clear
   470                                  ;	    DS:SI points to next entry
   471                                  ;	    ES:DI points to next entry
   472                                  ;	    [SAVE_CX],BX, updated						;AN000;
   473                                  ;	  carry set, insufficient memory error					;AN000;
   474                                  										;AN000;
   475                                  ;procedure   GET_ONE_EA,NEAR							 ;AN000;
   476                                  ;	ASSUME	CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:DOSGROUP			;AN000;
   477                                  ;										;AN000;
   478                                  ;	PUSH   CX				 ;FT.				;AN000;
   479                                  ;	CMP    [XA_TYPE],2			 ;FT. type 2 ?			;AN000;
   480                                  ;	JZ     gtyp2				 ;FT. yes			;AN000;
   481                                  ;	MOV    CX,QEA_NAME - QEA_TYPE		 ;FT.				;AN000;
   482                                  ;	JMP    SHORT addnmlen			 ;FT.
   483                                  ;gtyp2:
   484                                  ;	MOV    CX,EA_NAME - EA_TYPE		 ;FT. cx = EA entry size	;AN000;
   485                                  ;	ADD    CX,[SI.EA_VALLEN]		 ;FT.				;AN000;
   486                                  ;addnmlen:
   487                                  ;	MOV    AL,[SI.EA_NAMELEN]		 ;FT.
   488                                  ;	XOR    AH,AH				 ;FT.				;AN000;
   489                                  ;	ADD    CX,AX				 ;FT.				;AN000;
   490                                  ;	CMP    CX,[SAVE_CX]			 ;FT. > buffer size		;AN000;
   491                                  ;	JA     sizeshort			 ;FT. yes			;AN000;
   492                                  ;	PUSH   CX				 ;FT.				;AN000;
   493                                  ;	LODSB					 ;FT. move type 		;AN000;
   494                                  ;	STOSB					 ;FT.				;AN000;
   495                                  ;	LODSW					 ;FT.				;AN000;
   496                                  ;	STOSW					 ;FT. move flag 		;AN000;
   497                                  ;	LODSB					 ;FT. EA list need RC		;AN000;
   498                                  ;	CMP    [XA_TYPE],2			 ;FT.				;AN000;
   499                                  ;	JNZ    norc				 ;FT.				;AN000;
   500                                  ;	STOSB					 ;FT.				;AN000;
   501                                  ;norc:
   502                                  ;	LODSB					 ;FT. move name len		;AN000;
   503                                  ;	STOSB					 ;FT.				;AN000;
   504                                  ;	MOV    CL,AL				 ;FT.				;AN000;
   505                                  ;	XOR    CH,CH				 ;FT.				;AN000;
   506                                  ;	LODSW					 ;FT. EA list need value len	;AN000;
   507                                  ;	CMP    [XA_TYPE],2			 ;FT.				;AN000;
   508                                  ;	JNZ    novalen				 ;FT.				;AN000;
   509                                  ;	STOSW					 ;FT.				;AN000;
   510                                  ;novalen:
   511                                  ;
   512                                  ;	REP    MOVSB				 ;FT. move EA to buffer 	;AN000;
   513                                  ;	CMP    [XA_TYPE],2			 ;FT.				;AN000;
   514                                  ;	JNZ    novalue				 ;FT.				;AN000;
   515                                  ;	CALL   GET_VALUE			 ;FT. get value for type 2	;AN000;
   516                                  ;novalue:
   517                                  ;	POP    CX				 ;FT.				;AN000;
   518                                  ;	ADD    [SAVE_BX],CX			 ;FT. add entry size		;AN000;
   519                                  ;	LES    DI,DWORD PTR [SAVE_DI]		 ;FT.				;AN000;
   520                                  ;	ADD    DI,[SAVE_BX]			 ;FT. es:di -> next entry	;AN000;
   521                                  ;	SUB    [SAVE_CX],CX			 ;FT. update buffer size	;AN000;
   522                                  ;	CLC					 ;FT.				;AN000;
   523                                  ;	JMP    SHORT okget			 ;FT.				;AN000;
   524                                  ;
   525                                  ;sizeshort:
   526                                  ;	MOV    AX,error_not_enough_memory	 ;FT.  error			;AN000;
   527                                  ;	STC					 ;FT.				;AN000;
   528                                  ;okget:
   529                                  ;	POP    CX				 ;FT.				;AN000;
   530                                  ;	return				    ;FT.				;AN000;
   531                                  ;										;AN000;
   532                                  ;EndProc GET_ONE_EA								 ;AN000;
   533                                  										;AN000;
   534                                  										;AN000;
   535                                  ; Input: DX= EA ID (0 codpage, 1 Filetype, etc.)
   536                                  ;	 [THISSFT]= points to SFT
   537                                  ;	 ES:DI= buffer address of EA value
   538                                  ;	 [XA_DEVICE]=0 file, 1 device
   539                                  ; Function: get attribute							;AN000;
   540                                  ; Output: none									;AN000;
   541                                  ;										;AN000;
   542                                  										;AN000;
   543                                  ;procedure   GET_VALUE,NEAR							 ;AN000;
   544                                  ;	ASSUME	CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:DOSGROUP			;AN000;
   545                                  ;										;AN000;
   546                                  ;	PUSH   DS			     ;FT. save ds:si			;AN000;
   547                                  ;	PUSH   SI			     ;FT.				;AN000;
   548                                  ;	LDS    SI,[ThisSFT]		     ;FT. ds:si -> SFT			;AN000;
   549                                  ;
   550                                  ;	CMP    DX,0			     ;FT. code page ?			;AN000;
   551                                  ;	JNZ    eafiltyp 		     ;FT. no				;AN000;
   552                                  ;	CMP    [XA_DEVICE],0		     ;FT. device ?			;AN000;
   553                                  ;	JZ     notdev			     ;FT. no				;AN000;
   554                                  ;	CALL   GSetDevCdPg		     ;FT. do ioctl invoke		;AN000;
   555                                  ;	JNC    okcdpg			     ;FT. error ?			;AN000;
   556                                  ;	PUSH   DI			     ;FT.				;AN000;
   557                                  ;	XOR    AX,AX			     ;FT. make code page 0		;AN000;
   558                                  ;	LES    DI,DWORD PTR [SAVE_DI]	     ;FT.				;AN000;
   559                                  ;	ADD    DI,[SAVE_BX]		     ;FT. es:di -> beginning of entry	;AN000;
   560                                  ;	MOV    [ES:DI.EA_RC],EARCNOTFOUND    ;FT.				;AN000;
   561                                  ;	POP    DI			     ;FT.				;AN000;
   562                                  ;	JMP    SHORT okcdpg		     ;FT.				;AN000;
   563                                  ;notdev:
   564                                  ;	MOV    AX,[SI.sf_CodePage]	     ;FT. get code page from  sft	;AN000;
   565                                  ;okcdpg:
   566                                  ;	STOSW				     ;FT. put in buffer 		;AN000;
   567                                  ;	JMP    SHORT gotea		     ;FT.				;AN000;
   568                                  ;eafiltyp:
   569                                  ;	MOV    AL,[SI.sf_ATTR_HI]	     ;FT. get high attribute		;AN000;
   570                                  ;	STOSB				     ;FT. put in buffer 		;AN000;
   571                                  ;
   572                                  ;gotea:
   573                                  ;	POP    SI			     ;FT. retore regs			;AN000;
   574                                  ;	POP    DS			     ;FT.				;AN000;
   575                                  ;	return				     ;FT.				;AN000;
   576                                  ;EndProc GET_VALUE								 ;AN000;
   577                                  										;AN000;
   578                                  										;AN000;
   579                                  ; Input:    [XA_handle] = device handle 					;AN000;
   580                                  ;	    [XA_type] = 4 , set 						;AN000;
   581                                  ;	    AX= code page (set)
   582                                  ;			2,3 get 						;AN000;
   583                                  ; Function: get or set device code page 					;AN000;
   584                                  ; Output:   carry clear, AX= device code page (get)				;AN000;
   585                                  ;	    carry set, error							;AN000;
   586                                  										;AN000;
   587                                  ;procedure   GSetDevCdPg,near							 ;AN000;
   588                                  ;	ASSUME	CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:DOSGROUP			;AN000;
   589                                  ;										;AN000;
   590                                  ;	invoke SAVE_WORLD	       ;FT. save all regs			;AN000;
   591                                  ;	CMP    [XA_type],4	       ;FT. set ?				;AN000;
   592                                  ;	JZ     setpg		       ;FT. yes 				;AN000;
   593                                  ;	MOV    CX,6AH		       ;FT. get selected code page		;AN000;
   594                                  ;	JMP    SHORT dogset	       ;FT.					;AN000;
   595                                  ;setpg: 									 ;AN000;
   596                                  ;	MOV    CX,4AH		       ;FT. set code page			;AN000;
   597                                  ;IF  DBCS
   598                                  ;
   599                                  ;	invoke Save_World	       ;FT. save all regs			;AN000;
   600                                  ;	MOV    BX,AX		       ;FT. bx= code page id			;AN000;
   601                                  ;	MOV    AL,7		       ;FT. get DBCS vectors			;AN000;
   602                                  ;	MOV    DX,-1		       ;FT. get current country 		;AN000;
   603                                  ;	MOV    CX,5		       ;FT. minimum size			;AN000;
   604                                  ;	MOV    DI,OFFSET DBCS_PACKET wrt DOSGROUP	;FT.				;AN000;
   605                                  ;	PUSH   CS		       ;FT.					;AN000;
   606                                  ;	POP    ES		       ;FT.					;AN000;
   607                                  ;	invoke $GetExtCntry	       ;FT. get DBCS vectors			;AN000;
   608                                  ;	JC     nlsfunc_err	       ;FT. error				;AN000;
   609                                  ;	LDS    SI,DWORD PTR DBCS_PACKET+1     ;FT.				;AN000;
   610                                  ;	LODSW				      ;FT. get vector length		;AN000;
   611                                  ;	MOV    CX,AX			      ;FT. cx=length			;AN000;
   612                                  ;
   613                                  ;	MOV    DI,OFFSET XA_PACKET+4 wrt DOSGROUP	;FT.				;AN000;
   614                                  ;	PUSH   CS		       ;FT.					;AN000;
   615                                  ;	POP    ES		       ;FT.					;AN000;
   616                                  ;	REP    MOVSB			      ;FT.				;AN000;
   617                                  ;	CLC				      ;FT.				;AN000;
   618                                  ;nlsfunc_err:
   619                                  ;	invoke RESTORE_WORLD	       ;FT. restore all regs			;AN000;
   620                                  ;	JC     deverr		       ;FT.					;AN000;
   621                                  ;
   622                                  ;ENDIF
   623                                  ;	MOV    WORD PTR [XA_PACKET+2],AX  ;FT.					;AN000;
   624                                  ;dogset:									 ;AN000;
   625                                  ;	MOV    BX,[XA_handle]	       ;FT. set up handle			;AN000;
   626                                  ;	PUSH   CS		       ;FT. ds:dx -> packet			;AN000;
   627                                  ;	POP    DS		       ;FT.					;AN000;
   628                                  ;	MOV    DX,OFFSET XA_PACKET wrt DOSGROUP  ;FT.				;AN000;
   629                                  ;	MOV    AX,440CH 	       ;FT. IOCTL to char device by handle	;AN000;
   630                                  ;	invoke $IOCTL			     ;FT. issue get code page		;AN000;
   631                                  ;	JC     deverr			     ;FT. error 			;AN000;
   632                                  ;	invoke RESTORE_WORLD		     ;FT. restore all regs		;AN000;
   633                                  ;	MOV    AX,WORD PTR [XA_PACKET+2]     ;FT. get code page 		;AN000;
   634                                  ;	return				     ;FT.				;AN000;
   635                                  ;deverr:									 ;AN000;
   636                                  ;	invoke RESTORE_WORLD		     ;FT. restore all regs		;AN000;
   637                                  ;	return				     ;FT. exit				;AN000;
   638                                  ;										;AN000;
   639                                  ;EndProc GSetDevCdPg								 ;AN000;
   640                                  										;AN000;
   641                                  
   642                                  ; Input:    DS:SI -> query list
   643                                  ;
   644                                  ; Function: get max size							;AN000;
   645                                  ; Output:   CX= size
   646                                  ;	    carry set error
   647                                  										;AN000;
   648                                  ;procedure   Get_max_EA_size,NEAR						 ;AN000;
   649                                  ;	ASSUME	CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:DOSGROUP			;AN000;
   650                                  ;										;AN000;
   651                                  ;	CMP    [SAVE_SI],0FFFFH 	     ;FT. get all ?			;AN000;
   652                                  ;	JNZ    scan_query		     ;FT. no				;AN000;
   653                                  ;	MOV    CX,[MAX_EA_SIZE] 	     ;FT. get max EA size		      ;AN000;
   654                                  ;	JMP    SHORT gotit		     ;FT.
   655                                  ;scan_query:
   656                                  ;	LDS    SI,DWORD PTR [SAVE_SI]	     ;FT. ds:si -> query list		;AN000;
   657                                  ;	LODSW				     ;FT. ax= number of entries 	;AN000;
   658                                  ;	MOV    [SAVE_CX],AX		     ;FT.				;AN000;
   659                                  ;	XOR    CX,CX			     ;FT. set initial size to 0 	;AN000;
   660                                  ;	OR     AX,AX			     ;FT. if no entris			;AN000;
   661                                  ;	JZ     gotit			     ;FT.    then return		;AN000;
   662                                  ;	MOV    CX,2			     ;FT. at lesat 2			;AN000;
   663                                  ;NEXT_QEA:
   664                                  ;	CALL   Search_EA		     ;FT. search EA			;AN000;
   665                                  ;	JC     serror			     ;FT. wrong EA			;AN000;
   666                                  ;	ADD    CX,size EA		     ;FT. get EA size			;AN000;
   667                                  ;	ADD    CL,[ES:DI.EA_NAMELEN]	     ;FT.				;AN000;
   668                                  ;	ADC    CH,0			     ;FT.				;AN000;
   669                                  ;	ADD    CX,[ES:DI.EA_VALLEN]	     ;FT.				;AN000;
   670                                  ;	DEC    CX			     ;FT.				;AN000;
   671                                  ;	DEC    [SAVE_CX]		     ;FT. end of entris 		;AN000;
   672                                  ;	JZ     gotit			     ;FT. no				;AN000;
   673                                  ;	MOV    AL,[SI.QEA_NAMELEN]	     ;FT. update to next QEA		;AN000;
   674                                  ;	XOR    AH,AH			     ;FT. update to next QEA		;AN000;
   675                                  ;	ADD    SI,AX			     ;FT. update to next QEA		;AN000;
   676                                  ;	ADD    SI,size QEA		     ;FT.				;AN000;
   677                                  ;	DEC    SI			     ;FT.				;AN000;
   678                                  ;	JMP    next_QEA 		     ;FT. do next			;AN000;
   679                                  ;serror:
   680                                  ;	MOV    AX,error_invalid_data	     ;FT. set initial size to 0 	;AN000;
   681                                  ;gotit: 				      ;FT.				 ;AN000;
   682                                  ;	return				     ;FT. exit				;AN000;;FT. exit			  ;AN000;
   683                                  ;
   684                                  ;EndProc Get_max_EA_size		      ;FT. exit 			 ;AN000;				   ;AN000;
   685                                  										;AN000;
   686                                  END										;AN000;
