/* * 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 servers_init { LogFlag logFlag; SslFlag sslVerifyFlag; } SERVERS_INIT; typedef struct servers_http { const char *url; char *postData; char *filePath; char **header; char *reply; unsigned int replyLength; int code; } SERVERS_HTTP; typedef struct servers_ftp { const char *url; const FtpsFlag ftpsFlag; char *user_password; char *filePath; unsigned int timeOutMs; int code; } SERVERS_FTP; 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; } SERVERS_SMTP; void servers_init(SERVERS_INIT init); void servers_unit(void); // HTTP API SERVERS_HTTP *new_servers_http(const char *url); void delete_servers_http(SERVERS_HTTP *ptr); void http_get(SERVERS_HTTP *param); void http_post(SERVERS_HTTP *param); void http_put(SERVERS_HTTP *param); // FTP API SERVERS_FTP *new_servers_ftp(const char *url, const FtpsFlag ftpsFlag); void delete_servers_ftp(SERVERS_FTP *ptr); void ftp_servers_check(SERVERS_FTP *param); void ftp_download(SERVERS_FTP *param); void ftp_upload(SERVERS_FTP *param); // SMTP API SERVERS_SMTP *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(SERVERS_SMTP *ptr); void smtp_send_email(SERVERS_SMTP *param); #ifdef __cplusplus } #endif #endif // !SERVERS_H