asg1-shell-fnptrs

asg1-shell-fnptrs - CMPS-109 Winter 2010 Program 1 Function...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPS-109 • Winter 2010 • Program 1 • Function pointers and a shell page 1 of 5 $Id: asg1-shell-fnptrs.mm,v 1.32 2010-01-05 19:10:19-08 - - $ /afs/cats.ucsc.edu/courses/cmps109-wm/Assignments/asg1-shell-fnptrs 1. Overview Your first C ++ program will familiarize you with the basics of the language ,aswell as the STL (Standard Template Library), whichcontains many classes whichmake data structures problems very easy .You will maintain a tree structure with a simple inheritance hierarchy ,maintained by a map of functions .Programming will be done C ++ style ,not C style :Use iostream , string ,and vec- tor ,rather than cstdio , char * ,and arrays .However ,wewill avoid inheritance and virtual func- tions at this time and use a union instead. 2. Program Specification The program specification is given in terms of a Unix man (1) page. NAME yshell — in memory simulated tree shell SYNOPSIS yshell [ -D flags ] DESCRIPTION This shell reads commands from stdin and write output to stdout, with errors being set to stderr .Eachline read by the shell is parsed into words by splitting using space characters, with any number of spaces between words .There mayalso be leading and trailing spaces .The first word on any line is a command to be simulated, and the rest are operands to that com- mand. If either stdin or stdout is not a tty ,eachline from stdin is echoed to stdout. The commands modify an inode tree ,where eachinode is either a file or a directory .Files con- tain data and directories contain inodes .Aninode is specified by means of a pathname .A pathname consists of a sequence of characters separated by slash ( / )characters. 1 The inode tree has a root, whichisaspecial node ,and also a current inode as well. Whenever a pathname is decoded, if the first character is a slash, decoding begins at the root, otherwise it begins with the current directory .Whenever a pathname component is a dot ( . ), it refers to the current directory .Ifacomponent is a double dot ( .. )itrefers to the parent of the current direc- tory .Every directory has both of these entries ,with the root being its own parent. Every inode has three attributes :aninode number ,whichisuniquely assigned, starting from 1for the root ;contents ,whichisavector of inodes for a directory ,and text for a file ;and a size ,whichisthe byte count for text, and the number of sub-inodes for a directory. OPERANDS None .All input comes from stdin. OPTIONS The -D option is followed by a sequence of flags to enable debugging output, whichiswritten to stderr. COMMANDS The following commands are interpreted. Error messages are printed and nothing is done in the case of invalid operands. # string If the first non-space character on a line is a hash, the line is a comment and is ignored.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/26/2010 for the course CMPS 109 taught by Professor Bailey,d during the Spring '08 term at UCSC.

Page1 / 5

asg1-shell-fnptrs - CMPS-109 Winter 2010 Program 1 Function...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online