-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprog5cli.h
158 lines (117 loc) · 2.75 KB
/
prog5cli.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/********************************************************************
prog5cli.f
Class: CSCI 631 Network Applications Programming
Program: Assignment 5
Author: Vishrant K Gupta
Z-number: z1815637
Date Due: 04/28/17
Purpose: FTP
Execution: Make execute N=5 T=1
*********************************************************************/
#ifndef PROG5CLI_H_
#define PROG5CLI_H_
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <netdb.h>
#include <sys/socket.h>
#include "util5cli.h"
#include <wordexp.h>
#include "/home/cs631/common/in-out.h"
#define DEFAULT_PORT 9880
//#define MAXLINE 1024
#define CMD 0
// arg 1 index
#define ARG1 1
// agr 2 index
#define ARG2 2
// not connected message
#define NOT_CONNECTED "Not connected.\n"
// prompt
#define PROMPT "ftp> "
// already connected
#define ALREADY_CONNECTED "Already connected to %s, use close first.\n"
// good bye
#define GOODBYE "Goodbye.\n"
// invalid command
#define INVALID_CMD "?Invalid command\n"
// error
#define ERROR "Error"
// local message
#define LCD_MSG "Local directory now %s\n"
// space
#define SPACE " "
// user home
#define USER_HOME "~"
// backslash zero
#define BACKSLASH_ZERO '\0'
// backslash n
#define BACKSLASH_N '\n'
// help
#define HELP_CMD "%s: %s\n"
// help invalid command
#define HELP_INVALID "help: no help topics match `%s'. Try `help'\n"
// connected message
#define CONNECTED_MSG "Connected to %s.\n"
// inet pton message
#define INET_PTON_MSG "ftp: %s: Name or service not known\n"
// ignore server error index
#define IGNORE_SUCCUESS_CODE 2
// open message
#define OPEN_MSG "usage: open host-name [port]\n"
// to message
#define TO_MSG "(to) "
// cd message
#define CD_MSG "(remote-directory) "
// cd usage
#define CD_USAGE "usage: cd remote-directory\n"
// zero message
#define ZERO '0'
// new line
#define NEWLINE "\n"
#define FGETS_MSG "Error while reading from stream\n"
/*
* Name: client
*
* Prototype:
* bool client(char* ip_addr, char* server_port, bool prompt)
*
* Description:
* Executes command on client and server
*
* Header files:
* prog5cli.h
*
*/
bool client(char* ip_address, char* server_port, bool prompt);
/*
* Name: str_cli
*
* Prototype:
* bool str_cli(int sockfd, char* saddr, bool prompt)
*
* Description:
* Executes command on client and server
*
* Header files:
* prog5cli.h
*
*/
bool str_cli(int sockfd, char* saddr, bool prompt);
/*
* Name: str_echo
*
* Prototype:
* void str_echo(int sockfd, char* command)
*
* Description:
* send to server
*
* Header files:
* prog5cli.h
*/
void str_echo(int sockfd, char* command);
#endif /* PROG5CLI_H_ */