2525//avoiding double execution
2626#ifndef SHELLOPS_H
2727#define SHELLOPS_H
28- #define GHZ_RL_BUFFERSIZE 1024 //buffer size
28+ #define PYOF_RL_BUFFERSIZE 1024 //buffer size
2929#define EXIT_FAILURE 1 //exit error code
30- #define GHZ_TOK_BUFFERSIZE 64
31- #define GHZ_TOK_DELIM " \t\n\r\a"
30+ #define PYOF_TOK_BUFFERSIZE 64
31+ #define PYOF_TOK_DELIM " \t\n\r\a"
3232// function for reading input
33- char * ghzsh_readLine ();
34- char * * ghzsh_splitLine ();
35- int ghzsh_execute (char * * args );
33+ char * pyoverflow_readLine ();
34+ char * * pyoverflow_splitLine ();
35+ int pyoverflow_execute (char * * args );
3636
3737//loop for shell
38- void ghzsh_loop (void ){
38+ void pyoverflow_loop (void ){
3939 char * line ;
4040 char * * args ;
4141 int status ;
4242
4343 do {
44- printf ("> " );
44+ printf ("PyOverflow-CLI > " );
4545 //reading and executing input
46- line = ghzsh_readLine ();
47- args = ghzsh_splitLine ();
48- status = ghzsh_execute (args );
46+ line = pyoverflow_readLine ();
47+ args = pyoverflow_splitLine ();
48+ status = pyoverflow_execute (args );
4949
5050 //freeing allocated memory
5151 free (line );
@@ -55,9 +55,9 @@ void ghzsh_loop(void){
5555
5656// function for reading input
5757
58- char * ghzsh_readLine (void ){
58+ char * pyoverflow_readLine (void ){
5959 //setting buffer size
60- int bufsize = GHZ_RL_BUFFERSIZE ;
60+ int bufsize = PYOF_RL_BUFFERSIZE ;
6161 //setting buffer position
6262 int position = 0 ;
6363 //allocating memory for buffer
@@ -66,7 +66,7 @@ char *ghzsh_readLine(void){
6666
6767 //handling buffer memory allocation error
6868 if (!buffer ){
69- fprintf (stderr ,"ghz-sh : Buffer Allocation Failed" );
69+ fprintf (stderr ,"pyoverflow-cli : Buffer Allocation Failed" );
7070 exit (EXIT_FAILURE );
7171 }
7272
@@ -85,11 +85,11 @@ char *ghzsh_readLine(void){
8585
8686 //handling event where buffer limit is exceeded
8787 if (position >=bufsize ){
88- bufsize += GHZ_RL_BUFFERSIZE ;
88+ bufsize += PYOF_RL_BUFFERSIZE ;
8989 //realloc the buffer
9090 buffer = (char * )realloc (buffer ,bufsize );
9191 if (!buffer ){
92- fprintf (stderr ,"ghz-sh : Buffer Allocation Error" );
92+ fprintf (stderr ,"pyoverflow-cli : Buffer Allocation Error" );
9393 exit (EXIT_FAILURE );
9494 }
9595 }
@@ -100,27 +100,27 @@ char *ghzsh_readLine(void){
100100}
101101
102102//split line
103- char * * ghzsh_splitLine (){
103+ char * * pyoverflow_splitLine (){
104104 //defining buffersize and position
105- int bufsize = GHZ_TOK_BUFFERSIZE , position = 0 ;
105+ int bufsize = PYOF_TOK_BUFFERSIZE , position = 0 ;
106106 //allocating mem for tokens
107107 char * * tokens = (char * * )malloc (bufsize * sizeof (char * ));
108108 char * token ;
109109 char * line ;
110110
111111 //handling mem allocation failure
112112 if (!tokens ){
113- fprintf (stderr ,"ghz-sh : Buffer Allocation Failed" );
113+ fprintf (stderr ,"pyoverflow-cli : Buffer Allocation Failed" );
114114 exit (EXIT_FAILURE );
115115 }
116- token = strtok (line ,GHZ_TOK_DELIM );
116+ token = strtok (line ,PYOF_TOK_DELIM );
117117 while (token != NULL ){
118118 tokens [position ]= token ;
119119 position ++ ;
120120
121121 //if buffer size exceeds
122122 if (position >=bufsize ){
123- bufsize += GHZ_TOK_BUFFERSIZE ;
123+ bufsize += PYOF_TOK_BUFFERSIZE ;
124124 //realloc bufsize
125125 tokens = realloc (tokens , bufsize * sizeof (char * ));
126126 if (!tokens ) {
@@ -129,14 +129,14 @@ char **ghzsh_splitLine(){
129129 }
130130
131131 }
132- token = strtok (NULL ,GHZ_TOK_DELIM );
132+ token = strtok (NULL ,PYOF_TOK_DELIM );
133133 }
134134 tokens [position ] = NULL ;
135135 return tokens ;
136136}
137137
138138//launch function
139- int ghzsh_launch (char * * args )
139+ int pyoverflow_launch (char * * args )
140140{
141141 pid_t pid , wpid ;
142142 int status ;
@@ -146,12 +146,12 @@ int ghzsh_launch(char **args)
146146 if (pid == 0 ) {
147147 // Child process
148148 if (execvp (args [0 ], args ) == -1 ) {
149- perror ("ghz-sh " );
149+ perror ("pyoverflow-cli " );
150150 }
151151 exit (EXIT_FAILURE );
152152 } else if (pid < 0 ) {
153153 // Error forking
154- perror ("ghz-sh " );
154+ perror ("pyoverflow-cli " );
155155 } else {
156156 // Parent process
157157 do {
@@ -162,7 +162,7 @@ int ghzsh_launch(char **args)
162162 return 1 ;
163163}
164164
165- int ghzsh_execute (char * * args )
165+ int pyoverflow_execute (char * * args )
166166{
167167 int i ;
168168
@@ -171,13 +171,13 @@ int ghzsh_execute(char **args)
171171 return 1 ;
172172 }
173173
174- for (i = 0 ; i < ghzsh_num_builtins (); i ++ ) {
174+ for (i = 0 ; i < pyoverflow_num_builtins (); i ++ ) {
175175 if (strcmp (args [0 ], builtin_str [i ]) == 0 ) {
176176 return (* builtin_func [i ])(args );
177177 }
178178 }
179179
180- return ghzsh_launch (args );
180+ return pyoverflow_launch (args );
181181}
182182
183183
0 commit comments