; Header File ; Created 16/10/2004; 01:17:47 common_copy_file: clr.b _section_is_good move.l 200,a5 bsr get_file move.w d0,d6 beq \file_not_found moveq #10,d0 bsr alloc move.w d0,d4 beq \memory_error bsr deref move.l #$00050001,(a0)+ move.l #$2000E000,(a0);et hop, un texte vide de fait =) move.w d6,d0 bsr lock bsr deref addq.l #5,a0 move.l a0,a2 \loop: tst.b (a0); apu de clefs beq \end_loop move.l a0,a2 bsr match_key;on regarde si c'est celle qu'on cherche cmp.b #1,_section_is_good bne \skip_section tst.w d0 bne \found \skip_section: bsr next_key;on passe à la suivante move.l a0,d0 beq \end_loop cmp.b #2,_section_is_good;on regarde si on ne change pas de section avant d'avoir créé la bonne clef bne \skip_good_section move.l a0,-(a7) bsr make_key;on crée la clef cherchée beq \error move.l (a7)+,a0 \skip_good_section: bsr copy_key;on la copie avant de changer le pointeur beq \error bra \loop \found: bsr make_key;on crée la clef cherchée beq \error bsr next_key;et on passe à la suivante move.l a0,d0 bne \loop;et on continue à recopier les clefs \end_loop: bsr make_section bsr make_key;on crée la clef cherchée beq \error moveq #CONFLIB_OK,d0 \exit: ;reste à échanger les 2 handles dans la VAT, et archiver le fichier ; faut encore retrouver le fichier ; preos powaa > un chtit ram_call est c'est fait move.w d6,d0 jsr kernel::Hd2Sym move.b 10(a0),d1;pour conserver le flag archivé clr.w 10(a0) move.w d4,12(a0) ;là faut faire les sommations d'usage (désarchiver, blablabla) move.w d6,d0 btst.b #1,d1 beq \not_archived \archived: move.w d0,-(a7) move.l $15B*4(a5),a0;EM_Abandon jsr (a0) addq.l #2,a7 move.w d4,d0 jsr kernel::Hd2Sym move.l a0,-(a7) jsr kernel::Ptr2Hd move.w d0,-(a7) move.l $282*4(a5),a0;MakeHSym jsr (a0) addq.l #6,a7 move.l d0,-(a7) clr.l -(a7) move.l $162*4(a5),a0;EM_SymMoveToExtMem jsr (a0) addq.l #8,a7 bra \common \not_archived: bsr unlock bsr free \common: moveq #CONFLIB_OK,d0 movem.l (a7)+,a0-a6/d1-d7 rts \file_not_found: moveq #CONFLIB_FILE_NOT_FOUND,d0 bra \error \memory_error: moveq #4,d0 \error: exg.l d4,d0 bsr free exg.l d4,d0 movem.l (a7)+,a0-a6/d1-d7 rts make_key: moveq #1,d0 tst.w d5 bne \skip moveq #1,d5 movem.l a0-a3/d1-d5,-(a7) cmp.b #10,_type bge \skip_for_sections move.l a4,a0 \str_len: tst.b (a0)+ bne \str_len sub.l a4,a0 move.l a0,d5 addq.l #2,d5 \skip_for_sections: addq.l #2,d5;on ajoute 5o pour ' = ' et '\n ', ou pour '[' ']\n' ;là ça diverge entre les différents types de clé move.b _type(pc),d0 bne \skip_make_num_key \make_num_key: move.l d7,d0 bsr hex_to_dec bra \make_key \skip_make_num_key: \make_string_key: cmp.b #10,d0 bge \make_section move.l _value(pc),a0 moveq #0,d0 \loop: addq.l #1,d0 tst.b (a0)+ bne \loop addq.l #1,d0;pour les " " bra \make_key \make_section: lea _section(pc),a0 moveq #0,d0 \loop_section: addq.l #1,d0 tst.b (a0)+ bne \loop_section bra \make_key \make_key: ;-> d0 taille des données à ajouter ;là ça reconverge add.l d0,d5 ;on change la taille du texte à la hausse, pour accueillir la nouvelle clef move.w d4,d0 bsr size add.l d5,d0 move.w d4,d1 bsr realloc tst.w d0 beq \exit bsr deref moveq #0,d0 move.w 2(a0),d0 add.w d5,(a0) add.w d5,2(a0) lea 4(a0,d0.l),a0;on va le faire pointer à la fin du texte en cours ;on recopie le nom de la clef move.b _type(pc),d0 cmp.b #10,d0 bge \made_section move.l a4,a1 \copy_key: move.b (a1)+,(a0)+ bne \copy_key move.b #' ',-1(a0) move.b #'=',(a0)+ move.b #' ',(a0)+ ;là ça diverge entre les différents types de clé tst.b d0 bne \skip_made_num_key \made_num_key: lea _buffer(pc),a1 \copy_value: move.b (a1)+,(a0)+ bne \copy_value subq.l #1,a0 bra \made_key \made_section: lea _section(pc),a1 moveq #0,d0 move.b #'[',(a0)+ \copy_section: move.b (a1)+,(a0)+ bne \copy_section move.b #']',-1(a0) bra \made_key \skip_made_num_key: \made_string_key: move.b #'"',(a0)+ move.l _value(pc),a1 \copie_string: tst.b (a1) beq \exit_string move.b (a1)+,(a0)+ bra \copie_string \exit_string: move.b #'"',(a0)+ \made_key: ;là ça reconverge move.b #13,(a0)+ move.b #' ',(a0)+ clr.b (a0)+ move.b #$E0,(a0) moveq #1,d0 \exit: movem.l (a7)+,a0-a3/d1-d5 \skip: tst.w d0 rts make_section: moveq #1,d0 tst.b _section_is_good bne \skip move.l d5,-(a7) move.b _type(pc),-(a7) move.b #10,_type moveq #0,d5 bsr make_key move.b (a7)+,_type move.l (a7)+,d5 \skip: tst.w d0 rts copy_key: ;recopie la clé comprise entre a2 et a0 dans le texte ;la clé est contenue entre a2 et a0 movem.l a0-a3/d1-d5,-(a7) move.l a0,d5 sub.l a2,d5 tst.b (a0) bne \skip cmp.b #13,-2(a0) beq \skip add.l #2,d5 \skip: moveq #1,d0 tst.l d5 beq \exit move.w d4,d0 bsr size add.l d5,d0 move.w d4,d1 bsr realloc tst.w d0 beq \exit bsr deref moveq #0,d0 move.w 2(a0),d0 add.w d5,(a0) add.w d5,2(a0) lea 4(a0,d0.l),a0;on va le faire pointer à la fin du texte en cours subq.b #1,d5 \copy: move.b (a2)+,(a0)+ dbra d5,\copy tst.b -2(a0);quand on a ajouté 2 à d5 ... bne \skip_2 cmp.b #13,-4(a0) beq \skip_2 move.b #13,-2(a0) move.b #' ',-1(a0) \skip_2: clr.b (a0)+ move.b #$E0,(a0) moveq #1,d0 \exit: movem.l (a7)+,a0-a3/d1-d5 tst.w d0 rts