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
2218aaaa
Commit
2218aaaa
authored
3 months ago
by
Vanshika Mohan Bongade
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
1ae93929
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
WEEK-8/rshlib.h
+67
-0
67 additions, 0 deletions
WEEK-8/rshlib.h
with
67 additions
and
0 deletions
WEEK-8/rshlib.h
0 → 100644
+
67
−
0
View file @
2218aaaa
#ifndef __RSHLIB_H__
#define __RSHLIB_H__
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<unistd.h>
#define RDSH_DEF_PORT 1234 // Default port
#define RDSH_DEF_SVR_INTFACE "0.0.0.0" // Default server binds to all interfaces
#define RDSH_DEF_CLI_CONNECT "127.0.0.1" // Default client connects to localhost
#define OK 0
#define RDSH_COMM_BUFF_SZ 1024
#define STOP_SERVER_SC 200 // Signal for stopping the server
static
const
char
RDSH_EOF_CHAR
=
0x04
;
#define ERR_RDSH_COMMUNICATION -50
#define ERR_RDSH_SERVER -51
#define ERR_RDSH_CLIENT -52
#define ERR_RDSH_CMD_EXEC -53
#define ERR_RDSH_CMD_PARSE -3
#define WARN_RDSH_NOT_IMPL -99
#define MAX_ARGS 10
typedef
struct
{
char
*
argv
[
MAX_ARGS
];
}
command_t
;
typedef
struct
{
command_t
commands
[
10
];
int
command_count
;
}
command_list_t
;
// ✅ Enum for built-in commands
typedef
enum
{
BI_NOT_BI
=
0
,
BI_CMD_EXIT
,
BI_CMD_STOP_SVR
,
BI_CMD_CD
}
Built_In_Cmds
;
int
start_client
(
char
*
server_ip
,
int
port
);
int
exec_remote_cmd_loop
(
char
*
address
,
int
port
);
int
client_cleanup
(
int
cli_socket
,
char
*
cmd_buff
,
char
*
rsp_buff
,
int
rc
);
int
start_server
(
char
*
ifaces
,
int
port
,
int
is_threaded
);
int
boot_server
(
char
*
ifaces
,
int
port
);
int
process_cli_requests
(
int
svr_socket
);
int
exec_client_requests
(
int
cli_socket
);
int
rsh_execute_pipeline
(
int
cli_sock
,
command_list_t
*
clist
);
int
send_message_eof
(
int
cli_socket
);
int
stop_server
(
int
svr_socket
);
int
build_cmd_list
(
char
*
cmd
,
command_list_t
*
clist
);
Built_In_Cmds
rsh_match_command
(
const
char
*
input
);
int
exec_builtin_command
(
Built_In_Cmds
cmd_type
,
char
*
arg
);
#endif // __RSHLIB_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