File: dosemu.c

package info (click to toggle)
fdclone 2.00a-1woody3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,448 kB
  • ctags: 4,594
  • sloc: ansic: 56,823; sh: 438; makefile: 419; sed: 124
file content (751 lines) | stat: -rw-r--r-- 14,634 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
/*
 *	dosemu.c
 *
 *	UNIX Function Emulation for DOS
 */

#include "fd.h"
#include "func.h"
#include "kctype.h"
#include "dosdisk.h"

#ifdef	_NOKANJIFCONV
#define	convget(buf, s)	(s)
#define	convput(buf, s)	(s)
#else
#define	convget(buf, s)	kanjiconv2(buf, s, MAXPATHLEN - 1, \
			getkcode(s), DEFCODE)
#define	convput(buf, s)	kanjiconv2(buf, s, MAXPATHLEN - 1, \
			DEFCODE, getkcode(s))

char *sjispath = NULL;
char *eucpath = NULL;
char *jis7path = NULL;
char *jis8path = NULL;
char *junetpath = NULL;
char *ojis7path = NULL;
char *ojis8path = NULL;
char *ojunetpath = NULL;
char *hexpath = NULL;
char *cappath = NULL;
char *utf8path = NULL;
char *noconvpath = NULL;
#endif

#ifndef	_NODOSDRIVE
static char pseudocwd[MAXPATHLEN] = "";
int lastdrv = -1;
int dosdrive = 0;


int _dospath(path)
char *path;
{
	if (!dosdrive) return(0);
	return((isalpha(*path) && path[1] == ':') ? *path : 0);
}

int dospath(path, buf)
char *path, *buf;
{
	char *cp, tmp[MAXPATHLEN];
	int drive;

	if (!dosdrive) return(0);
	if (_dospath(path)) cp = path;
	else if (*path == _SC_ || !_dospath(pseudocwd)) return(0);
	else cp = pseudocwd;

	drive = *cp;
	if (!buf) return(drive);
	if (cp == buf) {
		strcpy(tmp, cp);
		cp = tmp;
	}

# ifdef	CODEEUC
	buf[ujis2sjis(buf, (u_char *)cp, MAXPATHLEN - 1)] = '\0';
# else
	strcpy(buf, cp);
# endif
	if (cp != path && *path) {
		buf = strcatdelim(buf);
# ifdef	CODEEUC
		buf[ujis2sjis(buf, (u_char *)path, MAXPATHLEN - 1)] = '\0';
# else
		strcpy(buf, path);
# endif
	}
	return(drive);
}
#endif	/* !_NODOSDRIVE */

#ifndef	_NOKANJIFCONV
int getkcode(path)
char *path;
{
	static int recurse = 0;
	int c;

	if (recurse) return(NOCNV);
	recurse = 1;
# ifndef	_NODOSDRIVE
	if (_dospath(path)) c = SJIS;
	else
# endif
	if (includepath(NULL, path, sjispath)) c = SJIS;
	else if (includepath(NULL, path, eucpath)) c = EUC;
	else if (includepath(NULL, path, jis7path)) c = JIS7;
	else if (includepath(NULL, path, jis8path)) c = JIS8;
	else if (includepath(NULL, path, junetpath)) c = JUNET;
	else if (includepath(NULL, path, ojis7path)) c = O_JIS7;
	else if (includepath(NULL, path, ojis8path)) c = O_JIS8;
	else if (includepath(NULL, path, ojunetpath)) c = O_JUNET;
	else if (includepath(NULL, path, hexpath)) c = HEX;
	else if (includepath(NULL, path, cappath)) c = CAP;
	else if (includepath(NULL, path, utf8path)) c = UTF8;
	else if (includepath(NULL, path, noconvpath)) c = NOCNV;
	else c = fnamekcode;
	recurse = 0;
	return(c);
}
#endif

DIR *_Xopendir(path)
char *path;
{
#if	!defined (_NODOSDRIVE) || !defined (_NOKANJIFCONV)
	char buf[MAXPATHLEN];
#endif

#ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(dosopendir(buf));
#endif
	return(opendir(convput(buf, path)));
}

#ifndef	_NOROCKRIDGE
DIR *Xopendir(path)
char *path;
{
	char buf[MAXPATHLEN];

	if (detransfile(path, buf, 1) == buf) path = buf;
	return(_Xopendir(path));
}
#endif

