Category : UNIX Files
Archive   : UNDEL10.ZIP
Filename : ISTTY.C

 
Output of file : ISTTY.C contained in archive : UNDEL10.ZIP
/* Copyright (c) 1990 Citadel */
/* All Rights Reserved */

#ident "@(#)istty.c 1.1 - 90/08/13"

#include "ansi.h" /* ansi compatibility macros */

/* ansi headers */
#include

/* system headers */
#ifndef SYS_TYPES_H
#include
#define SYS_TYPES_H
#endif
#ifndef SYS_STAT_H
#include
#define SYS_STAT_H
#endif

/* local headers */
#include "syscalls.h"

/*man---------------------------------------------------------------------------
NAME
istty, isftty - test for tty device

SYNOPSIS
int istty(path)
const char *path;

int isftty(fd)
int fd;

DESCRIPTION
Path points to a path name naming a file. The istty function
tests the file type of that file. If it is a character special
file, a non-zero (true) value is returned. If it is not, a zero
(false) is returned. isftty operates in the same manner as
istty, but takes an open file descriptor fd.

DIAGNOSTICS
istty and isftty return a -1 on failure, with errno set to
indicate the error.

------------------------------------------------------------------------------*/
int istty(path)
const char *path;
{
struct stat st;

if (stat(path, &st) == -1) {
return -1;
}

errno = 0;
return st.st_mode & S_IFCHR ? 1 : 0;
}

int isftty(fd)
int fd;
{
struct stat st;

if (fstat(fd, &st) == -1) {
return -1;
}

errno = 0;
return st.st_mode & S_IFCHR ? 1 : 0;
}


  3 Responses to “Category : UNIX Files
Archive   : UNDEL10.ZIP
Filename : ISTTY.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/