110 lines
2.9 KiB
C
110 lines
2.9 KiB
C
/*
|
|
* Copyright (c) 2023 Fancy Code.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
#ifndef SERVERS_H
|
|
#define SERVERS_H
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#define SERVERS_PARAM_NULL_MEANS_END NULL
|
|
#define SERVERS_NEVER_TIMEOUT 0
|
|
typedef enum
|
|
{
|
|
SERVERS_CODE_DEFAULT = -1,
|
|
SERVERS_CODE_OK = 0,
|
|
SERVERS_CODE_END
|
|
} ServersCode;
|
|
typedef enum
|
|
{
|
|
FTPS_FLAG_ENABLE = 0,
|
|
FTPS_FLAG_DISABLE,
|
|
FTPS_FLAG_END
|
|
} FtpsFlag;
|
|
typedef enum
|
|
{
|
|
LOG_FLAG_ENABLE = 0,
|
|
LOG_FLAG_DISABLE,
|
|
LOG_FLAG_END
|
|
} LogFlag;
|
|
typedef enum
|
|
{
|
|
SSL_VERIFY_ENABLE = 0,
|
|
SSL_VERIFY_DISABLE,
|
|
SSL_VERIFY_END
|
|
} SslFlag;
|
|
typedef struct ServersInit
|
|
{
|
|
LogFlag logFlag;
|
|
SslFlag sslVerifyFlag;
|
|
} ServerParam;
|
|
typedef struct servers_http
|
|
{
|
|
const char *url;
|
|
char *postData;
|
|
char *filePath;
|
|
char **header;
|
|
char *reply;
|
|
unsigned int replyLength;
|
|
int code;
|
|
} ServerHttp;
|
|
typedef struct servers_ftp
|
|
{
|
|
const char *url;
|
|
const FtpsFlag ftpsFlag;
|
|
char *user_password;
|
|
char *filePath;
|
|
unsigned int timeOutMs;
|
|
int code;
|
|
} ServerFtp;
|
|
typedef struct servers_smtp
|
|
{
|
|
const char *url;
|
|
const char *subject;
|
|
const char *from;
|
|
const char *to;
|
|
const char *userName;
|
|
const char *password;
|
|
const char *date;
|
|
char *inlineText;
|
|
char **toList;
|
|
unsigned int toListLength;
|
|
// char *text;
|
|
// unsigned int textLength;
|
|
char **attachment;
|
|
int code;
|
|
} ServerSmtp;
|
|
void ServersInit(ServerParam init);
|
|
void ServersUnInit(void);
|
|
// HTTP API
|
|
ServerHttp *NewServersHttp(const char *url);
|
|
void DeleteServersHttp(ServerHttp *ptr);
|
|
void HttpGet(ServerHttp *param);
|
|
void HttpPost(ServerHttp *param);
|
|
void HttpPostFile(ServerHttp *param);
|
|
void HttpPut(ServerHttp *param);
|
|
// FTP API
|
|
ServerFtp *NewServersFtp(const char *url, const FtpsFlag ftpsFlag);
|
|
void DeleteServersFtp(ServerFtp *ptr);
|
|
void FtpServersCheck(ServerFtp *param);
|
|
void FtpDownload(ServerFtp *param);
|
|
void FtpUpload(ServerFtp *param);
|
|
// SMTP API
|
|
ServerSmtp *new_servers_smtp(const char *url, const char *subject, const char *from, const char *to,
|
|
const char *userName, const char *password, const char *date);
|
|
void delete_servers_smtp(ServerSmtp *ptr);
|
|
void smtp_send_email(ServerSmtp *param);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif // !SERVERS_H
|