Skip to content
Snippets Groups Projects
Select Git revision
  • main default
1 result

kaltura.py

Blame
  • rshlib.h 1.72 KiB
    #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__