int Xclosedir(dirp)
DIR *dirp;
{
#ifndef	_NODOSDRIVE
	if (*((int *)dirp) < 0) return(dosclosedir(dirp));
#endif
	closedir(dirp);
	return(0);
}

struct dirent *Xreaddir(dirp)
DIR *dirp;
{
#if	defined (_NOROCKRIDGE) && defined (_NODOSDRIVE) \
&& defined (_NOKANJIFCONV)
	return(readdir(dirp));
#else	/* !_NOROCKRIDGE || !_NODOSDRIVE || !_NOKANJIFCONV */
	static st_dirent buf;
	struct dirent *dp;
	char *cp;
# ifndef	_NOROCKRIDGE
	char tmp[MAXNAMLEN + 1];
# endif

# ifndef	_NODOSDRIVE
	if (*((int *)dirp) < 0) dp = dosreaddir(dirp);
	else
# endif
	dp = readdir(dirp);
	if (!dp) return(NULL);
	cp = ((struct dirent *)&buf) -> d_name;
	memcpy(&buf, dp, cp - (char *)&buf);
	if (*((int *)dirp) < 0)
# ifdef	CODEEUC
		cp[sjis2ujis(cp, (u_char *)(dp -> d_name), MAXNAMLEN)] = '\0';
# else
		strcpy(cp, dp -> d_name);
# endif
	else
# ifndef	_NOKANJIFCONV
	if (convget(cp, dp -> d_name) != cp)
# endif
		strcpy(cp, dp -> d_name);
# ifndef	_NOROCKRIDGE
	if (transfile(cp, tmp) == tmp) strcpy(cp, tmp);
# endif
	return((struct dirent *)&buf);
#endif	/* !_NOROCKRIDGE || !_NODOSDRIVE */
}

VOID Xrewinddir(dirp)
DIR *dirp;
{
#ifndef	_NODOSDRIVE
	if (*((int *)dirp) < 0) dosrewinddir(dirp);
#endif
	rewinddir(dirp);
}

int _Xchdir(path)
char *path;
{
#if	!defined (_NODOSDRIVE) || !defined (_NOKANJIFCONV)
	char buf[MAXPATHLEN];
#endif

#ifdef	_NODOSDRIVE
	return(chdir(convput(buf, path)));
#else	/* !_NODOSDRIVE */
	int dd, drive;

	if ((drive = dospath(path, buf))) {
		if ((dd = preparedrv(drive)) < 0) return(-1);
		if (doschdir(buf) < 0) {
			shutdrv(dd);
			return(-1);
		}
		if (chdir(_SS_) < 0) return(-1);
		if (lastdrv >= 0) {
			if ((lastdrv % DOSNOFILE) != (dd % DOSNOFILE))
				shutdrv(lastdrv);
			else dd = lastdrv;
		}
		lastdrv = dd;
	}
	else {
		if (chdir(convput(buf, path)) < 0) return(-1);
		if (lastdrv >= 0) shutdrv(lastdrv);
		lastdrv = -1;
	}
	if (!Xgetwd(pseudocwd)) {
		*pseudocwd = '\0';
		return(-1);
	}
	return(0);
#endif	/* !_NODOSDRIVE */
}

#ifndef	_NOROCKRIDGE
int Xchdir(path)
char *path;
{
	char buf[MAXPATHLEN];

	if (detransfile(path, buf, 1) == buf) path = buf;
	return(_Xchdir(path));
}
#endif

char *_Xgetwd(path)
char *path;
{
#ifdef	USEGETWD
	return((char *)getwd(path));
#else
	return((char *)getcwd(path, MAXPATHLEN));
#endif
}

