User Guide
char * string
echo("My name is $name\n");
char * format
It should be noted that unlike echo(), any variables included in the format string passed to printf() are not expanded before the output is generated. The only way to include variable values in the output is to use C styled format definitions (such as "%s" for a string value etc).
Example :
printf("My name is also
%s\n", $name);
int fd
char * format
Example :
$fd = open("/tmp/name","");
fprintf($fd, "My name is $name\n");
close($fd);
char * path
char * access
|
|
|
File is opened for reading |
|
File is opened for writing |
|
File is opened for reading and writing |
|
Create a named pipe in the file system and open it for reading |
|
Create a named pipe in the file system and open it for writing |
|
The contents of the path argument is a shell command. The command is executed and the output of the new process is available to be read from the returned file descriptor |
|
The contents of the path argument is a shell command. The command is executed and any data written to the returned file descriptor is passed as input to the new process |
It should be noted that both the named pipe related modes create the pipe prior to accessing it. If the pipe exists in the file system prior to the call, open() will fail.
Example :
if ($fd < 0) {
echo("Error : $ERRMSG\n");
} else {
fprintf($fd,"This is a test\n");
close($fd);
}
$fd = open("ls -l /etc", "<|");
$line = readln($fd);
printf($line);
close($fd);
int fd
Please note that if you do not close all file descriptors you open then you will eventually run out of file descriptors.
Example :
close ($fd);
int fd
int numBytes
Example :
$buf = read($fd, 80);
if ($buf == "")
{
if ($ERRMSG != "")
{
else
{
}
else
{
printf("$buf\n");
}
close($fd);
int fd
Example :
$line = readln($fd);
int fd
char * token
Please note that the token is a single character value. If more than one character is passed in the token argument, only the first character is used.
Example :
$username = readtok($fd, ":");
printf("Username is '$username'\n");
close($fd);
char * str , * token
Example :
$info = split($line,":");
printf("Username = $info[0]\n");
printf("Full name = $info[1]\n");
printf("Organisation = $info[2]\n");
char * str
int start , end
Example :
$sub = strseg($string, 5,
8,);
char * str
Example :
$line = chop($line);
char * str , * expr1 , * expr2
Example :
$str = tr($str, "A-Z!", "a-z.");
char * str , * expr1 , * expr2
Example :
$str = sub($str, "is", "was");
char * str , * regexp , * pattern
Example :
$new = substr($str, ".* ([A-Z][a-z]*) .*",
"Who's $1?");
char * test
char * filename
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example :
{
echo("/tmp/foo is a block device\n");
}
char * path
Example :
{
echo("ERROR : $ERRMSG\n");
}
int mask
Example :
char * path
int mode
Example :
{
echo("ERROR : $ERRMSG\n");
}
char * path
Example :
{
echo("ERROR : $ERRMSG\n");
}
char * path
Example :
{
echo("ERROR : $ERRMSG\n");
}
char * path
Example :
{
echo("ERROR : $ERRMSG\n");
}
char * old
char * new
Example :
{
echo("ERROR : $ERRMSG\n");
}
char * path
int length
Example :
{
echo("ERROR : $ERRMSG\n");
}
char * path
char * new
Example :
{
echo("ERROR : $ERRMSG\n");
}
char * path
char * new
It should be noted that if the installation process determined that your operating system does not support the symlink() system call this function will not be available.
Example :
{
echo("ERROR : $ERRMSG\n");
}
char * path
|
|
|
Inode number |
|
File mode |
|
Number of links to file |
|
UID |
|
GID |
|
Size of file |
|
atime |
|
mtime |
|
ctime |
|
Block size of file system |
|
Number of file system blocks used |
if ( #$sbuf == 0)
{
echo("ERROR : $ERRMSG\n");
}
else
{
echo("/tmp/foo is $sbuf[5] bytes long\n");
}
sleep ( )
int time
system ( )
char * command
Example :
{
echo("Error running ls! \n");
}
getppid ( )
kill ( )
int pid
int signal
Example :
{
echo("ERROR : $ERRMSG\n");
}
Example :
echo("The number of seconds
since Jan 1 1970 is $time\n");
int time
Example :
printf("The date and time is '%s'\n",
ctime($time));
int sec , min , hour , day , month , year;
Example :
$time2000 = time2unixtime(0,0,0,1,1,2000);
printf("The number of seconds before the end of the century is %d\n",
$time2000 - $time);
int time;
$year = unixtime2year($time);
$month = unixtime2month($time);
$day = unixtime2day($time);
echo("The date is $day/$month/$year\n");
char * fmt; int time;
|
|
|
day of week, using locale's abbreviated weekday names |
|
day of week, using locale's full weekday names |
|
month, using locale's abbreviated month names |
|
month, using locale's full month names |
|
day of month (01-31) |
|
date as %m/%d/%y |
|
Day of month (1-31 with single digits preceded by a space) |
|
hour (00-23) |
|
hour (00-12) |
|
Day of year (001-366) |
|
hour (0-23, blank padded) |
|
hour (1-12, blank padded) |
|
month number (01-12) |
|
minute (00-59) |
|
AM or PM |
|
seconds (00-59) |
|
time as %H:%M:%S |
|
week number in year (01-52) |
|
day of week (0-6, Sunday being 0) |
|
year within the century (00-99) |
|
year including century (e.g. 1999) |
$message = strftime("The time is %H:%M:%S on %A, %e %B", $time);
echo("$message\n");
char * uname
|
|
|
username |
|
password |
|
UID |
|
GID |
|
GECOS |
|
home directory |
|
shell |
if ( # $pwinfo == 0)
{
echo("User 'bambi' does not exist!\n");
exit(1);
}
printf("Bambi's home directory is %s and his uid is %d\n",
$pwinfo[5], (int)$pwinfo[2]);
int UID
char * host
Example :
if ( # $info == 0)
{
echo("Host unknown!\n");
}
else
{
echo("IP Address = $info[1]\n");
}
char * addr
Example :
if ( # $info == 0)
{
echo("Host unknown!\n");
}
else
{
echo("Host name = $info[0]\n");
}
char str
Example :
char *str
Example :
char *filename
Example :