Arduino TinyFTP
Loading...
Searching...
No Matches
FTPCommon.h
1#pragma once
2
3#include "Arduino.h"
4#include "Client.h"
5#include "IPAddress.h"
6#include "Stream.h"
7
8#ifndef FTP_ABORT_DELAY_MS
9#define FTP_ABORT_DELAY_MS 300
10#endif
11
12#ifndef FTP_COMMAND_BUFFER_SIZE
13#define FTP_COMMAND_BUFFER_SIZE 300
14#endif
15
16#ifndef FTP_RESULT_BUFFER_SIZE
17#define FTP_RESULT_BUFFER_SIZE 300
18#endif
19
20#ifndef FTP_COMMAND_PORT
21#define FTP_COMMAND_PORT 21
22#endif
23
24#ifndef FTP_MAX_SESSIONS
25#define FTP_MAX_SESSIONS 10
26#endif
27
28#ifndef FTP_REPLY_TIMEOUT_MS
29#define FTP_REPLY_TIMEOUT_MS 10000
30#endif
31
32#ifndef FTP_CONNECT_RETRIES
33#define FTP_CONNECT_RETRIES 10
34#endif
35
36#ifndef FTP_CONNECT_RETRY_DELAY_MS
37#define FTP_CONNECT_RETRY_DELAY_MS 500
38#endif
39
41namespace tinyftp {
42
44enum FileMode { READ_MODE, WRITE_MODE, WRITE_APPEND_MODE };
47enum CurrentOperation { READ_OP, WRITE_OP, LS_OP, NOP, RESERVED_OP };
48enum FTPLogLevel { LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR };
49enum ObjectType { TypeFile, TypeDirectory, TypeUndefined };
50
52inline int findNthInStr(const char *str, char ch, int n) {
53 int occur = 0;
54 for (unsigned int i = 0; i < strlen(str); i++) {
55 if (str[i] == ch) {
56 occur += 1;
57 }
58 if (occur == n) return i;
59 }
60 return -1;
61}
62
63} // namespace tinyftp
FTP client and server functionality.
Definition FTPBasicAPI.h:7
FileMode
File Mode.
Definition FTPCommon.h:44
int findNthInStr(const char *str, char ch, int n)
Provides the position of the n-th occurrence of ch in str (or -1)
Definition FTPCommon.h:52
CurrentOperation
State of a session: RESERVED_OP means a data connection was opened (PASV) but no transfer command was...
Definition FTPCommon.h:47