char *Xgetwd(path)
char *path;
{
#if	!defined (_NOKANJIFCONV) \
|| (!defined (_NODOSDRIVE) && defined (CODEEUC))
	char buf[MAXPATHLEN];
#endif
	char *cp;

#ifdef	_NODOSDRIVE
	if (!(cp = _Xgetwd(path))) return(NULL);
# ifndef	_NOKANJIFCONV
	if (convget(buf, cp) == buf) strcpy(cp, buf);
# endif
	return(cp);
#else	/* !_NODOSDRIVE */
	if (lastdrv < 0) {
		if (!(cp = _Xgetwd(path))) return(NULL);
# ifndef	_NOKANJIFCONV
		if (convget(buf, cp) == buf) strcpy(cp, buf);
# endif
		return(cp);
	}
	else if (!(cp = dosgetcwd(path, MAXPATHLEN))) return(NULL);

	if (cp[0] >= 'A' && cp[0] <= 'Z') {
		int i;

		for (i = 2; cp[i]; i++) {
			if (issjis1((u_char)(cp[i]))) i++;
			else cp[i] = tolower2(cp[i]);
		}
	}
# ifdef	CODEEUC
	buf[sjis2ujis(buf, (u_char *)cp, MAXPATHLEN - 1)] = '\0';
	strcpy(cp, buf);
# endif
	return(cp);
#endif	/* !_NODOSDRIVE */
}

int Xstat(path, stp)
char *path;
struct stat *stp;
{
#if	!defined (_NOROCKRIDGE) || !defined (_NODOSDRIVE)
	char buf[MAXPATHLEN];
#endif
#ifndef	_NOKANJIFCONV
	char buf2[MAXPATHLEN];
#endif

#ifndef	_NOROCKRIDGE
	if (detransfile(path, buf, 1) == buf) path = buf;
#endif
#ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(dosstat(buf, stp));
#endif
	return(stat(convput(buf2, path), stp) ? -1 : 0);
}

#ifndef	_NOKANJIFCONV
int _Xlstat(path, stp)
char *path;
struct stat *stp;
{
	char buf[MAXPATHLEN];

	return(lstat(convput(buf, path), stp) ? -1 : 0);
}
#endif

int Xlstat(path, stp)
char *path;
struct stat *stp;
{
#if	!defined (_NOROCKRIDGE) || !defined (_NODOSDRIVE)
	char buf[MAXPATHLEN];
#endif
#ifndef	_NOKANJIFCONV
	char buf2[MAXPATHLEN];
#endif

#ifndef	_NOROCKRIDGE
	if (detransfile(path, buf, 0) == buf) path = buf;
#endif
#ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(doslstat(buf, stp));
#endif
	return(lstat(convput(buf2, path), stp) ? -1 : 0);
}

int Xaccess(path, mode)
char *path;
int mode;
{
#if	!defined (_NOROCKRIDGE) || !defined (_NODOSDRIVE)
	char buf[MAXPATHLEN];
#endif
#ifndef	_NOKANJIFCONV
	char buf2[MAXPATHLEN];
#endif

#ifndef	_NOROCKRIDGE
	if (detransfile(path, buf, 1) == buf) path = buf;
#endif
#ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(dosaccess(buf, mode));
#endif
	return(access(convput(buf2, path), mode));
}

int Xsymlink(name1, name2)
char *name1, *name2;
{
#ifndef	_NOKANJIFCONV
	char buf1[MAXPATHLEN], buf2[MAXPATHLEN];
#endif
#ifndef	_NOROCKRIDGE
	char buf[MAXPATHLEN];

	if (detransfile(name1, buf, 0) == buf) name1 = buf;
#endif
#ifndef	_NODOSDRIVE
	if ((dospath(name1, NULL) || dospath(name2, NULL)))
		return(dossymlink(name1, name2));
#endif
	return(symlink(convput(buf1, name1), convput(buf2, name2)));
}

int Xreadlink(path, buf, bufsiz)
char *path, *buf;
int bufsiz;
{
#if	!defined (_NOROCKRIDGE) || !defined (_NOKANJIFCONV)
	char tmp[MAXPATHLEN];
#endif
	char buf2[MAXPATHLEN + 1];
	int len;

#ifndef	_NOROCKRIDGE
	if (detransfile(path, tmp, 0) == tmp) {
		detransfile(path, buf2, 1);
		if (strcmp(tmp, buf2)) {
			errno = EINVAL;
			return(-1);
		}
	}
	else
#endif
	{
#ifndef	_NODOSDRIVE
		if (dospath(path, NULL))
			return(dosreadlink(path, buf, bufsiz));
#endif
		if ((len = readlink(convput(tmp, path), buf2, MAXPATHLEN)) < 0)
			return(-1);
		buf2[len] = '\0';
	}
#ifndef	_NOKANJIFCONV
	if (convget(tmp, buf2) != buf2) strcpy(buf2, tmp);
#endif
	for (len = 0; len < bufsiz && buf2[len]; len++) buf[len] = buf2[len];
	return(len);
}

