Subversion Repositories SvarDOS

Rev

Rev 1576 | Rev 1578 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1576 Rev 1577
Line 23... Line 23...
23
 * IN THE SOFTWARE.
23
 * IN THE SOFTWARE.
24
 */
24
 */
25
 
25
 
26
#include <i86.h> /* MK_FP() */
26
#include <i86.h> /* MK_FP() */
27
 
27
 
28
#include "libc.h"
-
 
29
 
-
 
30
#include "mdr\bios.h"
28
#include "mdr\bios.h"
31
#include "mdr\cout.h"
29
#include "mdr\cout.h"
32
#include "mdr\dos.h"
30
#include "mdr\dos.h"
33
 
31
 
34
#include "svarlang\svarlang.h"
32
#include "svarlang\svarlang.h"
Line 155... Line 153...
155
/*****************************************************************************
153
/*****************************************************************************
156
 * functions                                                                 *
154
 * functions                                                                 *
157
 *****************************************************************************/
155
 *****************************************************************************/
158
 
156
 
159
 
157
 
-
 
158
static unsigned short dos_write(unsigned short handle, const void far *buf, unsigned short count, unsigned short *bytes) {
-
 
159
  unsigned short res = 0;
-
 
160
  unsigned short resax = 0;
-
 
161
  unsigned short buf_seg = FP_SEG(buf);
-
 
162
  unsigned short buf_off = FP_OFF(buf);
-
 
163
 
-
 
164
  _asm {
-
 
165
    push bx
-
 
166
    push cx
-
 
167
    push dx
-
 
168
 
-
 
169
    mov ah, 0x40
-
 
170
    mov bx, handle
-
 
171
    mov cx, count
-
 
172
    mov dx, buf_off
-
 
173
    push ds
-
 
174
    mov ds, buf_seg
-
 
175
 
-
 
176
    int 0x21
-
 
177
    pop ds
-
 
178
    jnc done
-
 
179
    mov res, ax
-
 
180
 
-
 
181
    done:
-
 
182
    mov resax, ax
-
 
183
 
-
 
184
    pop dx
-
 
185
    pop cx
-
 
186
    pop bx
-
 
187
  }
-
 
188
 
-
 
189
  *bytes = resax;
-
 
190
  return(res);
-
 
191
}
-
 
192
 
-
 
193
 
160
static size_t strlen(const char *s) {
194
static size_t strlen(const char *s) {
161
  const char *ptr = s;
195
  const char *ptr = s;
162
  while (*ptr != 0) ptr++;
196
  while (*ptr != 0) ptr++;
163
  return(ptr - s);
197
  return(ptr - s);
164
}
198
}
Line 356... Line 390...
356
  }
390
  }
357
 
391
 
358
  while (l) {
392
  while (l) {
359
    /* do not write the last empty line, it is only useful for edition */
393
    /* do not write the last empty line, it is only useful for edition */
360
    if (l->len != 0) {
394
    if (l->len != 0) {
361
      errflag |= mdr_dos_write(fd, l->payload, l->len, &bytes);
395
      errflag |= dos_write(fd, l->payload, l->len, &bytes);
362
    } else if (l->next == NULL) {
396
    } else if (l->next == NULL) {
363
      break;
397
      break;
364
    }
398
    }
365
    errflag |= mdr_dos_write(fd, eolbuf, eollen, &bytes);
399
    errflag |= dos_write(fd, eolbuf, eollen, &bytes);
366
    l = l->next;
400
    l = l->next;
367
  }
401
  }
368
 
402
 
369
  errflag |= dosfclose(fd);
403
  errflag |= dosfclose(fd);
370
 
404