For this assignment write your own limited version of the st

For this assignment, write your own limited version of the stty system command. A man page for the command could look like the following:


NAME

st - change and print terminal line settings

SYNOPSIS

st [SETTING]

DESCRIPTION

Print or change terminal characteristics

-a
print the current settings for iuclc, ouclc, echo, and icanon.

Input Settings:

[-]iuclc
translate upper case characters to lower case

Output Settings:

[-]ouclc
translate lowercase characters to uppercase

Local Settings:

[-]echo
echo input characters

[-]icanon
enable erase, kill, werase, and rprnt special characters


Some Sample Usages:

st
displays synopsis message

st -a
displays all the settings in human readable format.

st -echo
turns off the echoing of characters

st iuclc
turns on translation of upper case characters typed appearing as lower case

You may assume a user will only change one setting at a time.

Hints:

man stty

man tcsetattr

1. understand the problem. 2. plan your solution. 3. implement the solution.

Don\'t forget to check the C library for any functions that could make your life easier.

The above sample usages are not a complete list.
A 10-Point Sample Run [stalica@trig ~]s cc st.c -ost stalicaêtrig ~]5 /st -a -iuclc -olcuc echo icanon [stalica@trig ]s ./st iuclc [stalica@trig ~]s asdfsdfs bash: asdfsdfs: command not found [stalica@trig ]$s ./st -iuclc [stalica@trig ] ASDFSDF bash: ASDFSDF: command not found [stalica@trig ]s ./st -echo [stalica@trig ~Js ./st -echo [stalica@trig ~]S st [SETTING] [stalica@trig ]s -iuclc -olcuc echo icanon [stalica@trig ]S [stalica@trig ]s ./st -a iuclc olcuc echo icanon [stalica@trig js ./st -icanon stalica@trig ]s

Solution

#include<stdio.h>
#include<string.h>
#include<unistd.h>
int main(int argc, char ** argv)
{
        if(strcmp(argv[0],\"./st\")==0 && argc == 1){

                printf(\"Some sample Usages :\ ./st\ \\t displays synopsis message\ \");
                printf(\"./st -a\ \\t displays all the settings in human readable format\ \");
                printf(\"./st -echo\ \\t turns off the echoing of characters\ \");
                printf(\"./st -iuclc\ \\t turns on translation of upper case characters typed appearing as lower case\ \");
                return 0;
        }
        if(strcmp(argv[1],\"-a\")==0){

                execlp(\"/bin/stty\",\"stty\", \"-a\", NULL);
        }
        if(strcmp(argv[1],\"-iuclc\")==0){

                execlp(\"/bin/stty\",\"stty\", \"-iuclc\", NULL);
        }
        if(strcmp(argv[1],\"-ouclc\")==0){

                execlp(\"/bin/stty\",\"stty\", \"-ouclc\", NULL);
        }
        if(strcmp(argv[1],\"-echo\")==0){

                execlp(\"/bin/stty\",\"stty\", \"-echo\", NULL);
        }
        if(strcmp(argv[1],\"-icanon\")==0){

                execlp(\"/bin/stty\",\"stty\", \"-icanon\", NULL);
        }
        else{
                printf(\"-bash :%s command not found\ \",argv[1]);
                return 0;
        }
}

For this assignment, write your own limited version of the stty system command. A man page for the command could look like the following: NAME st - change and p
For this assignment, write your own limited version of the stty system command. A man page for the command could look like the following: NAME st - change and p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site