int Xchmod(path, mode)
char *path;
int mode;
{
#if	!defined (_NOROCKRIDGE) || !defined (_NODOSDRIVE)
	char buf[MAXPATHLEN];
#endif
#ifndef	_NOKANJIFCONV
	char buf2[MAXPATHLEN];
#endif

#ifndef	_NOROCKRIDGE
	if (detransfile(path, buf, 0) == buf) path = buf;
#endif
#ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(doschmod(buf, mode));
#endif
	return(chmod(convput(buf2, path), mode));
}

#ifdef	USEUTIME
int Xutime(path, times)
char *path;
struct utimbuf *times;
{
# if	!defined (_NOROCKRIDGE) || !defined (_NODOSDRIVE)
	char buf[MAXPATHLEN];
# endif
# ifndef	_NOKANJIFCONV
	char buf2[MAXPATHLEN];
# endif

# ifndef	_NOROCKRIDGE
	if (detransfile(path, buf, 0) == buf) path = buf;
# endif
# ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(dosutime(buf, times));
# endif
	return(utime(convput(buf2, path), times));
#else	/* !USEUTIME */
int Xutimes(path, tvp)
char *path;
struct timeval tvp[2];
{
# if	!defined (_NOROCKRIDGE) || !defined (_NODOSDRIVE)
	char buf[MAXPATHLEN];
# endif
# ifndef	_NOKANJIFCONV
	char buf2[MAXPATHLEN];
# endif

# ifndef	_NOROCKRIDGE
	if (detransfile(path, buf, 0) == buf) path = buf;
# endif
# ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(dosutimes(buf, tvp));
# endif
	return(utimes(convput(buf2, path), tvp));
#endif	/* !USEUTIME */
}

int Xunlink(path)
char *path;
{
#if	!defined (_NOROCKRIDGE) || !defined (_NODOSDRIVE)
	char buf[MAXPATHLEN];
#endif
#ifndef	_NOKANJIFCONV
	char buf2[MAXPATHLEN];
#endif

#ifndef	_NOROCKRIDGE
	if (detransfile(path, buf, 0) == buf) path = buf;
#endif
#ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(dosunlink(buf));
#endif
	return(unlink(convput(buf2, path)));
}

int Xrename(from, to)
char *from, *to;
{
#if	!defined (_NOROCKRIDGE) || !defined (_NODOSDRIVE) \
|| !defined (_NOKANJIFCONV)
	char buf1[MAXPATHLEN], buf2[MAXPATHLEN];
#endif

#ifndef	_NOROCKRIDGE
	if (detransfile(from, buf1, 0) == buf1) from = buf1;
	if (detransfile(to, buf2, 0) == buf2) to = buf2;
#endif
#ifndef	_NODOSDRIVE
	errno = EXDEV;
	if (dospath(from, buf1))
		return(dospath(to, buf2) ? dosrename(buf1, buf2) : -1);
	else if (dospath(to, NULL)) return(-1);
#endif
	return(rename(convput(buf1, from), convput(buf2, to)));
}

int Xopen(path, flags, mode)
char *path;
int flags, mode;
{
#if	!defined (_NOROCKRIDGE) || !defined (_NODOSDRIVE)
	char buf[MAXPATHLEN];
#endif
#ifndef	_NOKANJIFCONV
	char buf2[MAXPATHLEN];
#endif

#ifndef	_NOROCKRIDGE
	if (detransfile(path, buf, 1) == buf) path = buf;
#endif
#ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(dosopen(buf, flags, mode));
#endif
	return(open(convput(buf2, path), flags, mode));
}

#ifndef	_NODOSDRIVE
int Xclose(fd)
int fd;
{
	if (fd >= DOSFDOFFSET) return(dosclose(fd));
	return(close(fd));
}

int Xread(fd, buf, nbytes)
int fd;
char *buf;
int nbytes;
{
	if (fd >= DOSFDOFFSET) return(dosread(fd, buf, nbytes));
	return(read(fd, buf, nbytes));
}

int Xwrite(fd, buf, nbytes)
int fd;
char *buf;
int nbytes;
{
	if (fd >= DOSFDOFFSET) return(doswrite(fd, buf, nbytes));
	return(write(fd, buf, nbytes));
}

off_t Xlseek(fd, offset, whence)
int fd;
off_t offset;
int whence;
{
	if (fd >= DOSFDOFFSET) return(doslseek(fd, offset, whence));
	return(lseek(fd, offset, whence));
}

int Xdup(oldd)
int oldd;
{
	if (oldd >= DOSFDOFFSET) {
		errno = EBADF;
		return(-1);
	}
	return(dup(oldd));
}

int Xdup2(oldd, newd)
int oldd, newd;
{
	if (oldd >= DOSFDOFFSET || newd >= DOSFDOFFSET) {
		errno = EBADF;
		return(-1);
	}
	return(dup2(oldd, newd));
}
#endif	/* !_NODOSDRIVE */

#if	!defined (_NODOSDRIVE) || !defined (_NOKANJIFCONV)
int _Xmkdir(path, mode)
char *path;
int mode;
{
	char buf[MAXPATHLEN];

# ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(dosmkdir(buf, mode));
# endif
	return(mkdir(convput(buf, path), mode));
}

int _Xrmdir(path)
char *path;
{
	char buf[MAXPATHLEN];

# ifndef	_NODOSDRIVE
	if (dospath(path, buf)) return(dosrmdir(buf));
# endif
	return(rmdir(convput(buf, path)));
}
#endif

#ifndef	_NOROCKRIDGE
int Xmkdir(path, mode)
char *path;
int mode;
{
	char buf[MAXPATHLEN];

	if (detransfile(path, buf, 0) == buf) path = buf;
	return(_Xmkdir(path, mode));
}

int Xrmdir(path)
char *path;
{
	char buf[MAXPATHLEN];

	if (detransfile(path, buf, 0) == buf) path = buf;
	return(_Xrmdir(path));
}
#endif

#if	!defined (_NODOSDRIVE) || !defined (_NOKANJIFCONV)
FILE *_Xfopen(path, type)
char *path, *type;
{
	char buf[MAXPATHLEN];

# ifndef	_NODOSDRIVE
	if (dospath(path, buf))  return(dosfopen(buf, type));
# endif
	return(fopen(convput(buf, path), type));
}
#endif

#ifndef	_NOROCKRIDGE
FILE *Xfopen(path, type)
char *path, *type;
{
	char buf[MAXPATHLEN];

	if (detransfile(path, buf, 1) == buf) path = buf;
	return(_Xfopen(path, type));
}
#endif

#ifndef	_NODOSDRIVE
FILE *Xfdopen(fd, type)
int fd;
char *type;
{
	if (fd >= DOSFDOFFSET) return(dosfdopen(fd, type));
	return(fdopen(fd, type));
}

int Xfclose(stream)
FILE *stream;
{
	if (dosfileno(stream) >= 0) return(dosfclose(stream));
	return(fclose(stream));
}

int Xfeof(stream)
FILE *stream;
{
	if (dosfileno(stream) >= 0) return(dosfeof(stream));
	return(feof(stream));
}

int Xfread(buf, size, nitems, stream)
char *buf;
int size, nitems;
FILE *stream;
{
	if (dosfileno(stream) >= 0)
		return(dosfread(buf, size, nitems, stream));
	return(fread(buf, size, nitems, stream));
}

int Xfwrite(buf, size, nitems, stream)
char *buf;
int size, nitems;
FILE *stream;
{
	if (dosfileno(stream) >= 0)
		return(dosfwrite(buf, size, nitems, stream));
	return(fwrite(buf, size, nitems, stream));
}

int Xfflush(stream)
FILE *stream;
{
	if (dosfileno(stream) >= 0) return(dosfflush(stream));
	return(fflush(stream));
}

int Xfgetc(stream)
FILE *stream;
{
	if (dosfileno(stream) >= 0) return(dosfgetc(stream));
	return(fgetc(stream));
}

int Xfputc(c, stream)
int c;
FILE *stream;
{
	if (dosfileno(stream) >= 0) return(dosfputc(c, stream));
	return(fputc(c, stream));
}

char *Xfgets(s, n, stream)
char *s;
int n;
FILE *stream;
{
	if (dosfileno(stream) >= 0) return(dosfgets(s, n, stream));
	return(fgets(s, n, stream));
}

int Xfputs(s, stream)
char *s;
FILE *stream;
{
	if (dosfileno(stream) >= 0) return(dosfputs(s, stream));
	return(fputs(s, stream));
}
#endif	/* !_NODOSDRIVE */