Subversion Repositories SvarDOS

Rev

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

Rev 2050 Rev 2051
Line 181... Line 181...
181
"mov ax, 0x0C0B" \
181
"mov ax, 0x0C0B" \
182
"int 0x21" \
182
"int 0x21" \
183
modify [ax]
183
modify [ax]
184
 
184
 
185
 
185
 
186
#define FILE_TYPE_UNKNOWN 0x00
-
 
187
#define FILE_TYPE_DISK    0x01
-
 
188
#define FILE_TYPE_CHAR    0x02
-
 
189
#define FILE_TYPE_PIPE    0x03
-
 
190
#define FILE_TYPE_REMOTE  0x80
-
 
191
 
-
 
192
/* checks if stdout appears to be redirected. returns 0 if not, non-zero otherwise. */
186
/* checks if stdout appears to be redirected. returns 0 if not, non-zero otherwise. */
193
static unsigned char is_stdout_redirected(void) {
187
static unsigned char is_stdout_redirected(void);
194
  union REGS r;
188
#pragma aux is_stdout_redirected = \
195
 
-
 
196
  r.x.ax = 0x4400;                 /* DOS 2+, IOCTL Get Device Info */
189
"mov ax, 0x4400"    /* DOS 2+, IOCTL Get Device Info */            \
197
  r.x.bx = 0x0001;                 /* file handle (stdout) */
190
"mov bx, 0x0001"    /* file handle (stdout) */                     \
198
 
191
"int 0x21" \
199
  intdos(&r, &r);     /* Clib function to invoke DOS int21h call   */
192
"jc DONE"           /* on error AL contains a non-zero err code */ \
200
 
-
 
201
  /* error? */
-
 
202
  if (r.x.cflag != 0) return(FILE_TYPE_UNKNOWN);
193
"and dl, 0x80"      /* bit 7 of DL is the "CHAR" flag */           \
203
 
-
 
204
  /* if bit 7 is set it is a char dev (not redirected to disk) */
194
"xor dl, 0x80"      /* return 0 if CHAR bit is set */              \
205
  if (r.x.dx & 0x80) return(0);
195
"mov al, dl" \
206
 
196
"DONE:" \
207
  /* assume valid file handle */
197
modify [ax bx dx] \
208
  return(1);
198
value [al]
209
}
-
 
210
 
199
 
211
 
200
 
212
/* sets rows & cols to size of actual console window
201
/* sets rows & cols to size of actual console window
213
 * force NOPAUSE if appears output redirected to a file or
202
 * force NOPAUSE if appears output redirected to a file or
214
 * piped to another program
203
 * piped to another program