Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CS503
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vanshika Mohan Bongade
CS503
Commits
98275dfb
Commit
98275dfb
authored
2 months ago
by
Vanshika Mohan Bongade
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
b0467730
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
WEEK-7/dshlib.h
+45
-0
45 additions, 0 deletions
WEEK-7/dshlib.h
with
45 additions
and
0 deletions
WEEK-7/dshlib.h
0 → 100644
+
45
−
0
View file @
98275dfb
#ifndef DSHLIB_H
#define DSHLIB_H
#include
<stdbool.h>
#define SH_CMD_MAX 512 // Max length of a command line
#define CMD_MAX 10 // Max number of piped commands
#define CMD_ARG_MAX 20 // Max arguments per command
#define OK 0
#define OK_EXIT -1
#define ERR_TOO_MANY_COMMANDS -2
#define ERR_MEMORY -3
#define ERR_EXEC_CMD -4
#define WARN_NO_CMDS -5
#define CMD_WARN_NO_CMD "Warning: No command entered.\n"
#define CMD_ERR_PIPE_LIMIT "Error: Too many commands. Max is %d.\n"
#define EXIT_CMD "exit"
#define SH_PROMPT "dsh3> "
/**
* Structure to store a single command with arguments.
*/
typedef
struct
{
char
*
_cmd_buffer
;
// The full command string
char
*
argv
[
CMD_ARG_MAX
];
// Array of command arguments
char
*
infile
;
// Input redirection file (for `<`)
char
*
outfile
;
// Output redirection file (for `>` and `>>`)
bool
append
;
// True if `>>` (append mode), false if `>` (overwrite mode)
}
cmd_buff_t
;
/**
* Structure to store a list of commands, e.g., for pipelines.
*/
typedef
struct
{
cmd_buff_t
commands
[
CMD_MAX
];
// Array of commands
int
num
;
// Number of commands in the pipeline
}
command_list_t
;
// Function Declarations
int
exec_local_cmd_loop
();
int
build_cmd_list
(
char
*
cmd_line
,
command_list_t
*
clist
);
int
execute_pipeline
(
command_list_t
*
clist
);
int
free_cmd_list
(
command_list_t
*
cmd_lst
);
#endif // DSHLIB_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment