Subversion Repositories SvarDOS

Rev

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

Rev 1579 Rev 1580
Line 91... Line 91...
91
/*****************************************************************************
91
/*****************************************************************************
92
 * assembly pragma "functions"                                               *
92
 * assembly pragma "functions"                                               *
93
 *****************************************************************************/
93
 *****************************************************************************/
94
 
94
 
95
 
95
 
96
unsigned short dosalloc(unsigned short siz);
96
unsigned short dos_alloc(unsigned short siz);
97
 
97
 
98
#pragma aux dosalloc = \
98
#pragma aux dos_alloc = \
99
"mov ah, 0x48" \
99
"mov ah, 0x48" \
100
"int 0x21" \
100
"int 0x21" \
101
"jnc done" \
101
"jnc done" \
102
"xor ax, ax" \
102
"xor ax, ax" \
103
"done:" \
103
"done:" \
104
parm [bx] \
104
parm [bx] \
105
value [ax];
105
value [ax];
106
 
106
 
107
 
107
 
108
unsigned short dosfree(unsigned short segn);
108
unsigned short dos_free(unsigned short segn);
109
 
109
 
110
#pragma aux dosfree = \
110
#pragma aux dos_free = \
111
"mov ah, 0x49" \
111
"mov ah, 0x49" \
112
"int 0x21" \
112
"int 0x21" \
113
"jc done" \
113
"jc done" \
114
"xor ax, ax" \
114
"xor ax, ax" \
115
"done:" \
115
"done:" \
116
parm [es] \
116
parm [es] \
117
value [ax];
117
value [ax];
118
 
118
 
119
 
119
 
120
unsigned short dosfclose(unsigned short handle);
120
unsigned short dos_fclose(unsigned short handle);
121
 
121
 
122
#pragma aux dosfclose = \
122
#pragma aux dos_fclose = \
123
"mov ah,0x3e" \
123
"mov ah,0x3e" \
124
"int 0x21" \
124
"int 0x21" \
125
"jc done" \
125
"jc done" \
126
"xor ax, ax" \
126
"xor ax, ax" \
127
"done:" \
127
"done:" \
128
parm [bx] \
128
parm [bx] \
129
value [ax];
129
value [ax];
130
 
130
 
131
 
131
 
132
unsigned short dosfread(unsigned short handle, void *buf, unsigned short count, unsigned short *bytes);
132
unsigned short dos_fread(unsigned short handle, void *buf, unsigned short count, unsigned short *bytes);
133
 
133
 
134
#pragma aux dosfread = \
134
#pragma aux dos_fread = \
135
"mov ah, 0x3f" \
135
"mov ah, 0x3f" \
136
"int 0x21" \
136
"int 0x21" \
137
"jc done" \
137
"jc done" \
138
"mov [di], ax" \
138
"mov [di], ax" \
139
"xor ax, ax" \
139
"xor ax, ax" \
Line 152... Line 152...
152
"done:" \
152
"done:" \
153
parm [bx] [es] \
153
parm [bx] [es] \
154
value [ax]
154
value [ax]
155
 
155
 
156
 
156
 
157
unsigned short dos_write(unsigned short handle, unsigned short count, unsigned short *bytes, const void far *buf);
157
unsigned short dos_fwrite(unsigned short handle, unsigned short count, unsigned short *bytes, const void far *buf);
158
/* NOTE: last parameter (far pointer buf) is passed on the stack */
158
/* NOTE: last parameter (far pointer buf) is passed on the stack */
159
#pragma aux dos_write = \
159
#pragma aux dos_fwrite = \
160
"push ds"   /* save DS into AX */ \
160
"push ds"   /* save DS into AX */ \
161
"pop ax" \
161
"pop ax" \
162
"pop dx" \
162
"pop dx" \
163
"pop ds" \
163
"pop ds" \
164
"push ax"   /* save DS into stack for later restoration */ \
164
"push ax"   /* save DS into stack for later restoration */ \
Line 213... Line 213...
213
 
213
 
