shiocmd_solaris.c revision 34f9b3eef6fdadbda0a846aa4d68691ac40eace5
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2007 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include <shell.h>
#include <stdio.h>
#include <stdbool.h>
#include <option.h>
#include <stk.h>
#include <tm.h>
#include "name.h"
#ifndef SH_DICT
# define SH_DICT "libshell"
#endif
#include <poll.h>
/*
* time formatting related
*/
struct dctime
{
};
{
}
{
char *last;
if(val)
{
int32_t t;
if(flag&NV_INTEGER)
{
t = *(Sfdouble_t*)val;
else
t = *(double*)val;
}
else
{
if(*last)
}
}
else
{
}
}
{
return((Namval_t*)0);
}
{
sizeof(struct dctime),
0,
0,
};
{
if(!dp)
return((Namval_t*)0);
return(np);
}
/*
* mode formatting related
*/
{
}
{
if(val)
{
char *last;
if(flag&NV_INTEGER)
{
else
}
else
{
if(*last)
}
}
else
}
{
0,
};
{
if(!nfp)
return((Namval_t*)0);
return(np);
}
/*
* field related typese and functions
*/
typedef struct _field_
{
char *name; /* field name */
int flags; /* flags */
short offset; /* offset of field into data */
short size; /* size of field */
} Shfield_t;
/*
* lookup field in field table
*/
{
register int i,n;
register const char *cp;
{
if(*cp=='.')
break;
}
{
return(fp);
}
return(0);
}
/*
* class types and functions
*/
typedef struct _class_
{
int nelem; /* number of elements */
int dsize; /* size for data structure */
} Shclass_t;
struct dcclass
{
};
{
return(nq);
}
{
{
}
return(nq);
return(nq);
}
{
register int i,isarray;
if(out)
{
indent++;
}
{
#if 0
/* handle recursive case */
#endif
if(np)
{
isarray=0;
{
isarray=1;
isarray=2;
else
}
if(isarray)
{
if(isarray==2)
continue;
}
while(1)
{
char *fmtq;
if(isarray)
{
}
fmtq = "";
if(!nv_nextsub(np))
break;
}
if(isarray)
{
}
}
}
if(out)
{
if(indent>1)
}
}
{
if(dlete)
outfile = 0;
else
if(!outfile)
return((char*)0);
}
{
}
{
{
}
if(val)
}
{
sizeof(struct dcclass),
0,
0,
};
{
if(!tcp)
return(0);
return(1);
}
/*
* ====================from here down is file class specific
*/
struct filedata
{
int fd;
char *name;
};
{
};
{
sizeof(struct filedata),
};
static const char sh_optopen[] =
"[-?\n@(#)$Id: open (AT&T Labs Research) 2007-05-07 $\n]"
"[-author?David Korn <dgk@research.att.com>]"
"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
"[+NAME? open - create a shell variable correspnding to a file]"
"[+DESCRIPTION?\bopen\b creates the compound variable \avar\a correspinding "
"to the file given by the pathname \afile\a. The elements of \avar\a "
"are the names of elements in the \astat\a structure with the \bst_\b "
"prefix removed.]"
"\avar\a\b.fd\b is the file descriptor.]"
"[a:append?Open for append.]"
"[b:binary?Open in binary mode"
#ifndef O_BINARY
#endif
".]"
"[t:text?Open in text mode"
#ifndef O_TEXT
#endif
".]"
"[c:create?Open for create.]"
"[i:inherit?Open without the close-on-exec bit set.]"
"[I:noinherit?Open with the close-on-exec bit set.]"
"[r:read?Open with read access.]"
"[w:write?Open with write access.]"
"[m:mode]:[mode:=rwrwrw?Open with access mode \amode\a.]"
"[x:exclusive?Open exclusive.]"
"[N:nofollow?If the path names a symbolic link, open fails with ELOOP "
#ifndef O_NOFOLLOW
#endif
".]"
"[S:sync?Write I/O operations on the file descriptor complete as "
"defined by synchronized I/O file integrity completion"
#ifndef O_SYNC
#endif
".]"
"[T:trunc?If the file exists and is a regular file, and the file "
"truncated to 0 and the mode and owner are unchanged. It "
"has no effect on FIFO special files or terminal device "
"files. Its effect on other file types is "
"implementation-dependent. The result of using -T "
"with read-only files is undefined"
#ifndef O_TRUNC
#endif
".]"
"\n"
"\nvar file\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Success.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\btmpfile\b(1),\bdup\b(1),\bclose\b(1),\bstat\b(1),\bpoll\b(1),\bstat\b(2)]"
;
{
register int n,oflag=0;
long flags = 0;
int fd = -1;
char *arg;
{
case 'r':
case 'w':
case 'i':
break;
case 'I':
break;
case 'b':
#ifdef O_BINARY
#endif
break;
case 't':
#ifdef O_TEXT
#endif
break;
case 'N':
#ifdef O_NOFOLLOW
oflag |= O_NOFOLLOW;
#endif
break;
case 'T':
#ifdef O_TRUNC
#endif
break;
case 'x':
break;
case 'c':
break;
case 'a':
break;
case 'S':
#ifdef O_SYNC
#endif
break;
case 'm':
break;
case ':':
break;
case '?':
break;
}
{
else
}
if(fd<0)
return(0);
}
static const char sh_optclose[] =
"[-?\n@(#)$Id: close (AT&T Labs Research) 2007-04-21 $\n]"
"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
"[+NAME? close - close a file descriptor]"
"[+DESCRIPTION?\bclose\b closes the file descriptor specified by fd.]"
"\n"
"\nfd\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Success.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\bopen\b(1),\bdup\b(1),\btmpfile\b(1),\bpoll\b(1),\bstat\b(1)]"
;
{
register int n=0;
int fd = -1;
{
case ':':
break;
case '?':
break;
}
if(argc!=1)
errno = 0;
if (n < 0)
return(n==0?0:1);
}
static const char sh_opttmpfile[] =
"[-?\n@(#)$Id: tmpfile (AT&T Labs Research) 2007-05-07 $\n]"
"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
"[+NAME? tmpfile - create a shell variable correspnding to a temporary file]"
"[+DESCRIPTION?\btmpfile\b creates the compound variable \avar\a correspinding "
"to a temporary file. The elements of \avar\a "
"are the names of elements in the \astat\a structure with the \bst_\b "
"prefix removed.]"
"[i:inherit?Open without the close-on-exec bit set.]"
"[I:noinherit?Open with the close-on-exec bit set.]"
"\n"
"\nvar\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Success.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\bopen\b(1),\bdup\b(1),\bclose\b(1),\bstat\b(1),\bstat\b(2)]"
;
{
register int n;
bool inherit = false;
{
case 'i':
inherit = true;
break;
case 'I':
inherit = false;
break;
case ':':
break;
case '?':
break;
}
if(argc!=1)
if(!file)
if(fd<0)
if(!inherit)
return(0);
}
static const char sh_optdup[] =
"[-?\n@(#)$Id: dup (AT&T Labs Research) 2007-05-07 $\n]"
"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
"[+NAME? dup - duplicate an open file descriptor]"
"[+DESCRIPTION?The \bdup\b commands returns a new file descriptor having the "
"following in common with the original open file descriptor "
"fd: same open file (or pipe), same file pointer (that is, both file descriptors "
"The file descriptor returned is the lowest one available.]"
"[i:inherit?Open without the close-on-exec bit set.]"
"[I:noinherit?Open with the close-on-exec bit set.]"
"\n"
"\nvar fd\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Success.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\bopen\b(1),\btmpfile\b(1),\bclose\b(1),\bpoll\b(1),\bstat\b(1)]"
;
{
register int n;
bool inherit = false;
{
case 'i':
inherit = true;
break;
case 'I':
inherit = false;
break;
case ':':
break;
case '?':
break;
}
if(argc!=2)
errno = 0;
if(fd<0)
if(!inherit)
return(0);
}
static const char sh_optstat[] =
"[-?\n@(#)$Id: stat (AT&T Labs Research) 2007-05-07 $\n]"
"[-author?David Korn <dgk@research.att.com>]"
"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
"[+NAME? stat - get file status]"
"[+DESCRIPTION?\bstat\b creates the compound variable \avar\a correspinding "
"to the file given by the pathname \afile\a. The elements of \avar\a "
"are the names of elements in the \astat\a structure with the \bst_\b "
"prefix removed.]"
"[l:lstat?If the the named file is a symbolic link returns information about "
"the link itself.]"
"\n"
"\nvar file\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Success.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\bopen\b(1),\btmpfile\b(1),\bdup\b(1),\bclose\b(1),\bpoll\b(1),\bstat\b(2),\blstat\b(2)]"
;
{
register int n;
long flags = 0;
{
case 'l':
break;
case ':':
break;
case '?':
break;
}
if(argc!=2)
{
}
else
{
}
return(0);
}
static const char sh_optrewind[] =
"[-?\n@(#)$Id: rewind (AT&T Labs Research) 2007-05-07 $\n]"
"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
"[+NAME? rewind - reset file position indicator in a stream]"
"[+DESCRIPTION?The \brewind\b command will move the file pointer of fd to position 0.]"
"\n"
"\nfd\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Success.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\bopen\b(1),\btmpfile\b(1),\bdup\b(1),\bclose\b(1),\bstat\b(1),\bstat\b(2)]"
;
{
int fd = -1;
register int n;
{
case ':':
break;
case '?':
break;
}
if(argc!=1)
errno = 0;
return(0);
}