home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 35 / hot35.iso / ficheros / LC / SIMPWN93.ZIP / SIMPWIN.ZIP / LFSW92.C < prev    next >
C/C++ Source or Header  |  1997-06-08  |  2KB  |  111 lines

  1. #include <stdarg.h>
  2. #include <dos.h>
  3. #include <mem.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <alloc.h>
  7. #include <conio.h>
  8. #include <stdlib.h>
  9.  
  10.  
  11. void main(int argc,char *argv[])
  12. {
  13.     char *char_buff;
  14.     unsigned int handle;
  15.     unsigned int error;
  16.     unsigned int seg;
  17.     unsigned int off;
  18.     unsigned int file_seg;
  19.     unsigned int file_off;
  20.     char *file_name;
  21.  
  22.     if((char_buff = (char*)malloc(4096)) == NULL)
  23.     {
  24.         cprintf("Not enough memory!");
  25.         exit(1);
  26.     }
  27.     else
  28.     {
  29.         if((file_name = (char*)malloc(256)) == NULL)
  30.         {
  31.             cprintf("Not enough memory!");
  32.             free(char_buff);
  33.             exit(1);
  34.         }
  35.     }
  36.     strcpy(file_name,argv[1]);
  37.     asm    mov ax,ds;
  38.     asm    mov seg,ax;
  39.     asm    mov file_seg,ax;
  40.     asm    mov ax,char_buff;
  41.     asm    mov off,ax;
  42.     asm    mov ax,file_name;
  43.     asm    mov file_off,ax;
  44.     asm    mov ax,file_seg;
  45.     asm    mov dx,file_off;
  46.     asm    push ds;
  47.     asm    mov ds,ax;
  48.     asm    mov al,0x02;
  49.     asm    mov ah,0x3d;
  50.     asm    int 0x21;
  51.     asm    pop ds;
  52.     asm    jnc cont1;
  53.     asm    mov error,ax;
  54.     free(file_name);
  55.     free(char_buff);
  56.     cprintf("No file found!");
  57.     exit(1);
  58.     cont1:
  59.     asm    mov handle,ax;
  60.     asm    mov bx,ax;
  61.     asm    mov cx,4096;
  62.     asm    mov dx,off;
  63.     asm    mov ax,seg;
  64.     asm    push ds;
  65.     asm    mov ds,ax;
  66.     asm    mov ah,0x3f;
  67.     asm    int 0x21;
  68.     asm    pop ds;
  69.     asm    jnc cont2;
  70.     asm    mov error,ax;
  71.     free(char_buff);
  72.     free(file_name);
  73.     asm    mov ah,0x3e;
  74.     asm    mov bx,handle;
  75.     asm    int 0x21;
  76.     asm    jnc cont3;
  77.     asm    mov error,ax;
  78.     cprintf("Read error!");
  79.     free(char_buff);
  80.     free(file_name);
  81.     exit(1);
  82.     cont2:
  83.     asm    mov ah,0x3e;
  84.     asm    mov bx,handle;
  85.     asm    int 0x21;
  86.     asm    jnc cont3;
  87.     asm    mov error,ax;
  88.     free(char_buff);
  89.     free(file_name);
  90.     cprintf("Can't close file!");
  91.     exit(1);
  92.     cont3:
  93.     asm    mov bh,0x10;
  94.     asm    mov bl,0x00;
  95.     asm    mov dx,0x00;
  96.     asm    mov cx,0xff;
  97.     asm    mov ax,seg;
  98.     asm    push es;
  99.     asm    mov es,ax;
  100.     asm    push bp;
  101.     asm    mov ax,off;
  102.     asm    mov bp,ax;
  103.     asm    mov ah,0x11;
  104.     asm    mov al,0x10;
  105.     asm    int 0x10;
  106.     asm    pop bp;
  107.     asm    pop es;
  108.     free(char_buff);
  109.     free(file_name);
  110. }
  111.