214
static struct line far *line_calloc(unsigned short siz) {
214
static struct line far *line_calloc(unsigned short siz) {
215
  struct line far *res;
215
  struct line far *res;
216
  unsigned short seg;
216
  unsigned short seg;
217
 
217
 
218
  seg = dosalloc((sizeof(struct line) + siz + 15) / 16);
218
  seg = dos_alloc((sizeof(struct line) + siz + 15) / 16);
219
  if (seg == 0) return(NULL);
219
  if (seg == 0) return(NULL);
220
  res = MK_FP(seg, 0);
220
  res = MK_FP(seg, 0);
221
  res->len = 0;
221
  res->len = 0;
222
  res->next = NULL;
222
  res->next = NULL;
223
  res->prev = NULL;
223
  res->prev = NULL;
Line 225... Line 225...
225
  return(res);
225
  return(res);
226
}
226
}
227
 
227
 
228
 
228
 
229
static void line_free(struct line far *ptr) {
229
static void line_free(struct line far *ptr) {
230
  dosfree(FP_SEG(ptr));
230
  dos_free(FP_SEG(ptr));
231
}
231
}
232
 
232
 
233
 
233
 
234
static int curline_resize(struct file *db, unsigned short newsiz) {
234
static int curline_resize(struct file *db, unsigned short newsiz) {
235
  struct line far *newptr;
235
  struct line far *newptr;
Line 383... Line 383...
383
  }
383
  }
384
 
384
 
385
  while (l) {
385
  while (l) {
386
    /* do not write the last empty line, it is only useful for edition */
386
    /* do not write the last empty line, it is only useful for edition */
387
    if (l->len != 0) {
387
    if (l->len != 0) {
388
      errflag |= dos_write(fd, l->len, &bytes, l->payload);
388
      errflag |= dos_fwrite(fd, l->len, &bytes, l->payload);
389
    } else if (l->next == NULL) {
389
    } else if (l->next == NULL) {
390
      break;
390
      break;
391
    }
391
    }
392
    errflag |= dos_write(fd, eollen, &bytes, eolbuf);
392
    errflag |= dos_fwrite(fd, eollen, &bytes, eolbuf);
393
    l = l->next;
393
    l = l->next;
394
  }
394
  }
395
 
395
 
396
  errflag |= dosfclose(fd);
396
  errflag |= dos_fclose(fd);
397
 
397
 
398
  /* did it all work? */
398
  /* did it all work? */
399
  if (errflag == 0) {
399
  if (errflag == 0) {
400
    db->modflag = 0;
400
    db->modflag = 0;
401
    if (saveas != db->fname) mdr_dos_truename(db->fname, saveas);
401
    if (saveas != db->fname) mdr_dos_truename(db->fname, saveas);
Line 808... Line 808...
808
  db->lfonly = 1;
808
  db->lfonly = 1;
809
 
809
 
810
  for (eolfound = 0;;) {
810
  for (eolfound = 0;;) {
811
    unsigned short consumedbytes;
811
    unsigned short consumedbytes;
812
 
812
 
813
    if ((dosfread(fd, buff, sizeof(buff), &len) != 0) || (len == 0)) break;
813
    if ((dos_fread(fd, buff, sizeof(buff), &len) != 0) || (len == 0)) break;
814
    buffptr = buff;
814
    buffptr = buff;
815
 
815
 
816
    FINDLINE:
816
    FINDLINE:
817
 
817
 
818
    /* look for nearest \n (also expand tabs) */
818
    /* look for nearest \n (also expand tabs) */
Line 872... Line 872...
872
      goto FINDLINE;
872
      goto FINDLINE;
873
    }
873
    }
874
 
874
 
875
  }
875
  }
876
 
876
 
877
  dosfclose(fd);
877
  dos_fclose(fd);
878
 
878
 
879
  SKIPLOADING:
879
  SKIPLOADING:
880
 
880
 
881
  /* rewind cursor to top of file because it has been used by line_add() */
881
  /* rewind cursor to top of file because it has been used by line_add() */
882
  db_rewind(db);
882
  db_rewind(db);
883
 
883
 
884
  return(err);
884
  return(err);
885
 
885
 
886
  IOERR:
886
  IOERR:
887
  dosfclose(fd);
887
  dos_fclose(fd);
888
  return(1);
888
  return(1);
889
}
889
}
890
 
890
 
891
 
891
 
892
/* a custom argv-parsing routine that looks directly inside the PSP, avoids the need
892
/* a custom argv-parsing routine that looks directly inside the PSP, avoids the need