forked from markus/S_New4
11_8_19
This commit is contained in:
parent
894a5ef55b
commit
c9cdfdac46
@ -1,7 +1,9 @@
|
|||||||
QT -= gui
|
QT -= gui
|
||||||
|
|
||||||
LIBS += -lcurl
|
#LIBS += -lcurl
|
||||||
#LIBS += -LC:\Users\Markus\Desktop\S_New4\S_New4\curl -lcurl
|
#LIBS += -LC:\Users\Markus\Desktop\S_New4\S_New4\curl -lcurl
|
||||||
|
LIBS += -L/home/markus/Qt/S_New4/curl -lcurl
|
||||||
|
|
||||||
|
|
||||||
CONFIG += c++11 console
|
CONFIG += c++11 console
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
|
3
curl/.gitignore
vendored
Executable file
3
curl/.gitignore
vendored
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
curlver.h.dist
|
||||||
|
stamp-h2
|
||||||
|
stamp-h3
|
BIN
curl/LIBCURL.DLL
Executable file
BIN
curl/LIBCURL.DLL
Executable file
Binary file not shown.
2872
curl/curl.h
Executable file
2872
curl/curl.h
Executable file
File diff suppressed because it is too large
Load Diff
77
curl/curlver.h
Executable file
77
curl/curlver.h
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
#ifndef __CURL_CURLVER_H
|
||||||
|
#define __CURL_CURLVER_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
|
* This software is licensed as described in the file COPYING, which
|
||||||
|
* you should have received as part of this distribution. The terms
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/* This header file contains nothing but libcurl version info, generated by
|
||||||
|
a script at release-time. This was made its own header file in 7.11.2 */
|
||||||
|
|
||||||
|
/* This is the global package copyright */
|
||||||
|
#define LIBCURL_COPYRIGHT "1996 - 2019 Daniel Stenberg, <daniel@haxx.se>."
|
||||||
|
|
||||||
|
/* This is the version number of the libcurl package from which this header
|
||||||
|
file origins: */
|
||||||
|
#define LIBCURL_VERSION "7.65.2-DEV"
|
||||||
|
|
||||||
|
/* The numeric version number is also available "in parts" by using these
|
||||||
|
defines: */
|
||||||
|
#define LIBCURL_VERSION_MAJOR 7
|
||||||
|
#define LIBCURL_VERSION_MINOR 65
|
||||||
|
#define LIBCURL_VERSION_PATCH 2
|
||||||
|
|
||||||
|
/* This is the numeric version of the libcurl version number, meant for easier
|
||||||
|
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
||||||
|
always follow this syntax:
|
||||||
|
|
||||||
|
0xXXYYZZ
|
||||||
|
|
||||||
|
Where XX, YY and ZZ are the main version, release and patch numbers in
|
||||||
|
hexadecimal (using 8 bits each). All three numbers are always represented
|
||||||
|
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
|
||||||
|
appears as "0x090b07".
|
||||||
|
|
||||||
|
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
|
||||||
|
and it is always a greater number in a more recent release. It makes
|
||||||
|
comparisons with greater than and less than work.
|
||||||
|
|
||||||
|
Note: This define is the full hex number and _does not_ use the
|
||||||
|
CURL_VERSION_BITS() macro since curl's own configure script greps for it
|
||||||
|
and needs it to contain the full number.
|
||||||
|
*/
|
||||||
|
#define LIBCURL_VERSION_NUM 0x074102
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the date and time when the full source package was created. The
|
||||||
|
* timestamp is not stored in git, as the timestamp is properly set in the
|
||||||
|
* tarballs by the maketgz script.
|
||||||
|
*
|
||||||
|
* The format of the date follows this template:
|
||||||
|
*
|
||||||
|
* "2007-11-23"
|
||||||
|
*/
|
||||||
|
#define LIBCURL_TIMESTAMP "[unreleased]"
|
||||||
|
|
||||||
|
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
|
||||||
|
#define CURL_AT_LEAST_VERSION(x,y,z) \
|
||||||
|
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
|
||||||
|
|
||||||
|
#endif /* __CURL_CURLVER_H */
|
112
curl/easy.h
Executable file
112
curl/easy.h
Executable file
@ -0,0 +1,112 @@
|
|||||||
|
#ifndef __CURL_EASY_H
|
||||||
|
#define __CURL_EASY_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
|
* This software is licensed as described in the file COPYING, which
|
||||||
|
* you should have received as part of this distribution. The terms
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CURL_EXTERN CURL *curl_easy_init(void);
|
||||||
|
CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
|
||||||
|
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
|
||||||
|
CURL_EXTERN void curl_easy_cleanup(CURL *curl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_easy_getinfo()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Request internal information from the curl session with this function. The
|
||||||
|
* third argument MUST be a pointer to a long, a pointer to a char * or a
|
||||||
|
* pointer to a double (as the documentation describes elsewhere). The data
|
||||||
|
* pointed to will be filled in accordingly and can be relied upon only if the
|
||||||
|
* function returns CURLE_OK. This function is intended to get used *AFTER* a
|
||||||
|
* performed transfer, all results from this function are undefined until the
|
||||||
|
* transfer is completed.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_easy_duphandle()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Creates a new curl session handle with the same options set for the handle
|
||||||
|
* passed in. Duplicating a handle could only be a matter of cloning data and
|
||||||
|
* options, internal state info and things like persistent connections cannot
|
||||||
|
* be transferred. It is useful in multithreaded applications when you can run
|
||||||
|
* curl_easy_duphandle() for each new thread to avoid a series of identical
|
||||||
|
* curl_easy_setopt() invokes in every thread.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_easy_reset()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Re-initializes a CURL handle to the default values. This puts back the
|
||||||
|
* handle to the same state as it was in when it was just created.
|
||||||
|
*
|
||||||
|
* It does keep: live connections, the Session ID cache, the DNS cache and the
|
||||||
|
* cookies.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN void curl_easy_reset(CURL *curl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_easy_recv()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Receives data from the connected socket. Use after successful
|
||||||
|
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
|
||||||
|
size_t *n);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_easy_send()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Sends data over the connected socket. Use after successful
|
||||||
|
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
|
||||||
|
size_t buflen, size_t *n);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_easy_upkeep()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Performs connection upkeep for the given session handle.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
50
curl/mprintf.h
Executable file
50
curl/mprintf.h
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef __CURL_MPRINTF_H
|
||||||
|
#define __CURL_MPRINTF_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
|
* This software is licensed as described in the file COPYING, which
|
||||||
|
* you should have received as part of this distribution. The terms
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h> /* needed for FILE */
|
||||||
|
#include "curl.h" /* for CURL_EXTERN */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CURL_EXTERN int curl_mprintf(const char *format, ...);
|
||||||
|
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);
|
||||||
|
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);
|
||||||
|
CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
|
||||||
|
const char *format, ...);
|
||||||
|
CURL_EXTERN int curl_mvprintf(const char *format, va_list args);
|
||||||
|
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);
|
||||||
|
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);
|
||||||
|
CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
|
||||||
|
const char *format, va_list args);
|
||||||
|
CURL_EXTERN char *curl_maprintf(const char *format, ...);
|
||||||
|
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CURL_MPRINTF_H */
|
441
curl/multi.h
Executable file
441
curl/multi.h
Executable file
@ -0,0 +1,441 @@
|
|||||||
|
#ifndef __CURL_MULTI_H
|
||||||
|
#define __CURL_MULTI_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
|
* This software is licensed as described in the file COPYING, which
|
||||||
|
* you should have received as part of this distribution. The terms
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
/*
|
||||||
|
This is an "external" header file. Don't give away any internals here!
|
||||||
|
|
||||||
|
GOALS
|
||||||
|
|
||||||
|
o Enable a "pull" interface. The application that uses libcurl decides where
|
||||||
|
and when to ask libcurl to get/send data.
|
||||||
|
|
||||||
|
o Enable multiple simultaneous transfers in the same thread without making it
|
||||||
|
complicated for the application.
|
||||||
|
|
||||||
|
o Enable the application to select() on its own file descriptors and curl's
|
||||||
|
file descriptors simultaneous easily.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This header file should not really need to include "curl.h" since curl.h
|
||||||
|
* itself includes this file and we expect user applications to do #include
|
||||||
|
* <curl/curl.h> without the need for especially including multi.h.
|
||||||
|
*
|
||||||
|
* For some reason we added this include here at one point, and rather than to
|
||||||
|
* break existing (wrongly written) libcurl applications, we leave it as-is
|
||||||
|
* but with this warning attached.
|
||||||
|
*/
|
||||||
|
#include "curl.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
|
||||||
|
typedef struct Curl_multi CURLM;
|
||||||
|
#else
|
||||||
|
typedef void CURLM;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
|
||||||
|
curl_multi_socket*() soon */
|
||||||
|
CURLM_OK,
|
||||||
|
CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
|
||||||
|
CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
|
||||||
|
CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
|
||||||
|
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
||||||
|
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
||||||
|
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
||||||
|
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
|
||||||
|
attempted to get added - again */
|
||||||
|
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
|
||||||
|
callback */
|
||||||
|
CURLM_LAST
|
||||||
|
} CURLMcode;
|
||||||
|
|
||||||
|
/* just to make code nicer when using curl_multi_socket() you can now check
|
||||||
|
for CURLM_CALL_MULTI_SOCKET too in the same style it works for
|
||||||
|
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
|
||||||
|
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
|
||||||
|
|
||||||
|
/* bitmask bits for CURLMOPT_PIPELINING */
|
||||||
|
#define CURLPIPE_NOTHING 0L
|
||||||
|
#define CURLPIPE_HTTP1 1L
|
||||||
|
#define CURLPIPE_MULTIPLEX 2L
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CURLMSG_NONE, /* first, not used */
|
||||||
|
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
|
||||||
|
the CURLcode of the transfer */
|
||||||
|
CURLMSG_LAST /* last, not used */
|
||||||
|
} CURLMSG;
|
||||||
|
|
||||||
|
struct CURLMsg {
|
||||||
|
CURLMSG msg; /* what this message means */
|
||||||
|
CURL *easy_handle; /* the handle it concerns */
|
||||||
|
union {
|
||||||
|
void *whatever; /* message-specific data */
|
||||||
|
CURLcode result; /* return code for transfer */
|
||||||
|
} data;
|
||||||
|
};
|
||||||
|
typedef struct CURLMsg CURLMsg;
|
||||||
|
|
||||||
|
/* Based on poll(2) structure and values.
|
||||||
|
* We don't use pollfd and POLL* constants explicitly
|
||||||
|
* to cover platforms without poll(). */
|
||||||
|
#define CURL_WAIT_POLLIN 0x0001
|
||||||
|
#define CURL_WAIT_POLLPRI 0x0002
|
||||||
|
#define CURL_WAIT_POLLOUT 0x0004
|
||||||
|
|
||||||
|
struct curl_waitfd {
|
||||||
|
curl_socket_t fd;
|
||||||
|
short events;
|
||||||
|
short revents; /* not supported yet */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_init()
|
||||||
|
*
|
||||||
|
* Desc: inititalize multi-style curl usage
|
||||||
|
*
|
||||||
|
* Returns: a new CURLM handle to use in all 'curl_multi' functions.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLM *curl_multi_init(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_add_handle()
|
||||||
|
*
|
||||||
|
* Desc: add a standard curl handle to the multi stack
|
||||||
|
*
|
||||||
|
* Returns: CURLMcode type, general multi error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
|
||||||
|
CURL *curl_handle);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_remove_handle()
|
||||||
|
*
|
||||||
|
* Desc: removes a curl handle from the multi stack again
|
||||||
|
*
|
||||||
|
* Returns: CURLMcode type, general multi error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
|
||||||
|
CURL *curl_handle);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_fdset()
|
||||||
|
*
|
||||||
|
* Desc: Ask curl for its fd_set sets. The app can use these to select() or
|
||||||
|
* poll() on. We want curl_multi_perform() called as soon as one of
|
||||||
|
* them are ready.
|
||||||
|
*
|
||||||
|
* Returns: CURLMcode type, general multi error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||||
|
fd_set *read_fd_set,
|
||||||
|
fd_set *write_fd_set,
|
||||||
|
fd_set *exc_fd_set,
|
||||||
|
int *max_fd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_wait()
|
||||||
|
*
|
||||||
|
* Desc: Poll on all fds within a CURLM set as well as any
|
||||||
|
* additional fds passed to the function.
|
||||||
|
*
|
||||||
|
* Returns: CURLMcode type, general multi error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
|
||||||
|
struct curl_waitfd extra_fds[],
|
||||||
|
unsigned int extra_nfds,
|
||||||
|
int timeout_ms,
|
||||||
|
int *ret);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_perform()
|
||||||
|
*
|
||||||
|
* Desc: When the app thinks there's data available for curl it calls this
|
||||||
|
* function to read/write whatever there is right now. This returns
|
||||||
|
* as soon as the reads and writes are done. This function does not
|
||||||
|
* require that there actually is data available for reading or that
|
||||||
|
* data can be written, it can be called just in case. It returns
|
||||||
|
* the number of handles that still transfer data in the second
|
||||||
|
* argument's integer-pointer.
|
||||||
|
*
|
||||||
|
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
|
||||||
|
* returns errors etc regarding the whole multi stack. There might
|
||||||
|
* still have occurred problems on individual transfers even when
|
||||||
|
* this returns OK.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
|
||||||
|
int *running_handles);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_cleanup()
|
||||||
|
*
|
||||||
|
* Desc: Cleans up and removes a whole multi stack. It does not free or
|
||||||
|
* touch any individual easy handles in any way. We need to define
|
||||||
|
* in what state those handles will be if this function is called
|
||||||
|
* in the middle of a transfer.
|
||||||
|
*
|
||||||
|
* Returns: CURLMcode type, general multi error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_info_read()
|
||||||
|
*
|
||||||
|
* Desc: Ask the multi handle if there's any messages/informationals from
|
||||||
|
* the individual transfers. Messages include informationals such as
|
||||||
|
* error code from the transfer or just the fact that a transfer is
|
||||||
|
* completed. More details on these should be written down as well.
|
||||||
|
*
|
||||||
|
* Repeated calls to this function will return a new struct each
|
||||||
|
* time, until a special "end of msgs" struct is returned as a signal
|
||||||
|
* that there is no more to get at this point.
|
||||||
|
*
|
||||||
|
* The data the returned pointer points to will not survive calling
|
||||||
|
* curl_multi_cleanup().
|
||||||
|
*
|
||||||
|
* The 'CURLMsg' struct is meant to be very simple and only contain
|
||||||
|
* very basic information. If more involved information is wanted,
|
||||||
|
* we will provide the particular "transfer handle" in that struct
|
||||||
|
* and that should/could/would be used in subsequent
|
||||||
|
* curl_easy_getinfo() calls (or similar). The point being that we
|
||||||
|
* must never expose complex structs to applications, as then we'll
|
||||||
|
* undoubtably get backwards compatibility problems in the future.
|
||||||
|
*
|
||||||
|
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
|
||||||
|
* of structs. It also writes the number of messages left in the
|
||||||
|
* queue (after this read) in the integer the second argument points
|
||||||
|
* to.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
|
||||||
|
int *msgs_in_queue);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_strerror()
|
||||||
|
*
|
||||||
|
* Desc: The curl_multi_strerror function may be used to turn a CURLMcode
|
||||||
|
* value into the equivalent human readable error string. This is
|
||||||
|
* useful for printing meaningful error messages.
|
||||||
|
*
|
||||||
|
* Returns: A pointer to a zero-terminated error message.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_socket() and
|
||||||
|
* curl_multi_socket_all()
|
||||||
|
*
|
||||||
|
* Desc: An alternative version of curl_multi_perform() that allows the
|
||||||
|
* application to pass in one of the file descriptors that have been
|
||||||
|
* detected to have "action" on them and let libcurl perform.
|
||||||
|
* See man page for details.
|
||||||
|
*/
|
||||||
|
#define CURL_POLL_NONE 0
|
||||||
|
#define CURL_POLL_IN 1
|
||||||
|
#define CURL_POLL_OUT 2
|
||||||
|
#define CURL_POLL_INOUT 3
|
||||||
|
#define CURL_POLL_REMOVE 4
|
||||||
|
|
||||||
|
#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
|
||||||
|
|
||||||
|
#define CURL_CSELECT_IN 0x01
|
||||||
|
#define CURL_CSELECT_OUT 0x02
|
||||||
|
#define CURL_CSELECT_ERR 0x04
|
||||||
|
|
||||||
|
typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
|
||||||
|
curl_socket_t s, /* socket */
|
||||||
|
int what, /* see above */
|
||||||
|
void *userp, /* private callback
|
||||||
|
pointer */
|
||||||
|
void *socketp); /* private socket
|
||||||
|
pointer */
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_timer_callback
|
||||||
|
*
|
||||||
|
* Desc: Called by libcurl whenever the library detects a change in the
|
||||||
|
* maximum number of milliseconds the app is allowed to wait before
|
||||||
|
* curl_multi_socket() or curl_multi_perform() must be called
|
||||||
|
* (to allow libcurl's timed events to take place).
|
||||||
|
*
|
||||||
|
* Returns: The callback should return zero.
|
||||||
|
*/
|
||||||
|
typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
|
||||||
|
long timeout_ms, /* see above */
|
||||||
|
void *userp); /* private callback
|
||||||
|
pointer */
|
||||||
|
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
|
||||||
|
int *running_handles);
|
||||||
|
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
|
||||||
|
curl_socket_t s,
|
||||||
|
int ev_bitmask,
|
||||||
|
int *running_handles);
|
||||||
|
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
|
||||||
|
int *running_handles);
|
||||||
|
|
||||||
|
#ifndef CURL_ALLOW_OLD_MULTI_SOCKET
|
||||||
|
/* This macro below was added in 7.16.3 to push users who recompile to use
|
||||||
|
the new curl_multi_socket_action() instead of the old curl_multi_socket()
|
||||||
|
*/
|
||||||
|
#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_timeout()
|
||||||
|
*
|
||||||
|
* Desc: Returns the maximum number of milliseconds the app is allowed to
|
||||||
|
* wait before curl_multi_socket() or curl_multi_perform() must be
|
||||||
|
* called (to allow libcurl's timed events to take place).
|
||||||
|
*
|
||||||
|
* Returns: CURLM error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
||||||
|
long *milliseconds);
|
||||||
|
|
||||||
|
#undef CINIT /* re-using the same name as in curl.h */
|
||||||
|
|
||||||
|
#ifdef CURL_ISOCPP
|
||||||
|
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
||||||
|
#else
|
||||||
|
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
|
||||||
|
#define LONG CURLOPTTYPE_LONG
|
||||||
|
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
|
||||||
|
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
|
||||||
|
#define OFF_T CURLOPTTYPE_OFF_T
|
||||||
|
#define CINIT(name,type,number) CURLMOPT_/**/name = type + number
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
/* This is the socket callback function pointer */
|
||||||
|
CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
|
||||||
|
|
||||||
|
/* This is the argument passed to the socket callback */
|
||||||
|
CINIT(SOCKETDATA, OBJECTPOINT, 2),
|
||||||
|
|
||||||
|
/* set to 1 to enable pipelining for this multi handle */
|
||||||
|
CINIT(PIPELINING, LONG, 3),
|
||||||
|
|
||||||
|
/* This is the timer callback function pointer */
|
||||||
|
CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
|
||||||
|
|
||||||
|
/* This is the argument passed to the timer callback */
|
||||||
|
CINIT(TIMERDATA, OBJECTPOINT, 5),
|
||||||
|
|
||||||
|
/* maximum number of entries in the connection cache */
|
||||||
|
CINIT(MAXCONNECTS, LONG, 6),
|
||||||
|
|
||||||
|
/* maximum number of (pipelining) connections to one host */
|
||||||
|
CINIT(MAX_HOST_CONNECTIONS, LONG, 7),
|
||||||
|
|
||||||
|
/* maximum number of requests in a pipeline */
|
||||||
|
CINIT(MAX_PIPELINE_LENGTH, LONG, 8),
|
||||||
|
|
||||||
|
/* a connection with a content-length longer than this
|
||||||
|
will not be considered for pipelining */
|
||||||
|
CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9),
|
||||||
|
|
||||||
|
/* a connection with a chunk length longer than this
|
||||||
|
will not be considered for pipelining */
|
||||||
|
CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10),
|
||||||
|
|
||||||
|
/* a list of site names(+port) that are blacklisted from
|
||||||
|
pipelining */
|
||||||
|
CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11),
|
||||||
|
|
||||||
|
/* a list of server types that are blacklisted from
|
||||||
|
pipelining */
|
||||||
|
CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12),
|
||||||
|
|
||||||
|
/* maximum number of open connections in total */
|
||||||
|
CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13),
|
||||||
|
|
||||||
|
/* This is the server push callback function pointer */
|
||||||
|
CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14),
|
||||||
|
|
||||||
|
/* This is the argument passed to the server push callback */
|
||||||
|
CINIT(PUSHDATA, OBJECTPOINT, 15),
|
||||||
|
|
||||||
|
CURLMOPT_LASTENTRY /* the last unused */
|
||||||
|
} CURLMoption;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_setopt()
|
||||||
|
*
|
||||||
|
* Desc: Sets options for the multi handle.
|
||||||
|
*
|
||||||
|
* Returns: CURLM error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
|
||||||
|
CURLMoption option, ...);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_assign()
|
||||||
|
*
|
||||||
|
* Desc: This function sets an association in the multi handle between the
|
||||||
|
* given socket and a private pointer of the application. This is
|
||||||
|
* (only) useful for curl_multi_socket uses.
|
||||||
|
*
|
||||||
|
* Returns: CURLM error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
|
||||||
|
curl_socket_t sockfd, void *sockp);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_push_callback
|
||||||
|
*
|
||||||
|
* Desc: This callback gets called when a new stream is being pushed by the
|
||||||
|
* server. It approves or denies the new stream.
|
||||||
|
*
|
||||||
|
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
|
||||||
|
*/
|
||||||
|
#define CURL_PUSH_OK 0
|
||||||
|
#define CURL_PUSH_DENY 1
|
||||||
|
|
||||||
|
struct curl_pushheaders; /* forward declaration only */
|
||||||
|
|
||||||
|
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
|
||||||
|
size_t num);
|
||||||
|
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
typedef int (*curl_push_callback)(CURL *parent,
|
||||||
|
CURL *easy,
|
||||||
|
size_t num_headers,
|
||||||
|
struct curl_pushheaders *headers,
|
||||||
|
void *userp);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* end of extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
33
curl/stdcheaders.h
Executable file
33
curl/stdcheaders.h
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __STDC_HEADERS_H
|
||||||
|
#define __STDC_HEADERS_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
|
* This software is licensed as described in the file COPYING, which
|
||||||
|
* you should have received as part of this distribution. The terms
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
size_t fread(void *, size_t, size_t, FILE *);
|
||||||
|
size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||||
|
|
||||||
|
int strcasecmp(const char *, const char *);
|
||||||
|
int strncasecmp(const char *, const char *, size_t);
|
||||||
|
|
||||||
|
#endif /* __STDC_HEADERS_H */
|
493
curl/system.h
Executable file
493
curl/system.h
Executable file
@ -0,0 +1,493 @@
|
|||||||
|
#ifndef __CURL_SYSTEM_H
|
||||||
|
#define __CURL_SYSTEM_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
|
* This software is licensed as described in the file COPYING, which
|
||||||
|
* you should have received as part of this distribution. The terms
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to keep one section per platform, compiler and architecture, otherwise,
|
||||||
|
* if an existing section is reused for a different one and later on the
|
||||||
|
* original is adjusted, probably the piggybacking one can be adversely
|
||||||
|
* changed.
|
||||||
|
*
|
||||||
|
* In order to differentiate between platforms/compilers/architectures use
|
||||||
|
* only compiler built in predefined preprocessor symbols.
|
||||||
|
*
|
||||||
|
* curl_off_t
|
||||||
|
* ----------
|
||||||
|
*
|
||||||
|
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
|
||||||
|
* wide signed integral data type. The width of this data type must remain
|
||||||
|
* constant and independent of any possible large file support settings.
|
||||||
|
*
|
||||||
|
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
|
||||||
|
* wide signed integral data type if there is no 64-bit type.
|
||||||
|
*
|
||||||
|
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
|
||||||
|
* only be violated if off_t is the only 64-bit data type available and the
|
||||||
|
* size of off_t is independent of large file support settings. Keep your
|
||||||
|
* build on the safe side avoiding an off_t gating. If you have a 64-bit
|
||||||
|
* off_t then take for sure that another 64-bit data type exists, dig deeper
|
||||||
|
* and you will find it.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__DJGPP__) || defined(__GO32__)
|
||||||
|
# if defined(__DJGPP__) && (__DJGPP__ > 1)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__SALFORDC__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__BORLANDC__)
|
||||||
|
# if (__BORLANDC__ < 0x520)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__TURBOC__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__WATCOMC__)
|
||||||
|
# if defined(__386__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__POCC__)
|
||||||
|
# if (__POCC__ < 280)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__LCC__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__SYMBIAN32__)
|
||||||
|
# if defined(__EABI__) /* Treat all ARM compilers equally */
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(__CW32__)
|
||||||
|
# pragma longlong on
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(__VC32__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||||
|
|
||||||
|
#elif defined(__MWERKS__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(_WIN32_WCE)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__MINGW32__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_WS2TCPIP_H 1
|
||||||
|
|
||||||
|
#elif defined(__VMS)
|
||||||
|
# if defined(__VAX)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||||
|
|
||||||
|
#elif defined(__OS400__)
|
||||||
|
# if defined(__ILEC400__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(__MVS__)
|
||||||
|
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||||
|
# if defined(_ILP32)
|
||||||
|
# elif defined(_LP64)
|
||||||
|
# endif
|
||||||
|
# if defined(_LONG_LONG)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(_LP64)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(__370__)
|
||||||
|
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||||
|
# if defined(_ILP32)
|
||||||
|
# elif defined(_LP64)
|
||||||
|
# endif
|
||||||
|
# if defined(_LONG_LONG)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(_LP64)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(TPF)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__TINYC__) /* also known as tcc */
|
||||||
|
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
|
||||||
|
# if !defined(__LP64) && (defined(__ILP32) || \
|
||||||
|
defined(__i386) || \
|
||||||
|
defined(__sparcv8) || \
|
||||||
|
defined(__sparcv8plus))
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(__LP64) || \
|
||||||
|
defined(__amd64) || defined(__sparcv9)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
#elif defined(__xlc__) /* IBM xlc compiler */
|
||||||
|
# if !defined(_LP64)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
/* ===================================== */
|
||||||
|
/* KEEP MSVC THE PENULTIMATE ENTRY */
|
||||||
|
/* ===================================== */
|
||||||
|
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
/* ===================================== */
|
||||||
|
/* KEEP GENERIC GCC THE LAST ENTRY */
|
||||||
|
/* ===================================== */
|
||||||
|
|
||||||
|
#elif defined(__GNUC__) && !defined(_SCO_DS)
|
||||||
|
# if !defined(__LP64__) && \
|
||||||
|
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
|
||||||
|
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
|
||||||
|
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
|
||||||
|
defined(__XTENSA__) || \
|
||||||
|
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
|
||||||
|
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(__LP64__) || \
|
||||||
|
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
|
||||||
|
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
|
||||||
|
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* generic "safe guess" on old 32 bit style */
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _AIX
|
||||||
|
/* AIX needs <sys/poll.h> */
|
||||||
|
#define CURL_PULL_SYS_POLL_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
|
||||||
|
/* ws2tcpip.h is required here to properly make type definitions below. */
|
||||||
|
#ifdef CURL_PULL_WS2TCPIP_H
|
||||||
|
# include <winsock2.h>
|
||||||
|
# include <windows.h>
|
||||||
|
# include <ws2tcpip.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
|
||||||
|
/* sys/types.h is required here to properly make type definitions below. */
|
||||||
|
#ifdef CURL_PULL_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
|
||||||
|
/* sys/socket.h is required here to properly make type definitions below. */
|
||||||
|
#ifdef CURL_PULL_SYS_SOCKET_H
|
||||||
|
# include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
|
||||||
|
/* sys/poll.h is required here to properly make type definitions below. */
|
||||||
|
#ifdef CURL_PULL_SYS_POLL_H
|
||||||
|
# include <sys/poll.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Data type definition of curl_socklen_t. */
|
||||||
|
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||||
|
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Data type definition of curl_off_t. */
|
||||||
|
|
||||||
|
#ifdef CURL_TYPEOF_CURL_OFF_T
|
||||||
|
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
|
||||||
|
* these to be visible and exported by the external libcurl interface API,
|
||||||
|
* while also making them visible to the library internals, simply including
|
||||||
|
* curl_setup.h, without actually needing to include curl.h internally.
|
||||||
|
* If some day this section would grow big enough, all this should be moved
|
||||||
|
* to its own header file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Figure out if we can use the ## preprocessor operator, which is supported
|
||||||
|
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
|
||||||
|
* or __cplusplus so we need to carefully check for them too.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
|
||||||
|
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
|
||||||
|
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
|
||||||
|
defined(__ILEC400__)
|
||||||
|
/* This compiler is believed to have an ISO compatible preprocessor */
|
||||||
|
#define CURL_ISOCPP
|
||||||
|
#else
|
||||||
|
/* This compiler is believed NOT to have an ISO compatible preprocessor */
|
||||||
|
#undef CURL_ISOCPP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
|
||||||
|
# define __CURL_OFF_T_C_HLPR2(x) x
|
||||||
|
# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
|
||||||
|
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
|
||||||
|
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
|
||||||
|
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
|
||||||
|
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
|
||||||
|
#else
|
||||||
|
# ifdef CURL_ISOCPP
|
||||||
|
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
|
||||||
|
# else
|
||||||
|
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
|
||||||
|
# endif
|
||||||
|
# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
|
||||||
|
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
|
||||||
|
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CURL_SYSTEM_H */
|
698
curl/typecheck-gcc.h
Executable file
698
curl/typecheck-gcc.h
Executable file
@ -0,0 +1,698 @@
|
|||||||
|
#ifndef __CURL_TYPECHECK_GCC_H
|
||||||
|
#define __CURL_TYPECHECK_GCC_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
|
* This software is licensed as described in the file COPYING, which
|
||||||
|
* you should have received as part of this distribution. The terms
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/* wraps curl_easy_setopt() with typechecking */
|
||||||
|
|
||||||
|
/* To add a new kind of warning, add an
|
||||||
|
* if(_curl_is_sometype_option(_curl_opt))
|
||||||
|
* if(!_curl_is_sometype(value))
|
||||||
|
* _curl_easy_setopt_err_sometype();
|
||||||
|
* block and define _curl_is_sometype_option, _curl_is_sometype and
|
||||||
|
* _curl_easy_setopt_err_sometype below
|
||||||
|
*
|
||||||
|
* NOTE: We use two nested 'if' statements here instead of the && operator, in
|
||||||
|
* order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
|
||||||
|
* when compiling with -Wlogical-op.
|
||||||
|
*
|
||||||
|
* To add an option that uses the same type as an existing option, you'll just
|
||||||
|
* need to extend the appropriate _curl_*_option macro
|
||||||
|
*/
|
||||||
|
#define curl_easy_setopt(handle, option, value) \
|
||||||
|
__extension__ ({ \
|
||||||
|
__typeof__(option) _curl_opt = option; \
|
||||||
|
if(__builtin_constant_p(_curl_opt)) { \
|
||||||
|
if(_curl_is_long_option(_curl_opt)) \
|
||||||
|
if(!_curl_is_long(value)) \
|
||||||
|
_curl_easy_setopt_err_long(); \
|
||||||
|
if(_curl_is_off_t_option(_curl_opt)) \
|
||||||
|
if(!_curl_is_off_t(value)) \
|
||||||
|
_curl_easy_setopt_err_curl_off_t(); \
|
||||||
|
if(_curl_is_string_option(_curl_opt)) \
|
||||||
|
if(!_curl_is_string(value)) \
|
||||||
|
_curl_easy_setopt_err_string(); \
|
||||||
|
if(_curl_is_write_cb_option(_curl_opt)) \
|
||||||
|
if(!_curl_is_write_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_write_callback(); \
|
||||||
|
if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
|
||||||
|
if(!_curl_is_resolver_start_callback(value)) \
|
||||||
|
_curl_easy_setopt_err_resolver_start_callback(); \
|
||||||
|
if((_curl_opt) == CURLOPT_READFUNCTION) \
|
||||||
|
if(!_curl_is_read_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_read_cb(); \
|
||||||
|
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
|
||||||
|
if(!_curl_is_ioctl_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_ioctl_cb(); \
|
||||||
|
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
|
||||||
|
if(!_curl_is_sockopt_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_sockopt_cb(); \
|
||||||
|
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
|
||||||
|
if(!_curl_is_opensocket_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_opensocket_cb(); \
|
||||||
|
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
|
||||||
|
if(!_curl_is_progress_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_progress_cb(); \
|
||||||
|
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
|
||||||
|
if(!_curl_is_debug_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_debug_cb(); \
|
||||||
|
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
|
||||||
|
if(!_curl_is_ssl_ctx_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_ssl_ctx_cb(); \
|
||||||
|
if(_curl_is_conv_cb_option(_curl_opt)) \
|
||||||
|
if(!_curl_is_conv_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_conv_cb(); \
|
||||||
|
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
|
||||||
|
if(!_curl_is_seek_cb(value)) \
|
||||||
|
_curl_easy_setopt_err_seek_cb(); \
|
||||||
|
if(_curl_is_cb_data_option(_curl_opt)) \
|
||||||
|
if(!_curl_is_cb_data(value)) \
|
||||||
|
_curl_easy_setopt_err_cb_data(); \
|
||||||
|
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
|
||||||
|
if(!_curl_is_error_buffer(value)) \
|
||||||
|
_curl_easy_setopt_err_error_buffer(); \
|
||||||
|
if((_curl_opt) == CURLOPT_STDERR) \
|
||||||
|
if(!_curl_is_FILE(value)) \
|
||||||
|
_curl_easy_setopt_err_FILE(); \
|
||||||
|
if(_curl_is_postfields_option(_curl_opt)) \
|
||||||
|
if(!_curl_is_postfields(value)) \
|
||||||
|
_curl_easy_setopt_err_postfields(); \
|
||||||
|
if((_curl_opt) == CURLOPT_HTTPPOST) \
|
||||||
|
if(!_curl_is_arr((value), struct curl_httppost)) \
|
||||||
|
_curl_easy_setopt_err_curl_httpost(); \
|
||||||
|
if((_curl_opt) == CURLOPT_MIMEPOST) \
|
||||||
|
if(!_curl_is_ptr((value), curl_mime)) \
|
||||||
|
_curl_easy_setopt_err_curl_mimepost(); \
|
||||||
|
if(_curl_is_slist_option(_curl_opt)) \
|
||||||
|
if(!_curl_is_arr((value), struct curl_slist)) \
|
||||||
|
_curl_easy_setopt_err_curl_slist(); \
|
||||||
|
if((_curl_opt) == CURLOPT_SHARE) \
|
||||||
|
if(!_curl_is_ptr((value), CURLSH)) \
|
||||||
|
_curl_easy_setopt_err_CURLSH(); \
|
||||||
|
} \
|
||||||
|
curl_easy_setopt(handle, _curl_opt, value); \
|
||||||
|
})
|
||||||
|
|
||||||
|
/* wraps curl_easy_getinfo() with typechecking */
|
||||||
|
#define curl_easy_getinfo(handle, info, arg) \
|
||||||
|
__extension__ ({ \
|
||||||
|
__typeof__(info) _curl_info = info; \
|
||||||
|
if(__builtin_constant_p(_curl_info)) { \
|
||||||
|
if(_curl_is_string_info(_curl_info)) \
|
||||||
|
if(!_curl_is_arr((arg), char *)) \
|
||||||
|
_curl_easy_getinfo_err_string(); \
|
||||||
|
if(_curl_is_long_info(_curl_info)) \
|
||||||
|
if(!_curl_is_arr((arg), long)) \
|
||||||
|
_curl_easy_getinfo_err_long(); \
|
||||||
|
if(_curl_is_double_info(_curl_info)) \
|
||||||
|
if(!_curl_is_arr((arg), double)) \
|
||||||
|
_curl_easy_getinfo_err_double(); \
|
||||||
|
if(_curl_is_slist_info(_curl_info)) \
|
||||||
|
if(!_curl_is_arr((arg), struct curl_slist *)) \
|
||||||
|
_curl_easy_getinfo_err_curl_slist(); \
|
||||||
|
if(_curl_is_tlssessioninfo_info(_curl_info)) \
|
||||||
|
if(!_curl_is_arr((arg), struct curl_tlssessioninfo *)) \
|
||||||
|
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
|
||||||
|
if(_curl_is_certinfo_info(_curl_info)) \
|
||||||
|
if(!_curl_is_arr((arg), struct curl_certinfo *)) \
|
||||||
|
_curl_easy_getinfo_err_curl_certinfo(); \
|
||||||
|
if(_curl_is_socket_info(_curl_info)) \
|
||||||
|
if(!_curl_is_arr((arg), curl_socket_t)) \
|
||||||
|
_curl_easy_getinfo_err_curl_socket(); \
|
||||||
|
if(_curl_is_off_t_info(_curl_info)) \
|
||||||
|
if(!_curl_is_arr((arg), curl_off_t)) \
|
||||||
|
_curl_easy_getinfo_err_curl_off_t(); \
|
||||||
|
} \
|
||||||
|
curl_easy_getinfo(handle, _curl_info, arg); \
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For now, just make sure that the functions are called with three arguments
|
||||||
|
*/
|
||||||
|
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
|
||||||
|
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
|
||||||
|
|
||||||
|
|
||||||
|
/* the actual warnings, triggered by calling the _curl_easy_setopt_err*
|
||||||
|
* functions */
|
||||||
|
|
||||||
|
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
|
||||||
|
#define _CURL_WARNING(id, message) \
|
||||||
|
static void __attribute__((__warning__(message))) \
|
||||||
|
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||||
|
id(void) { __asm__(""); }
|
||||||
|
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_long,
|
||||||
|
"curl_easy_setopt expects a long argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_curl_off_t,
|
||||||
|
"curl_easy_setopt expects a curl_off_t argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_string,
|
||||||
|
"curl_easy_setopt expects a "
|
||||||
|
"string ('char *' or char[]) argument for this option"
|
||||||
|
)
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_write_callback,
|
||||||
|
"curl_easy_setopt expects a curl_write_callback argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_resolver_start_callback,
|
||||||
|
"curl_easy_setopt expects a "
|
||||||
|
"curl_resolver_start_callback argument for this option"
|
||||||
|
)
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_read_cb,
|
||||||
|
"curl_easy_setopt expects a curl_read_callback argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
|
||||||
|
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,
|
||||||
|
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,
|
||||||
|
"curl_easy_setopt expects a "
|
||||||
|
"curl_opensocket_callback argument for this option"
|
||||||
|
)
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_progress_cb,
|
||||||
|
"curl_easy_setopt expects a curl_progress_callback argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_debug_cb,
|
||||||
|
"curl_easy_setopt expects a curl_debug_callback argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb,
|
||||||
|
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_conv_cb,
|
||||||
|
"curl_easy_setopt expects a curl_conv_callback argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_seek_cb,
|
||||||
|
"curl_easy_setopt expects a curl_seek_callback argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_cb_data,
|
||||||
|
"curl_easy_setopt expects a "
|
||||||
|
"private data pointer as argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_error_buffer,
|
||||||
|
"curl_easy_setopt expects a "
|
||||||
|
"char buffer of CURL_ERROR_SIZE as argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_FILE,
|
||||||
|
"curl_easy_setopt expects a 'FILE *' argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_postfields,
|
||||||
|
"curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_curl_httpost,
|
||||||
|
"curl_easy_setopt expects a 'struct curl_httppost *' "
|
||||||
|
"argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_curl_mimepost,
|
||||||
|
"curl_easy_setopt expects a 'curl_mime *' "
|
||||||
|
"argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_curl_slist,
|
||||||
|
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
|
||||||
|
_CURL_WARNING(_curl_easy_setopt_err_CURLSH,
|
||||||
|
"curl_easy_setopt expects a CURLSH* argument for this option")
|
||||||
|
|
||||||
|
_CURL_WARNING(_curl_easy_getinfo_err_string,
|
||||||
|
"curl_easy_getinfo expects a pointer to 'char *' for this info")
|
||||||
|
_CURL_WARNING(_curl_easy_getinfo_err_long,
|
||||||
|
"curl_easy_getinfo expects a pointer to long for this info")
|
||||||
|
_CURL_WARNING(_curl_easy_getinfo_err_double,
|
||||||
|
"curl_easy_getinfo expects a pointer to double for this info")
|
||||||
|
_CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
||||||
|
"curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
|
||||||
|
_CURL_WARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
|
||||||
|
"curl_easy_getinfo expects a pointer to "
|
||||||
|
"'struct curl_tlssessioninfo *' for this info")
|
||||||
|
_CURL_WARNING(_curl_easy_getinfo_err_curl_certinfo,
|
||||||
|
"curl_easy_getinfo expects a pointer to "
|
||||||
|
"'struct curl_certinfo *' for this info")
|
||||||
|
_CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
|
||||||
|
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
|
||||||
|
_CURL_WARNING(_curl_easy_getinfo_err_curl_off_t,
|
||||||
|
"curl_easy_getinfo expects a pointer to curl_off_t for this info")
|
||||||
|
|
||||||
|
/* groups of curl_easy_setops options that take the same type of argument */
|
||||||
|
|
||||||
|
/* To add a new option to one of the groups, just add
|
||||||
|
* (option) == CURLOPT_SOMETHING
|
||||||
|
* to the or-expression. If the option takes a long or curl_off_t, you don't
|
||||||
|
* have to do anything
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* evaluates to true if option takes a long argument */
|
||||||
|
#define _curl_is_long_option(option) \
|
||||||
|
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
|
||||||
|
|
||||||
|
#define _curl_is_off_t_option(option) \
|
||||||
|
((option) > CURLOPTTYPE_OFF_T)
|
||||||
|
|
||||||
|
/* evaluates to true if option takes a char* argument */
|
||||||
|
#define _curl_is_string_option(option) \
|
||||||
|
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
|
||||||
|
(option) == CURLOPT_ACCEPT_ENCODING || \
|
||||||
|
(option) == CURLOPT_ALTSVC || \
|
||||||
|
(option) == CURLOPT_CAINFO || \
|
||||||
|
(option) == CURLOPT_CAPATH || \
|
||||||
|
(option) == CURLOPT_COOKIE || \
|
||||||
|
(option) == CURLOPT_COOKIEFILE || \
|
||||||
|
(option) == CURLOPT_COOKIEJAR || \
|
||||||
|
(option) == CURLOPT_COOKIELIST || \
|
||||||
|
(option) == CURLOPT_CRLFILE || \
|
||||||
|
(option) == CURLOPT_CUSTOMREQUEST || \
|
||||||
|
(option) == CURLOPT_DEFAULT_PROTOCOL || \
|
||||||
|
(option) == CURLOPT_DNS_INTERFACE || \
|
||||||
|
(option) == CURLOPT_DNS_LOCAL_IP4 || \
|
||||||
|
(option) == CURLOPT_DNS_LOCAL_IP6 || \
|
||||||
|
(option) == CURLOPT_DNS_SERVERS || \
|
||||||
|
(option) == CURLOPT_DOH_URL || \
|
||||||
|
(option) == CURLOPT_EGDSOCKET || \
|
||||||
|
(option) == CURLOPT_FTPPORT || \
|
||||||
|
(option) == CURLOPT_FTP_ACCOUNT || \
|
||||||
|
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
|
||||||
|
(option) == CURLOPT_INTERFACE || \
|
||||||
|
(option) == CURLOPT_ISSUERCERT || \
|
||||||
|
(option) == CURLOPT_KEYPASSWD || \
|
||||||
|
(option) == CURLOPT_KRBLEVEL || \
|
||||||
|
(option) == CURLOPT_LOGIN_OPTIONS || \
|
||||||
|
(option) == CURLOPT_MAIL_AUTH || \
|
||||||
|
(option) == CURLOPT_MAIL_FROM || \
|
||||||
|
(option) == CURLOPT_NETRC_FILE || \
|
||||||
|
(option) == CURLOPT_NOPROXY || \
|
||||||
|
(option) == CURLOPT_PASSWORD || \
|
||||||
|
(option) == CURLOPT_PINNEDPUBLICKEY || \
|
||||||
|
(option) == CURLOPT_PRE_PROXY || \
|
||||||
|
(option) == CURLOPT_PROXY || \
|
||||||
|
(option) == CURLOPT_PROXYPASSWORD || \
|
||||||
|
(option) == CURLOPT_PROXYUSERNAME || \
|
||||||
|
(option) == CURLOPT_PROXYUSERPWD || \
|
||||||
|
(option) == CURLOPT_PROXY_CAINFO || \
|
||||||
|
(option) == CURLOPT_PROXY_CAPATH || \
|
||||||
|
(option) == CURLOPT_PROXY_CRLFILE || \
|
||||||
|
(option) == CURLOPT_PROXY_KEYPASSWD || \
|
||||||
|
(option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
|
||||||
|
(option) == CURLOPT_PROXY_SERVICE_NAME || \
|
||||||
|
(option) == CURLOPT_PROXY_SSLCERT || \
|
||||||
|
(option) == CURLOPT_PROXY_SSLCERTTYPE || \
|
||||||
|
(option) == CURLOPT_PROXY_SSLKEY || \
|
||||||
|
(option) == CURLOPT_PROXY_SSLKEYTYPE || \
|
||||||
|
(option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
|
||||||
|
(option) == CURLOPT_PROXY_TLS13_CIPHERS || \
|
||||||
|
(option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
|
||||||
|
(option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
|
||||||
|
(option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
|
||||||
|
(option) == CURLOPT_RANDOM_FILE || \
|
||||||
|
(option) == CURLOPT_RANGE || \
|
||||||
|
(option) == CURLOPT_REFERER || \
|
||||||
|
(option) == CURLOPT_REQUEST_TARGET || \
|
||||||
|
(option) == CURLOPT_RTSP_SESSION_ID || \
|
||||||
|
(option) == CURLOPT_RTSP_STREAM_URI || \
|
||||||
|
(option) == CURLOPT_RTSP_TRANSPORT || \
|
||||||
|
(option) == CURLOPT_SERVICE_NAME || \
|
||||||
|
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
|
||||||
|
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
|
||||||
|
(option) == CURLOPT_SSH_KNOWNHOSTS || \
|
||||||
|
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
|
||||||
|
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
|
||||||
|
(option) == CURLOPT_SSLCERT || \
|
||||||
|
(option) == CURLOPT_SSLCERTTYPE || \
|
||||||
|
(option) == CURLOPT_SSLENGINE || \
|
||||||
|
(option) == CURLOPT_SSLKEY || \
|
||||||
|
(option) == CURLOPT_SSLKEYTYPE || \
|
||||||
|
(option) == CURLOPT_SSL_CIPHER_LIST || \
|
||||||
|
(option) == CURLOPT_TLS13_CIPHERS || \
|
||||||
|
(option) == CURLOPT_TLSAUTH_PASSWORD || \
|
||||||
|
(option) == CURLOPT_TLSAUTH_TYPE || \
|
||||||
|
(option) == CURLOPT_TLSAUTH_USERNAME || \
|
||||||
|
(option) == CURLOPT_UNIX_SOCKET_PATH || \
|
||||||
|
(option) == CURLOPT_URL || \
|
||||||
|
(option) == CURLOPT_USERAGENT || \
|
||||||
|
(option) == CURLOPT_USERNAME || \
|
||||||
|
(option) == CURLOPT_USERPWD || \
|
||||||
|
(option) == CURLOPT_XOAUTH2_BEARER || \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/* evaluates to true if option takes a curl_write_callback argument */
|
||||||
|
#define _curl_is_write_cb_option(option) \
|
||||||
|
((option) == CURLOPT_HEADERFUNCTION || \
|
||||||
|
(option) == CURLOPT_WRITEFUNCTION)
|
||||||
|
|
||||||
|
/* evaluates to true if option takes a curl_conv_callback argument */
|
||||||
|
#define _curl_is_conv_cb_option(option) \
|
||||||
|
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
|
||||||
|
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
|
||||||
|
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
|
||||||
|
|
||||||
|
/* evaluates to true if option takes a data argument to pass to a callback */
|
||||||
|
#define _curl_is_cb_data_option(option) \
|
||||||
|
((option) == CURLOPT_CHUNK_DATA || \
|
||||||
|
(option) == CURLOPT_CLOSESOCKETDATA || \
|
||||||
|
(option) == CURLOPT_DEBUGDATA || \
|
||||||
|
(option) == CURLOPT_FNMATCH_DATA || \
|
||||||
|
(option) == CURLOPT_HEADERDATA || \
|
||||||
|
(option) == CURLOPT_INTERLEAVEDATA || \
|
||||||
|
(option) == CURLOPT_IOCTLDATA || \
|
||||||
|
(option) == CURLOPT_OPENSOCKETDATA || \
|
||||||
|
(option) == CURLOPT_PRIVATE || \
|
||||||
|
(option) == CURLOPT_PROGRESSDATA || \
|
||||||
|
(option) == CURLOPT_READDATA || \
|
||||||
|
(option) == CURLOPT_SEEKDATA || \
|
||||||
|
(option) == CURLOPT_SOCKOPTDATA || \
|
||||||
|
(option) == CURLOPT_SSH_KEYDATA || \
|
||||||
|
(option) == CURLOPT_SSL_CTX_DATA || \
|
||||||
|
(option) == CURLOPT_WRITEDATA || \
|
||||||
|
(option) == CURLOPT_RESOLVER_START_DATA || \
|
||||||
|
(option) == CURLOPT_TRAILERDATA || \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/* evaluates to true if option takes a POST data argument (void* or char*) */
|
||||||
|
#define _curl_is_postfields_option(option) \
|
||||||
|
((option) == CURLOPT_POSTFIELDS || \
|
||||||
|
(option) == CURLOPT_COPYPOSTFIELDS || \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/* evaluates to true if option takes a struct curl_slist * argument */
|
||||||
|
#define _curl_is_slist_option(option) \
|
||||||
|
((option) == CURLOPT_HTTP200ALIASES || \
|
||||||
|
(option) == CURLOPT_HTTPHEADER || \
|
||||||
|
(option) == CURLOPT_MAIL_RCPT || \
|
||||||
|
(option) == CURLOPT_POSTQUOTE || \
|
||||||
|
(option) == CURLOPT_PREQUOTE || \
|
||||||
|
(option) == CURLOPT_PROXYHEADER || \
|
||||||
|
(option) == CURLOPT_QUOTE || \
|
||||||
|
(option) == CURLOPT_RESOLVE || \
|
||||||
|
(option) == CURLOPT_TELNETOPTIONS || \
|
||||||
|
(option) == CURLOPT_CONNECT_TO || \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/* groups of curl_easy_getinfo infos that take the same type of argument */
|
||||||
|
|
||||||
|
/* evaluates to true if info expects a pointer to char * argument */
|
||||||
|
#define _curl_is_string_info(info) \
|
||||||
|
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)
|
||||||
|
|
||||||
|
/* evaluates to true if info expects a pointer to long argument */
|
||||||
|
#define _curl_is_long_info(info) \
|
||||||
|
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
|
||||||
|
|
||||||
|
/* evaluates to true if info expects a pointer to double argument */
|
||||||
|
#define _curl_is_double_info(info) \
|
||||||
|
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
|
||||||
|
|
||||||
|
/* true if info expects a pointer to struct curl_slist * argument */
|
||||||
|
#define _curl_is_slist_info(info) \
|
||||||
|
(((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
|
||||||
|
|
||||||
|
/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
|
||||||
|
#define _curl_is_tlssessioninfo_info(info) \
|
||||||
|
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
|
||||||
|
|
||||||
|
/* true if info expects a pointer to struct curl_certinfo * argument */
|
||||||
|
#define _curl_is_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
|
||||||
|
|
||||||
|
/* true if info expects a pointer to struct curl_socket_t argument */
|
||||||
|
#define _curl_is_socket_info(info) \
|
||||||
|
(CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
|
||||||
|
|
||||||
|
/* true if info expects a pointer to curl_off_t argument */
|
||||||
|
#define _curl_is_off_t_info(info) \
|
||||||
|
(CURLINFO_OFF_T < (info))
|
||||||
|
|
||||||
|
|
||||||
|
/* typecheck helpers -- check whether given expression has requested type*/
|
||||||
|
|
||||||
|
/* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros,
|
||||||
|
* otherwise define a new macro. Search for __builtin_types_compatible_p
|
||||||
|
* in the GCC manual.
|
||||||
|
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
|
||||||
|
* the actual expression passed to the curl_easy_setopt macro. This
|
||||||
|
* means that you can only apply the sizeof and __typeof__ operators, no
|
||||||
|
* == or whatsoever.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* XXX: should evaluate to true if expr is a pointer */
|
||||||
|
#define _curl_is_any_ptr(expr) \
|
||||||
|
(sizeof(expr) == sizeof(void *))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is NULL */
|
||||||
|
/* XXX: must not evaluate expr, so this check is not accurate */
|
||||||
|
#define _curl_is_NULL(expr) \
|
||||||
|
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is type*, const type* or NULL */
|
||||||
|
#define _curl_is_ptr(expr, type) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), type *) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), const type *))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
|
||||||
|
#define _curl_is_arr(expr, type) \
|
||||||
|
(_curl_is_ptr((expr), type) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), type []))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is a string */
|
||||||
|
#define _curl_is_string(expr) \
|
||||||
|
(_curl_is_arr((expr), char) || \
|
||||||
|
_curl_is_arr((expr), signed char) || \
|
||||||
|
_curl_is_arr((expr), unsigned char))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is a long (no matter the signedness)
|
||||||
|
* XXX: for now, int is also accepted (and therefore short and char, which
|
||||||
|
* are promoted to int when passed to a variadic function) */
|
||||||
|
#define _curl_is_long(expr) \
|
||||||
|
(__builtin_types_compatible_p(__typeof__(expr), long) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), int) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), signed int) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), short) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), signed short) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), char) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), signed char) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_off_t */
|
||||||
|
#define _curl_is_off_t(expr) \
|
||||||
|
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
|
||||||
|
/* XXX: also check size of an char[] array? */
|
||||||
|
#define _curl_is_error_buffer(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), char *) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), char[]))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
|
||||||
|
#if 0
|
||||||
|
#define _curl_is_cb_data(expr) \
|
||||||
|
(_curl_is_ptr((expr), void) || \
|
||||||
|
_curl_is_ptr((expr), FILE))
|
||||||
|
#else /* be less strict */
|
||||||
|
#define _curl_is_cb_data(expr) \
|
||||||
|
_curl_is_any_ptr(expr)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type FILE* */
|
||||||
|
#define _curl_is_FILE(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
(__builtin_types_compatible_p(__typeof__(expr), FILE *)))
|
||||||
|
|
||||||
|
/* evaluates to true if expr can be passed as POST data (void* or char*) */
|
||||||
|
#define _curl_is_postfields(expr) \
|
||||||
|
(_curl_is_ptr((expr), void) || \
|
||||||
|
_curl_is_arr((expr), char) || \
|
||||||
|
_curl_is_arr((expr), unsigned char))
|
||||||
|
|
||||||
|
/* helper: __builtin_types_compatible_p distinguishes between functions and
|
||||||
|
* function pointers, hide it */
|
||||||
|
#define _curl_callback_compatible(func, type) \
|
||||||
|
(__builtin_types_compatible_p(__typeof__(func), type) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(func) *, type))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_resolver_start_callback */
|
||||||
|
#define _curl_is_resolver_start_callback(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), curl_resolver_start_callback))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_read_callback or "similar" */
|
||||||
|
#define _curl_is_read_cb(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), __typeof__(fread) *) || \
|
||||||
|
_curl_callback_compatible((expr), curl_read_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_read_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_read_callback2) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_read_callback3) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_read_callback4) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_read_callback5) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_read_callback6))
|
||||||
|
typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
|
||||||
|
typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
|
||||||
|
typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *);
|
||||||
|
typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *);
|
||||||
|
typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
|
||||||
|
typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *);
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_write_callback or "similar" */
|
||||||
|
#define _curl_is_write_cb(expr) \
|
||||||
|
(_curl_is_read_cb(expr) || \
|
||||||
|
_curl_callback_compatible((expr), __typeof__(fwrite) *) || \
|
||||||
|
_curl_callback_compatible((expr), curl_write_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_write_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_write_callback2) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_write_callback3) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_write_callback4) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_write_callback5) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_write_callback6))
|
||||||
|
typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
|
||||||
|
typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
|
||||||
|
const void *);
|
||||||
|
typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *);
|
||||||
|
typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *);
|
||||||
|
typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
|
||||||
|
const void *);
|
||||||
|
typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
|
||||||
|
#define _curl_is_ioctl_cb(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), curl_ioctl_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ioctl_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ioctl_callback2) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ioctl_callback3) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ioctl_callback4))
|
||||||
|
typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *);
|
||||||
|
typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
|
||||||
|
typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *);
|
||||||
|
typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
|
||||||
|
#define _curl_is_sockopt_cb(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), curl_sockopt_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_sockopt_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_sockopt_callback2))
|
||||||
|
typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
|
||||||
|
typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t,
|
||||||
|
curlsocktype);
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_opensocket_callback or
|
||||||
|
"similar" */
|
||||||
|
#define _curl_is_opensocket_cb(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), curl_opensocket_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_opensocket_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_opensocket_callback2) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_opensocket_callback3) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_opensocket_callback4))
|
||||||
|
typedef curl_socket_t (*_curl_opensocket_callback1)
|
||||||
|
(void *, curlsocktype, struct curl_sockaddr *);
|
||||||
|
typedef curl_socket_t (*_curl_opensocket_callback2)
|
||||||
|
(void *, curlsocktype, const struct curl_sockaddr *);
|
||||||
|
typedef curl_socket_t (*_curl_opensocket_callback3)
|
||||||
|
(const void *, curlsocktype, struct curl_sockaddr *);
|
||||||
|
typedef curl_socket_t (*_curl_opensocket_callback4)
|
||||||
|
(const void *, curlsocktype, const struct curl_sockaddr *);
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
|
||||||
|
#define _curl_is_progress_cb(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), curl_progress_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_progress_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_progress_callback2))
|
||||||
|
typedef int (*_curl_progress_callback1)(void *,
|
||||||
|
double, double, double, double);
|
||||||
|
typedef int (*_curl_progress_callback2)(const void *,
|
||||||
|
double, double, double, double);
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
|
||||||
|
#define _curl_is_debug_cb(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), curl_debug_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_debug_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_debug_callback2) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_debug_callback3) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_debug_callback4) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_debug_callback5) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_debug_callback6) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_debug_callback7) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_debug_callback8))
|
||||||
|
typedef int (*_curl_debug_callback1) (CURL *,
|
||||||
|
curl_infotype, char *, size_t, void *);
|
||||||
|
typedef int (*_curl_debug_callback2) (CURL *,
|
||||||
|
curl_infotype, char *, size_t, const void *);
|
||||||
|
typedef int (*_curl_debug_callback3) (CURL *,
|
||||||
|
curl_infotype, const char *, size_t, void *);
|
||||||
|
typedef int (*_curl_debug_callback4) (CURL *,
|
||||||
|
curl_infotype, const char *, size_t, const void *);
|
||||||
|
typedef int (*_curl_debug_callback5) (CURL *,
|
||||||
|
curl_infotype, unsigned char *, size_t, void *);
|
||||||
|
typedef int (*_curl_debug_callback6) (CURL *,
|
||||||
|
curl_infotype, unsigned char *, size_t, const void *);
|
||||||
|
typedef int (*_curl_debug_callback7) (CURL *,
|
||||||
|
curl_infotype, const unsigned char *, size_t, void *);
|
||||||
|
typedef int (*_curl_debug_callback8) (CURL *,
|
||||||
|
curl_infotype, const unsigned char *, size_t, const void *);
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
|
||||||
|
/* this is getting even messier... */
|
||||||
|
#define _curl_is_ssl_ctx_cb(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), curl_ssl_ctx_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_ssl_ctx_callback8))
|
||||||
|
typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
|
||||||
|
typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
|
||||||
|
typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
|
||||||
|
typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *,
|
||||||
|
const void *);
|
||||||
|
#ifdef HEADER_SSL_H
|
||||||
|
/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
|
||||||
|
* this will of course break if we're included before OpenSSL headers...
|
||||||
|
*/
|
||||||
|
typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
|
||||||
|
typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
|
||||||
|
typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
|
||||||
|
typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX,
|
||||||
|
const void *);
|
||||||
|
#else
|
||||||
|
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
|
||||||
|
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
|
||||||
|
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;
|
||||||
|
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
|
||||||
|
#define _curl_is_conv_cb(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), curl_conv_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_conv_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_conv_callback2) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_conv_callback3) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_conv_callback4))
|
||||||
|
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
|
||||||
|
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
|
||||||
|
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
|
||||||
|
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
|
||||||
|
#define _curl_is_seek_cb(expr) \
|
||||||
|
(_curl_is_NULL(expr) || \
|
||||||
|
_curl_callback_compatible((expr), curl_seek_callback) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_seek_callback1) || \
|
||||||
|
_curl_callback_compatible((expr), _curl_seek_callback2))
|
||||||
|
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
|
||||||
|
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __CURL_TYPECHECK_GCC_H */
|
123
curl/urlapi.h
Executable file
123
curl/urlapi.h
Executable file
@ -0,0 +1,123 @@
|
|||||||
|
#ifndef __CURL_URLAPI_H
|
||||||
|
#define __CURL_URLAPI_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
|
* This software is licensed as described in the file COPYING, which
|
||||||
|
* you should have received as part of this distribution. The terms
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "curl.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* the error codes for the URL API */
|
||||||
|
typedef enum {
|
||||||
|
CURLUE_OK,
|
||||||
|
CURLUE_BAD_HANDLE, /* 1 */
|
||||||
|
CURLUE_BAD_PARTPOINTER, /* 2 */
|
||||||
|
CURLUE_MALFORMED_INPUT, /* 3 */
|
||||||
|
CURLUE_BAD_PORT_NUMBER, /* 4 */
|
||||||
|
CURLUE_UNSUPPORTED_SCHEME, /* 5 */
|
||||||
|
CURLUE_URLDECODE, /* 6 */
|
||||||
|
CURLUE_OUT_OF_MEMORY, /* 7 */
|
||||||
|
CURLUE_USER_NOT_ALLOWED, /* 8 */
|
||||||
|
CURLUE_UNKNOWN_PART, /* 9 */
|
||||||
|
CURLUE_NO_SCHEME, /* 10 */
|
||||||
|
CURLUE_NO_USER, /* 11 */
|
||||||
|
CURLUE_NO_PASSWORD, /* 12 */
|
||||||
|
CURLUE_NO_OPTIONS, /* 13 */
|
||||||
|
CURLUE_NO_HOST, /* 14 */
|
||||||
|
CURLUE_NO_PORT, /* 15 */
|
||||||
|
CURLUE_NO_QUERY, /* 16 */
|
||||||
|
CURLUE_NO_FRAGMENT /* 17 */
|
||||||
|
} CURLUcode;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CURLUPART_URL,
|
||||||
|
CURLUPART_SCHEME,
|
||||||
|
CURLUPART_USER,
|
||||||
|
CURLUPART_PASSWORD,
|
||||||
|
CURLUPART_OPTIONS,
|
||||||
|
CURLUPART_HOST,
|
||||||
|
CURLUPART_PORT,
|
||||||
|
CURLUPART_PATH,
|
||||||
|
CURLUPART_QUERY,
|
||||||
|
CURLUPART_FRAGMENT,
|
||||||
|
CURLUPART_ZONEID /* added in 7.65.0 */
|
||||||
|
} CURLUPart;
|
||||||
|
|
||||||
|
#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
|
||||||
|
#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
|
||||||
|
if the port number matches the
|
||||||
|
default for the scheme */
|
||||||
|
#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
|
||||||
|
missing */
|
||||||
|
#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
|
||||||
|
#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
|
||||||
|
#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
|
||||||
|
#define CURLU_URLDECODE (1<<6) /* URL decode on get */
|
||||||
|
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
|
||||||
|
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
|
||||||
|
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
|
||||||
|
|
||||||
|
typedef struct Curl_URL CURLU;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url() creates a new CURLU handle and returns a pointer to it.
|
||||||
|
* Must be freed with curl_url_cleanup().
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLU *curl_url(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url_cleanup() frees the CURLU handle and related resources used for
|
||||||
|
* the URL parsing. It will not free strings previously returned with the URL
|
||||||
|
* API.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
|
||||||
|
* handle must also be freed with curl_url_cleanup().
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url_get() extracts a specific part of the URL from a CURLU
|
||||||
|
* handle. Returns error code. The returned pointer MUST be freed with
|
||||||
|
* curl_free() afterwards.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
|
||||||
|
char **part, unsigned int flags);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
|
||||||
|
* error code. The passed in string will be copied. Passing a NULL instead of
|
||||||
|
* a part string, clears that part.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
|
||||||
|
const char *part, unsigned int flags);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* end of extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
BIN
g++/S_New4
BIN
g++/S_New4
Binary file not shown.
@ -41,12 +41,11 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
|||||||
char *url;
|
char *url;
|
||||||
std::string returnUrl;
|
std::string returnUrl;
|
||||||
|
|
||||||
std::cout << "Lade: '" << Url << "'...";
|
std::cout << "Lade: '" << Url << "'..." << std::flush;
|
||||||
std::cout.flush();
|
|
||||||
|
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if(!curl) {
|
if(!curl) {
|
||||||
perror("\33[2K\rError: Curl easy init failed");
|
perror("\33[2K\r => Error: Curl easy init failed");
|
||||||
return Reply("-1");
|
return Reply("-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,16 +67,14 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
|||||||
for (int timeout = 1; timeout <= maxTimeout; ++timeout) {
|
for (int timeout = 1; timeout <= maxTimeout; ++timeout) {
|
||||||
/* Perform the request, res will get the return code */
|
/* Perform the request, res will get the return code */
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
std::cout << "\33[2K\r";
|
std::cout << "\33[2K\r" << std::flush;
|
||||||
std::cout.flush();
|
|
||||||
|
|
||||||
if(res != CURLE_OK) {
|
if(res != CURLE_OK) {
|
||||||
if(timeout == maxTimeout) {
|
if(timeout == maxTimeout) {
|
||||||
perror((std::string("Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str());
|
perror((std::string(" => Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str());
|
||||||
return Reply("-1");
|
return Reply("-1");
|
||||||
} else {
|
} else {
|
||||||
std::cout << "\33[2K\r" << "Warning: Versuch " << timeout << " von " << maxTimeout << ": curl_easy_perform() failed: " << curl_easy_strerror(res);
|
std::cout << "\33[2K\r" << " => Warning: Versuch " << timeout << " von " << maxTimeout << ": curl_easy_perform() failed: " << curl_easy_strerror(res) << std::flush;
|
||||||
std::cout.flush();
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -89,7 +86,7 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
|||||||
//Get Url
|
//Get Url
|
||||||
res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
|
res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
|
||||||
if( res != CURLE_OK || !url ) {
|
if( res != CURLE_OK || !url ) {
|
||||||
perror((std::string("Error: curl_easy_getinfo failed: ") + curl_easy_strerror(res)).c_str());
|
perror((std::string(" => Error: curl_easy_getinfo failed: ") + curl_easy_strerror(res)).c_str());
|
||||||
return Reply("-1");
|
return Reply("-1");
|
||||||
} else
|
} else
|
||||||
returnUrl=url;
|
returnUrl=url;
|
||||||
@ -104,24 +101,24 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
|||||||
int PageManager::login(Account account)
|
int PageManager::login(Account account)
|
||||||
{
|
{
|
||||||
if(debugMode)
|
if(debugMode)
|
||||||
std::cout << "Melde mit neuem Account an: Email: " << account.Email << " Passowort: " << account.Password << std::endl;
|
std::cout << " > Melde mit neuem Account an: Email: " << account.Email << " Passowort: " << account.Password << std::endl;
|
||||||
|
|
||||||
std::string html = getServerRequest("https://s.to/login", false, std::string("email=" + account.Email + "&password=" + account.Password), true ).html;
|
std::string html = getServerRequest("https://s.to/login", false, std::string("email=" + account.Email + "&password=" + account.Password), true ).html;
|
||||||
if(html == "" )
|
if(html == "" )
|
||||||
return 0;
|
return 0;
|
||||||
else if (html.find("Das Feld Email muss eine gültige E-Mail-Adresse enthalten.") != std::string::npos)
|
else if (html.find("Das Feld Email muss eine gültige E-Mail-Adresse enthalten.") != std::string::npos)
|
||||||
std::cout << "Error: Login failed: Das Feld Email muss eine gültige E-Mail-Adresse enthalten." << std::endl
|
std::cout << " => Error: Login failed: Das Feld Email muss eine gültige E-Mail-Adresse enthalten." << std::endl
|
||||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||||
else if (html.find("Das Passwort ist nicht korrekt") != std::string::npos)
|
else if (html.find("Das Passwort ist nicht korrekt") != std::string::npos)
|
||||||
std::cout << "Error: Login failed: Das Passwort ist nicht korrekt." << std::endl
|
std::cout << " => Error: Login failed: Das Passwort ist nicht korrekt." << std::endl
|
||||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||||
else if (html.find("Ein Account mit dieser E-Mail Adresse wurde nicht gefunden.") != std::string::npos)
|
else if (html.find("Ein Account mit dieser E-Mail Adresse wurde nicht gefunden.") != std::string::npos)
|
||||||
std::cout << "Error: Login failed: Ein Account mit dieser E-Mail Adresse wurde nicht gefunden." << std::endl
|
std::cout << " => Error: Login failed: Ein Account mit dieser E-Mail Adresse wurde nicht gefunden." << std::endl
|
||||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||||
else if(html == "-1")
|
else if(html == "-1")
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
std::cout << "Error: Login failed: Keine Weiterleitung bei Login." << std::endl
|
std::cout << " => Error: Login failed: Keine Weiterleitung bei Login." << std::endl
|
||||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -134,14 +131,14 @@ std::string PageManager::getUrlAfterRedirect(std::string Url)
|
|||||||
std::string PageManager::checkName(std::string Name)
|
std::string PageManager::checkName(std::string Name)
|
||||||
{
|
{
|
||||||
std::string name = replace(Name, " ", "-");
|
std::string name = replace(Name, " ", "-");
|
||||||
std::cout << "Name: " << name << std::endl;
|
std::cout << " > Name: " << name << std::endl;
|
||||||
|
|
||||||
std::string html = getServerRequest("https://s.to/serie/stream/" + name).html;
|
std::string html = getServerRequest("https://s.to/serie/stream/" + name).html;
|
||||||
if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) {
|
if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) {
|
||||||
std::cout << "Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: " << Name << std::endl;
|
std::cout << " => Error: Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: " << Name << std::endl;
|
||||||
return "-1";
|
return "-1";
|
||||||
} else if (html.find("404 - Seite nicht gefunden") != std::string::npos) {
|
} else if (html.find("404 - Seite nicht gefunden") != std::string::npos) {
|
||||||
std::cout << "Ungültiger Name: " << Name << std::endl;
|
std::cout << " => Error: Ungültiger Name: " << Name << std::endl;
|
||||||
return "-1";
|
return "-1";
|
||||||
} else if (html == "-1") {
|
} else if (html == "-1") {
|
||||||
return "-1";
|
return "-1";
|
||||||
@ -155,7 +152,7 @@ std::string PageManager::getLinks(std::string HTML)
|
|||||||
{
|
{
|
||||||
size_t pos = HTML.find("<ul class=\"row\">");
|
size_t pos = HTML.find("<ul class=\"row\">");
|
||||||
if(pos == std::string::npos) {
|
if(pos == std::string::npos) {
|
||||||
std::cout << "Konnte Position von \"" << "<ul class=\"row\">" << " nicht finden" <<std::endl;
|
std::cout << " => Error: Konnte Position von \"" << "<ul class=\"row\">" << " nicht finden" <<std::endl;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +160,7 @@ std::string PageManager::getLinks(std::string HTML)
|
|||||||
|
|
||||||
pos = HTML.find("<script async=");
|
pos = HTML.find("<script async=");
|
||||||
if(pos == std::string::npos) {
|
if(pos == std::string::npos) {
|
||||||
std::cout << "Konnte Position von \"" << "<script async=" << "\" nicht finden" <<std::endl;
|
std::cout << " => Error: Konnte Position von \"" << "<script async=" << "\" nicht finden" <<std::endl;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,11 +219,10 @@ std::string PageManager::getLinks(std::string HTML)
|
|||||||
line.erase(pos,line.length()-pos);
|
line.erase(pos,line.length()-pos);
|
||||||
|
|
||||||
line = replace(line, "title=\"Hoster ", "hoster=\"");
|
line = replace(line, "title=\"Hoster ", "hoster=\"");
|
||||||
|
|
||||||
ReturnValue+=line+"\n";
|
ReturnValue+=line+"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ReturnValue.size() > 0)
|
if(ReturnValue.length() > 0)
|
||||||
return ReturnValue.erase( ReturnValue.size()-1 , 1);
|
return ReturnValue.erase( ReturnValue.size()-1 , 1);
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
@ -278,7 +274,7 @@ int PageManager::writeToFile(std::string path, std::string text)
|
|||||||
std::ofstream of;
|
std::ofstream of;
|
||||||
of.open(path, std::ios::out | std::ios::app);
|
of.open(path, std::ios::out | std::ios::app);
|
||||||
if(!of.is_open()) {
|
if(!of.is_open()) {
|
||||||
perror("Konnte output Datei nicht öffnen");
|
perror(" => Error: Konnte output Datei nicht öffnen");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
of << text << std::endl;
|
of << text << std::endl;
|
||||||
@ -306,7 +302,7 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho
|
|||||||
else if ( langId == "GerSub" )
|
else if ( langId == "GerSub" )
|
||||||
LangId=3;
|
LangId=3;
|
||||||
else {
|
else {
|
||||||
std::cout << "Unbekannte Sprache: " << langId << std::endl;
|
std::cout << " => Error: Unbekannte Sprache: " << langId << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,14 +324,14 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho
|
|||||||
Line = grep(LanguageSortedHoster, ("hoster=\"" + hoster + "\"" ) );
|
Line = grep(LanguageSortedHoster, ("hoster=\"" + hoster + "\"" ) );
|
||||||
pos = Line.find("href=\"");
|
pos = Line.find("href=\"");
|
||||||
if(pos == std::string::npos) {
|
if(pos == std::string::npos) {
|
||||||
std::cout << "Error: Konnte 'href=\"' nicht finden." << std::endl;
|
std::cout << "Error: Konnte 'href=\"' in chooseHosterLink() nicht finden." << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Line.erase(0, pos + static_cast<int>(strlen("href=\"")));
|
Line.erase(0, pos + static_cast<int>(strlen("href=\"")));
|
||||||
|
|
||||||
pos = Line.find("\"");
|
pos = Line.find("\"");
|
||||||
if(pos == std::string::npos) {
|
if(pos == std::string::npos) {
|
||||||
std::cout << "Error: Konnte '\"' nicht finden." << std::endl;
|
std::cout << "Error: Konnte '\"' in chooseHosterLink() nicht finden." << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
// if complied for windows; everything is in */projectfolder/curl/
|
// if complied for windows; everything is in */projectfolder/curl/
|
||||||
#include <curl/curl.h>
|
#include </home/markus/Qt/S_New4/curl/curl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
void setPaths(Settings &settings, std::string executablePathTo)
|
void setPaths(Settings &settings, std::string executablePathTo)
|
||||||
{
|
{
|
||||||
//Path settings
|
//Path settings
|
||||||
executablePathTo.erase(executablePathTo.find_last_of("/\\") + 1 , executablePathTo.length() - ( executablePathTo.find_last_of("/\\") + 1) );
|
executablePathTo.erase(executablePathTo.find_last_of(settings.pathSymbol) + 1 , executablePathTo.length() - ( executablePathTo.find_last_of(settings.pathSymbol) + 1) );
|
||||||
|
|
||||||
if(!dirExists(executablePathTo + "src/"))
|
if(!dirExists(executablePathTo + "src" + settings.pathSymbol))
|
||||||
system(std::string("mkdir \"" + executablePathTo + "src/\"").c_str());
|
system(std::string("mkdir \"" + executablePathTo + "src" + settings.pathSymbol + "\"").c_str());
|
||||||
if(dirExists(executablePathTo + "src/"))
|
if(dirExists(executablePathTo + "src" + settings.pathSymbol))
|
||||||
executablePathTo+="src/";
|
executablePathTo+="src" + std::string(1, settings.pathSymbol);
|
||||||
|
|
||||||
settings.cookieFilePath = executablePathTo + "S_New4_cookies";
|
settings.cookieFilePath = executablePathTo + "S_New4_cookies";
|
||||||
settings.accountFilePath = executablePathTo + "Accounts";
|
settings.accountFilePath = executablePathTo + "Accounts";
|
||||||
@ -89,8 +89,7 @@ int unterOption_default(Settings *settings, int argc, char ** argv)
|
|||||||
int c = 0;
|
int c = 0;
|
||||||
const option long_opts[] = {
|
const option long_opts[] = {
|
||||||
{"name", required_argument, nullptr, 'n'},
|
{"name", required_argument, nullptr, 'n'},
|
||||||
{"ip-addresse", required_argument, nullptr, 'i'},
|
{"socks5-proxy", required_argument, nullptr, 'p'},
|
||||||
{"port", required_argument, nullptr, 'p'},
|
|
||||||
{"genauer-hoster", required_argument, nullptr, 'g'},
|
{"genauer-hoster", required_argument, nullptr, 'g'},
|
||||||
{"languages", required_argument, nullptr, 'l'},
|
{"languages", required_argument, nullptr, 'l'},
|
||||||
{"output-file", required_argument, nullptr, 'o'},
|
{"output-file", required_argument, nullptr, 'o'},
|
||||||
@ -100,6 +99,10 @@ int unterOption_default(Settings *settings, int argc, char ** argv)
|
|||||||
{"start-season", required_argument, nullptr, 's'},
|
{"start-season", required_argument, nullptr, 's'},
|
||||||
{"stop-season", required_argument, nullptr, 'S'},
|
{"stop-season", required_argument, nullptr, 'S'},
|
||||||
|
|
||||||
|
{"check-dir", required_argument, nullptr, 'C'},
|
||||||
|
{"check-muster", required_argument, nullptr, 'm'},
|
||||||
|
{"check-max-dirs", required_argument, nullptr, 't'},
|
||||||
|
|
||||||
|
|
||||||
{"help", no_argument, nullptr, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{"colorless", no_argument, nullptr, 'c'},
|
{"colorless", no_argument, nullptr, 'c'},
|
||||||
@ -109,7 +112,7 @@ int unterOption_default(Settings *settings, int argc, char ** argv)
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
while( ( c = getopt_long (argc, argv, "n:i:p:g:l:o:e:E:s:S:hcd", long_opts, nullptr) ) != -1 ) {
|
while( ( c = getopt_long (argc, argv, "n:p:g:l:o:e:E:s:S:C:m:t:hcd", long_opts, nullptr) ) != -1 ) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'n':
|
case 'n':
|
||||||
if(optarg)
|
if(optarg)
|
||||||
@ -117,20 +120,29 @@ int unterOption_default(Settings *settings, int argc, char ** argv)
|
|||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Name: " << settings->name << std::endl;
|
std::cout << "Name: " << settings->name << std::endl;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'p': {
|
||||||
if(optarg)
|
if(!optarg || std::string(optarg) == "")
|
||||||
settings->proxy_ip = optarg;
|
|
||||||
if(settings->debugMode)
|
|
||||||
std::cout << "Proxy Ip Addresse: " << settings->proxy_ip << std::endl;
|
|
||||||
break;
|
break;
|
||||||
case 'p':
|
std::string optarg = ::optarg;
|
||||||
if(optarg)
|
if(optarg.find(":") == std::string::npos) {
|
||||||
settings->proxy_port = atoi( optarg ) ;
|
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||||
if(std::to_string(settings->proxy_port) != optarg) {
|
return 31;
|
||||||
std::cout << "Invalid Port: " << optarg << std::endl;
|
}
|
||||||
return 10;
|
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||||
} else if(settings->debugMode)
|
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||||
std::cout << "Proxy Port: " << settings->proxy_port << std::endl;
|
int port = atoi(portStr.c_str());
|
||||||
|
if(std::to_string(port) != portStr || port <= 0) {
|
||||||
|
std::cout << "[-p]: Invalid Port: " << portStr << std::endl;
|
||||||
|
return 32;
|
||||||
|
} else if (ip == "") {
|
||||||
|
std::cout << "[-p]: Invalid Ip Addresse: " << ip << std::endl;
|
||||||
|
return 34;
|
||||||
|
} else if(settings->debugMode) {
|
||||||
|
std::cout << "Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||||
|
}
|
||||||
|
settings->proxy_ip = ip;
|
||||||
|
settings->proxy_port = port;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
if(optarg)
|
if(optarg)
|
||||||
@ -151,7 +163,6 @@ int unterOption_default(Settings *settings, int argc, char ** argv)
|
|||||||
std::cout << "Pfad zu Output-Datei: " << settings->outputFilePath << std::endl;
|
std::cout << "Pfad zu Output-Datei: " << settings->outputFilePath << std::endl;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
if(!optarg)
|
if(!optarg)
|
||||||
break;
|
break;
|
||||||
@ -205,7 +216,31 @@ int unterOption_default(Settings *settings, int argc, char ** argv)
|
|||||||
} else if(settings->debugMode)
|
} else if(settings->debugMode)
|
||||||
std::cout << "StopSeason: " << settings->stopSeason << std::endl;
|
std::cout << "StopSeason: " << settings->stopSeason << std::endl;
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
if(optarg)
|
||||||
|
settings->default_Searchmuster = optarg;
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cout << "SearchMuster: " << settings->default_Searchmuster << std::endl;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
if(!optarg)
|
||||||
|
break;
|
||||||
|
settings->default_maxDirs = atoi(optarg);
|
||||||
|
if(std::to_string(settings->default_maxDirs) != std::string(optarg) ) {
|
||||||
|
std::cout << "[-t]: Invalid Count: " << optarg << std::endl;
|
||||||
|
return 18;
|
||||||
|
}
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cout << "SearchMuster: " << settings->default_Searchmuster << std::endl;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
if(!optarg)
|
||||||
|
break;
|
||||||
|
settings->default_checkDirPath = optarg;
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cout << "To check Dir: " << settings->default_checkDirPath << std::endl;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
settings->colorless = true;
|
settings->colorless = true;
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
@ -245,10 +280,8 @@ void unterOption_default_help(Settings *, char * argv0)
|
|||||||
<< "\t -> Die Sprache(n) die du willst. Die wichtigsten zuerst. Default: GerDub,GerSub,Eng" << std::endl
|
<< "\t -> Die Sprache(n) die du willst. Die wichtigsten zuerst. Default: GerDub,GerSub,Eng" << std::endl
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< " > Proxy-Optionen:" << std::endl
|
<< " > Proxy-Optionen:" << std::endl
|
||||||
<< "\t-i [ProxyIPAddresse], --ip-addresse [ProxyIPAddresse]" << std::endl
|
<< "\t-p [ProxyAddresse], --socks5-proxy [ProxyAddresse]" << std::endl
|
||||||
<< "\t -> Ip Addresse eines Socks5-Proxys angeben. Default: 127.0.0.1" << std::endl
|
<< "\t -> Ip Addresse eines Socks5-Proxys angeben. Default: 127.0.0.1:9050" << std::endl
|
||||||
<< "\t-p [ProxyPort], --port [ProxyPort]" << std::endl
|
|
||||||
<< "\t -> Port eines Socks5-Proxy angeben. Default: 9050" << std::endl
|
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< " > Outputoptionen:" << std::endl
|
<< " > Outputoptionen:" << std::endl
|
||||||
<< "\t-o [Pfad], --output-file [Pfad]" << std::endl
|
<< "\t-o [Pfad], --output-file [Pfad]" << std::endl
|
||||||
@ -258,6 +291,17 @@ void unterOption_default_help(Settings *, char * argv0)
|
|||||||
<< "\t-d, --debug-mode" << std::endl
|
<< "\t-d, --debug-mode" << std::endl
|
||||||
<< "\t -> Debug Nachrichten an. Default: false" << std::endl
|
<< "\t -> Debug Nachrichten an. Default: false" << std::endl
|
||||||
<< std::endl
|
<< std::endl
|
||||||
|
<< " > Check-Dir Optionen:" << std::endl
|
||||||
|
<< "\t-C [Pfad], --check-dir [Pfad]" << std::endl
|
||||||
|
<< "\t -> Überprüfe ob in diesem, oder in einen der Unterordnern die Folge vorkommt." << std::endl
|
||||||
|
<< "\t -> Wenn ja, dann überspringe diese." << std::endl
|
||||||
|
<< "\t-m, --check-muster" << std::endl
|
||||||
|
<< "\t -> Muster mit dem Überprüft wird, ob diese Folge in einem Ordner ist. Default: S%Staffel%E%Folge%" << std::endl
|
||||||
|
<< "\t -> %Staffel% ist eine Variable für die Staffel mit 0 + Staffel, wenn Staffel < 10. " << std::endl
|
||||||
|
<< "\t -> %Folge% ist eine Variable für die Folge mit 0 + Folge, wenn Folge < 10. " << std::endl
|
||||||
|
<< "\t-t, --check-max-dirs" << std::endl
|
||||||
|
<< "\t -> Maximale Anzahl der Ordner, die auf Dateien untersucht werden. Default: 20" << std::endl
|
||||||
|
<< std::endl
|
||||||
<< " > Durchlaufoptionen:" << std::endl
|
<< " > Durchlaufoptionen:" << std::endl
|
||||||
<< "\t-e [Folge], --start-episode [Folge]" << std::endl
|
<< "\t-e [Folge], --start-episode [Folge]" << std::endl
|
||||||
<< "\t -> Das Programm startet mit dieser Folge." << std::endl
|
<< "\t -> Das Programm startet mit dieser Folge." << std::endl
|
||||||
@ -287,8 +331,7 @@ int unterOption_url(Settings *settings, int argc, char **argv)
|
|||||||
int c = 0;
|
int c = 0;
|
||||||
const option long_opts[] = {
|
const option long_opts[] = {
|
||||||
{"url", required_argument, nullptr, 'u'},
|
{"url", required_argument, nullptr, 'u'},
|
||||||
{"ip-addresse", required_argument, nullptr, 'i'},
|
{"socks5-proxy", required_argument, nullptr, 'p'},
|
||||||
{"port", required_argument, nullptr, 'p'},
|
|
||||||
{"output-file", required_argument, nullptr, 'o'},
|
{"output-file", required_argument, nullptr, 'o'},
|
||||||
|
|
||||||
{"help", no_argument, nullptr, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
@ -299,7 +342,7 @@ int unterOption_url(Settings *settings, int argc, char **argv)
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
while( ( c = getopt_long (argc, argv, "u:i:p:o:hcd", long_opts, nullptr) ) != -1 ) {
|
while( ( c = getopt_long (argc, argv, "u:p:o:hcd", long_opts, nullptr) ) != -1 ) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'u':
|
case 'u':
|
||||||
if(optarg)
|
if(optarg)
|
||||||
@ -308,21 +351,29 @@ int unterOption_url(Settings *settings, int argc, char **argv)
|
|||||||
std::cout << "Urls: " << settings->name << std::endl;
|
std::cout << "Urls: " << settings->name << std::endl;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i':
|
case 'p': {
|
||||||
if(optarg)
|
if(!optarg || std::string(optarg) == "")
|
||||||
settings->proxy_ip = optarg;
|
|
||||||
if(settings->debugMode)
|
|
||||||
std::cout << "Proxy Ip Addresse: " << settings->proxy_ip << std::endl;
|
|
||||||
break;
|
break;
|
||||||
case 'p':
|
std::string optarg = ::optarg;
|
||||||
if(optarg)
|
if(optarg.find(":") == std::string::npos) {
|
||||||
settings->proxy_port = atoi( optarg );
|
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||||
if(std::to_string(settings->proxy_port) != optarg) {
|
return 31;
|
||||||
std::cout << "Invalid Port: " << optarg << std::endl;
|
}
|
||||||
return 20;
|
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||||
|
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||||
|
int port = atoi(portStr.c_str());
|
||||||
|
if(std::to_string(port) != portStr || port <= 0) {
|
||||||
|
std::cout << "[-p]: Invalid Port: " << portStr << std::endl;
|
||||||
|
return 32;
|
||||||
|
} else if (ip == "") {
|
||||||
|
std::cout << "[-p]: Invalid Ip Addresse: " << ip << std::endl;
|
||||||
|
return 34;
|
||||||
|
} else if(settings->debugMode) {
|
||||||
|
std::cout << "Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||||
|
}
|
||||||
|
settings->proxy_ip = ip;
|
||||||
|
settings->proxy_port = port;
|
||||||
}
|
}
|
||||||
if(settings->debugMode)
|
|
||||||
std::cout << "Proxy Port: " << settings->proxy_port << std::endl;
|
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if(optarg)
|
if(optarg)
|
||||||
@ -360,10 +411,8 @@ void unterOption_url_help(Settings *, char * argv0)
|
|||||||
<< "Parameter:" << std::endl
|
<< "Parameter:" << std::endl
|
||||||
<< "\t-u [Url1,Url2,...], --url [Url1,Url2,...]" << std::endl
|
<< "\t-u [Url1,Url2,...], --url [Url1,Url2,...]" << std::endl
|
||||||
<< "\t -> Die zu umwandelnden redirect-Links." << std::endl
|
<< "\t -> Die zu umwandelnden redirect-Links." << std::endl
|
||||||
<< "\t-i [ProxyIPAddresse], --ip-addresse [ProxyIPAddresse]" << std::endl
|
<< "\t-p [ProxyAddresse], --socks5-proxy [ProxyAddresse]" << std::endl
|
||||||
<< "\t -> Default: 127.0.0.1." << std::endl
|
<< "\t -> Type: Socks5, Default: 127.0.0.1:9050" << std::endl
|
||||||
<< "\t-p [ProxyPort], --port [ProxyPort]" << std::endl
|
|
||||||
<< "\t -> Default: 9050." << std::endl
|
|
||||||
<< "\t-o [Pfad], --output-file [Pfad]" << std::endl
|
<< "\t-o [Pfad], --output-file [Pfad]" << std::endl
|
||||||
<< "\t-c, --colorless" << std::endl
|
<< "\t-c, --colorless" << std::endl
|
||||||
<< "\t -> Default: false ." << std::endl
|
<< "\t -> Default: false ." << std::endl
|
||||||
@ -411,7 +460,7 @@ int unterOption_search(Settings *settings, int argc, char **argv)
|
|||||||
{nullptr, no_argument, nullptr, 0}
|
{nullptr, no_argument, nullptr, 0}
|
||||||
|
|
||||||
};
|
};
|
||||||
std::string optarg2;
|
|
||||||
while( ( c = getopt_long (argc, argv, "n:p:hcdeu", long_opts, nullptr) ) != -1 ) {
|
while( ( c = getopt_long (argc, argv, "n:p:hcdeu", long_opts, nullptr) ) != -1 ) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'n':
|
case 'n':
|
||||||
@ -421,15 +470,15 @@ int unterOption_search(Settings *settings, int argc, char **argv)
|
|||||||
std::cout << "Name: " << settings->name << std::endl;
|
std::cout << "Name: " << settings->name << std::endl;
|
||||||
break;
|
break;
|
||||||
case 'p': {
|
case 'p': {
|
||||||
optarg2 = optarg;
|
if(!optarg || std::string(optarg) == "")
|
||||||
if(!optarg || optarg2 == "")
|
|
||||||
break;
|
break;
|
||||||
else if(optarg2.find(":") == std::string::npos) {
|
std::string optarg = ::optarg;
|
||||||
|
if(optarg.find(":") == std::string::npos) {
|
||||||
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||||
return 31;
|
return 31;
|
||||||
}
|
}
|
||||||
std::string ip = optarg2.substr(0, optarg2.find(":"));
|
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||||
std::string portStr = optarg2.substr(optarg2.find(":") + 1, optarg2.length() - optarg2.find(":"));
|
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||||
int port = atoi(portStr.c_str());
|
int port = atoi(portStr.c_str());
|
||||||
if(std::to_string(port) != portStr || port <= 0) {
|
if(std::to_string(port) != portStr || port <= 0) {
|
||||||
std::cout << "[-p]: Invalid Port: " << portStr << std::endl;
|
std::cout << "[-p]: Invalid Port: " << portStr << std::endl;
|
||||||
|
@ -11,7 +11,8 @@ enum Modus {
|
|||||||
EXIT = -1,
|
EXIT = -1,
|
||||||
DEFAULT_MODUS = 0,
|
DEFAULT_MODUS = 0,
|
||||||
DIRECT_LINK_MODUS = 1,
|
DIRECT_LINK_MODUS = 1,
|
||||||
Search_MODUS = 2
|
Search_MODUS = 2,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -27,8 +28,11 @@ struct Settings {
|
|||||||
proxy_ip = "127.0.0.1",
|
proxy_ip = "127.0.0.1",
|
||||||
languages = "GerDub,GerSub,Eng",
|
languages = "GerDub,GerSub,Eng",
|
||||||
genaueHoster = "",
|
genaueHoster = "",
|
||||||
version = "1.0.1",
|
version = "2.0.0",
|
||||||
outputFilePath;
|
outputFilePath = "",
|
||||||
|
default_checkDirPath = "",
|
||||||
|
default_Searchmuster = "S%Staffel%E%Folge%";
|
||||||
|
|
||||||
Modus modus = Modus::DEFAULT_MODUS;
|
Modus modus = Modus::DEFAULT_MODUS;
|
||||||
bool colorless = false,
|
bool colorless = false,
|
||||||
debugMode = false,
|
debugMode = false,
|
||||||
@ -38,8 +42,9 @@ struct Settings {
|
|||||||
stopEpisode = 0,
|
stopEpisode = 0,
|
||||||
startSeason = 1,
|
startSeason = 1,
|
||||||
stopSeason = 0,
|
stopSeason = 0,
|
||||||
proxy_port = 9050;
|
proxy_port = 9050,
|
||||||
|
default_maxDirs = 20;
|
||||||
|
const char pathSymbol = '/';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,28 +32,59 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
{
|
{
|
||||||
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
||||||
|
|
||||||
|
//Wenn kein Name mit -n Angegeben wurde:
|
||||||
if(settings->name == "") {
|
if(settings->name == "") {
|
||||||
std::cout << "Kein Name angegeben: Missing Parameter -n [Name]." << std::endl;
|
if(settings->default_checkDirPath != "") {
|
||||||
|
if(settings->default_checkDirPath[settings->default_checkDirPath.length()-1] == settings->pathSymbol)
|
||||||
|
settings->default_checkDirPath.pop_back();
|
||||||
|
size_t pos = settings->default_checkDirPath.find_last_of(std::string(1, settings->pathSymbol));
|
||||||
|
if( pos != std::string::npos) {
|
||||||
|
settings->name = settings->default_checkDirPath.substr(pos + 1);
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cout << " > Use Path for Name: " << settings->default_checkDirPath << " -> " << settings->name << std::endl;
|
||||||
|
}
|
||||||
|
} if(settings->name == "") {
|
||||||
|
std::cout << " => Error: Kein Name angegeben: Missing Parameter -n [Name]." << std::endl;
|
||||||
return 27;
|
return 27;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Liste alle Dateien in dem Ornder von -C auf und speichere diese
|
||||||
|
std::string dirFiles;
|
||||||
|
if(settings->default_checkDirPath != "")
|
||||||
|
if(listDir(dirFiles, settings->default_checkDirPath, settings->default_maxDirs ) != 0)
|
||||||
|
return 28;
|
||||||
|
//Entferne von der liste das \n am ende
|
||||||
|
if(dirFiles.length() > 0)
|
||||||
|
dirFiles.pop_back();
|
||||||
|
|
||||||
|
//Wenn Debug Mode, gib die Liste aus
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cout << " > [-C] Files:\n" << dirFiles << std::endl;
|
||||||
|
|
||||||
|
//Führe Function aus, die überprüft ob die serie existiert
|
||||||
std::string nameInUrl =pageManager.checkName(settings->name);
|
std::string nameInUrl =pageManager.checkName(settings->name);
|
||||||
if(nameInUrl == "-1") {
|
if(nameInUrl == "-1") {
|
||||||
|
//Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch.
|
||||||
searchModus(settings);
|
searchModus(settings);
|
||||||
return 25;
|
return 25;
|
||||||
}
|
}
|
||||||
|
//Sonst melde sich bei s.to an und speicher cookies.
|
||||||
else if (pageManager.login(accountManager.getNextAccount()) != 0)
|
else if (pageManager.login(accountManager.getNextAccount()) != 0)
|
||||||
return 29;
|
return 29;
|
||||||
pageManager.writeToFile(settings->outputFilePath, "Name: " + settings->name);
|
pageManager.writeToFile(settings->outputFilePath, "Name: " + settings->name);
|
||||||
|
|
||||||
//Find out number of all seasons
|
//Finde die anzahl der staffel heraus:
|
||||||
|
//download html von der startpage einer serie
|
||||||
Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl);
|
Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl);
|
||||||
if(tmp_reply.html == "-1")
|
if(tmp_reply.html == "-1")
|
||||||
return 32;
|
return 32;
|
||||||
|
//speicher zahl -1, ab da wo /staffel-x nicht mehr vorkommt
|
||||||
int maxStaffel = pageManager.counterContains(tmp_reply.html, "/staffel-%i");
|
int maxStaffel = pageManager.counterContains(tmp_reply.html, "/staffel-%i");
|
||||||
|
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Die Serie " << settings->name << " hat " << maxStaffel << " Staffeln." << std::endl;
|
std::cout << " > Die Serie " << settings->name << " hat " << maxStaffel << " Staffeln." << std::endl;
|
||||||
|
|
||||||
//For every season
|
//For every season
|
||||||
for (int staffel = settings->startSeason; staffel <= maxStaffel; ++staffel) {
|
for (int staffel = settings->startSeason; staffel <= maxStaffel; ++staffel) {
|
||||||
|
|
||||||
@ -64,10 +95,21 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
int maxFolge = pageManager.counterContains(tmp_reply.html, "/episode-%i");
|
int maxFolge = pageManager.counterContains(tmp_reply.html, "/episode-%i");
|
||||||
|
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Die Staffel " << staffel << " hat " << maxFolge << " Folgen." << std::endl;
|
std::cout << " > Die Staffel " << staffel << " hat " << maxFolge << " Folgen." << std::endl;
|
||||||
|
|
||||||
//for every episode
|
//for every episode
|
||||||
for (int folge = settings->startEpisode; folge <= maxFolge; ++folge) {
|
for (int folge = settings->startEpisode; folge <= maxFolge; ++folge) {
|
||||||
|
|
||||||
|
//Überprüfe ob, wenn -C vorhanden, die Folge in dem Ordner bereits vorkommt.
|
||||||
|
if(settings->default_checkDirPath != "") {
|
||||||
|
if(dirFiles.find(pageManager.replace( pageManager.replace( settings->default_Searchmuster, "%Staffel%", ((staffel < 10) ? "0" : "") + std::to_string(staffel) ),
|
||||||
|
"%Folge%", ((folge < 10) ? "0" : "") + std::to_string(folge) ) ) != std::string::npos) {
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cout << " > Skippe Folge: S" << staffel << "E" << folge << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tmp_reply =pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel) + "/episode-" + std::to_string(folge));
|
tmp_reply =pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel) + "/episode-" + std::to_string(folge));
|
||||||
if(tmp_reply.html == "-1")
|
if(tmp_reply.html == "-1")
|
||||||
return 47;
|
return 47;
|
||||||
@ -75,7 +117,7 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
std::string Link = pageManager.chooseHosterLink(allLinks, settings->genaueHoster, settings->languages);
|
std::string Link = pageManager.chooseHosterLink(allLinks, settings->genaueHoster, settings->languages);
|
||||||
|
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << allLinks << std::endl << " -> Link: '" << ( (Link == "") ? "" : "https://s.to") << Link << "'" << std::endl;
|
std::cout << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" );
|
||||||
if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0)
|
if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0)
|
||||||
return 51;
|
return 51;
|
||||||
|
|
||||||
@ -89,11 +131,12 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
|
|
||||||
if(staffel == settings->stopSeason) {
|
if(staffel == settings->stopSeason) {
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Stoppe, weil Staffel: " << staffel << " == StopStaffel " << settings->stopSeason << std::endl;
|
std::cout << " > Stoppe, weil Staffel: " << staffel << " == StopStaffel " << settings->stopSeason << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << " > Fertig" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,9 +245,6 @@ int ProgramManager::searchModus_update(Settings *settings)
|
|||||||
//...\n|/serie/stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
|
//...\n|/serie/stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
|
||||||
serienListe = pageManager.replace(serienListe, "|/serie/stream/", "|/");
|
serienListe = pageManager.replace(serienListe, "|/serie/stream/", "|/");
|
||||||
|
|
||||||
//Performanze:
|
|
||||||
serienListe = pageManager.grep(serienListe, settings->name, true);
|
|
||||||
|
|
||||||
std::stringstream strstream(serienListe);
|
std::stringstream strstream(serienListe);
|
||||||
std::string line;
|
std::string line;
|
||||||
serienListe.clear();
|
serienListe.clear();
|
||||||
@ -229,6 +269,41 @@ int ProgramManager::searchModus_update(Settings *settings)
|
|||||||
}
|
}
|
||||||
ofs << serienListe << std::endl;
|
ofs << serienListe << std::endl;
|
||||||
ofs.close();
|
ofs.close();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ProgramManager::listDir(std::string &list,std::string path, int maxDepth)
|
||||||
|
{
|
||||||
|
if(maxDepth == 0)
|
||||||
|
return 0;
|
||||||
|
else if(!dirExists(path)) {
|
||||||
|
std::cout << " => Error: Verzeichnis '" << path << "' existiert nicht oder ist kein Ordner." << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
maxDepth--;
|
||||||
|
|
||||||
|
if(path[path.length()-1] != '/')
|
||||||
|
path.push_back('/');
|
||||||
|
|
||||||
|
DIR* dirp = opendir(path.c_str());
|
||||||
|
if(!dirp) {
|
||||||
|
perror(std::string(" => Error: Konnte Verzeichnis nicht öffnen: " + path).c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct dirent * dp;
|
||||||
|
while ((dp = readdir(dirp)) != nullptr) {
|
||||||
|
if(strcmp( dp->d_name, "." ) == 0 || strcmp ( dp->d_name, ".." ) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
else if(dirExists((path + dp->d_name + "/"))) { //if(dp->d_type == DT_DIR) {
|
||||||
|
listDir(list, (path + dp->d_name + "/"), maxDepth);
|
||||||
|
} else
|
||||||
|
list.append( std::string(dp->d_name) + "\n" );
|
||||||
|
}
|
||||||
|
closedir(dirp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +311,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou
|
|||||||
Settings * settings, int Staffel, int Folge, std::string allLinks)
|
Settings * settings, int Staffel, int Folge, std::string allLinks)
|
||||||
{
|
{
|
||||||
std::string folgenID = std::string((Staffel == -1 || Folge == -1 ) ? "" : "S" + std::string( (Staffel < 10) ? "0" : "" ) + std::to_string(Staffel)
|
std::string folgenID = std::string((Staffel == -1 || Folge == -1 ) ? "" : "S" + std::string( (Staffel < 10) ? "0" : "" ) + std::to_string(Staffel)
|
||||||
+ "E" + std::string( (Folge < 10) ? "0" : "" ) + std::to_string( Folge ) + ": ");
|
+ "E" + std::string( (Folge < 10) ? "0" : "" ) + std::to_string( Folge ) );
|
||||||
std::string green = ((settings->colorless) ? "" : "\033[32m"),
|
std::string green = ((settings->colorless) ? "" : "\033[32m"),
|
||||||
red = ((settings->colorless) ? "" : "\033[31m"),
|
red = ((settings->colorless) ? "" : "\033[31m"),
|
||||||
orange =((settings->colorless) ? "" : "\033[33m"),
|
orange =((settings->colorless) ? "" : "\033[33m"),
|
||||||
@ -264,20 +339,20 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou
|
|||||||
return 102;
|
return 102;
|
||||||
} else if(newUrl.find("/s.to/redirect/") != std::string::npos ) {
|
} else if(newUrl.find("/s.to/redirect/") != std::string::npos ) {
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Redirect Link nach umwandlung --> Neuer Account" << std::endl;
|
std::cout << "Warnung: Redirect Link nach umwandlung (Capcha?) --> Neuer Account" << std::endl;
|
||||||
if(pageManager.login(accountManager->getNextAccount()) != 0)
|
if(pageManager.login(accountManager->getNextAccount()) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
else {
|
} else {
|
||||||
std::cout << " => " << folgenID << green << newUrl << "\033[0m" << std::endl;
|
std::cout << " => " << folgenID << ": " << green << newUrl << "\033[0m" << std::endl;
|
||||||
if(settings->outputFilePath != "")
|
if(settings->outputFilePath != "")
|
||||||
if(pageManager.writeToFile(settings->outputFilePath,folgenID + newUrl) != 0)
|
if(pageManager.writeToFile(settings->outputFilePath,folgenID + newUrl) != 0)
|
||||||
return 108;
|
return 108;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << " => " << folgenID << red << "https://s.to" << redirectLink << "\033[0m" << std::endl;
|
std::cout << " => " << folgenID << ": " << red << "https://s.to" << redirectLink << "\033[0m" << std::endl;
|
||||||
if(settings->outputFilePath != "")
|
if(settings->outputFilePath != "")
|
||||||
if(pageManager.writeToFile(settings->outputFilePath, folgenID + redirectLink) != 0)
|
if(pageManager.writeToFile(settings->outputFilePath, folgenID + redirectLink) != 0)
|
||||||
return 114;
|
return 114;
|
||||||
|
@ -6,24 +6,26 @@
|
|||||||
#include "accountManager.h"
|
#include "accountManager.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
class ProgramManager
|
class ProgramManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProgramManager();
|
ProgramManager();
|
||||||
~ProgramManager();
|
~ProgramManager();
|
||||||
int start(Settings setting);
|
int start(Settings setting);
|
||||||
|
int listDir(std::string &list, std::string path, int maxDepth);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int defaultModus(Settings * settings);
|
int defaultModus(Settings * settings);
|
||||||
int directLinkModus(Settings * settings);
|
int directLinkModus(Settings * settings);
|
||||||
int searchModus(Settings * settings);
|
int searchModus(Settings * settings);
|
||||||
int searchModus_update(Settings * settings);
|
|
||||||
|
|
||||||
|
|
||||||
PageManager pageManager;
|
PageManager pageManager;
|
||||||
|
|
||||||
|
|
||||||
int convertLink(std::string redirectLink, AccountManager *accountManager, Settings * settings, int Staffel = -1, int Folge = -1, std::string allLinks = "NOT_EMPTY");
|
int convertLink(std::string redirectLink, AccountManager *accountManager, Settings * settings, int Staffel = -1, int Folge = -1, std::string allLinks = "NOT_EMPTY");
|
||||||
|
int searchModus_update(Settings * settings);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,12 +41,11 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
|||||||
char *url;
|
char *url;
|
||||||
std::string returnUrl;
|
std::string returnUrl;
|
||||||
|
|
||||||
std::cout << "Lade: '" << Url << "'...";
|
std::cout << "Lade: '" << Url << "'..." << std::flush;
|
||||||
std::cout.flush();
|
|
||||||
|
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if(!curl) {
|
if(!curl) {
|
||||||
perror("\33[2K\rError: Curl easy init failed");
|
perror("\33[2K\r => Error: Curl easy init failed");
|
||||||
return Reply("-1");
|
return Reply("-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,16 +67,14 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
|||||||
for (int timeout = 1; timeout <= maxTimeout; ++timeout) {
|
for (int timeout = 1; timeout <= maxTimeout; ++timeout) {
|
||||||
/* Perform the request, res will get the return code */
|
/* Perform the request, res will get the return code */
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
std::cout << "\33[2K\r";
|
std::cout << "\33[2K\r" << std::flush;
|
||||||
std::cout.flush();
|
|
||||||
|
|
||||||
if(res != CURLE_OK) {
|
if(res != CURLE_OK) {
|
||||||
if(timeout == maxTimeout) {
|
if(timeout == maxTimeout) {
|
||||||
perror((std::string("Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str());
|
perror((std::string(" => Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str());
|
||||||
return Reply("-1");
|
return Reply("-1");
|
||||||
} else {
|
} else {
|
||||||
std::cout << "\33[2K\r" << "Warning: Versuch " << timeout << " von " << maxTimeout << ": curl_easy_perform() failed: " << curl_easy_strerror(res);
|
std::cout << "\33[2K\r" << " => Warning: Versuch " << timeout << " von " << maxTimeout << ": curl_easy_perform() failed: " << curl_easy_strerror(res) << std::flush;
|
||||||
std::cout.flush();
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -89,7 +86,7 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
|||||||
//Get Url
|
//Get Url
|
||||||
res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
|
res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
|
||||||
if( res != CURLE_OK || !url ) {
|
if( res != CURLE_OK || !url ) {
|
||||||
perror((std::string("Error: curl_easy_getinfo failed: ") + curl_easy_strerror(res)).c_str());
|
perror((std::string(" => Error: curl_easy_getinfo failed: ") + curl_easy_strerror(res)).c_str());
|
||||||
return Reply("-1");
|
return Reply("-1");
|
||||||
} else
|
} else
|
||||||
returnUrl=url;
|
returnUrl=url;
|
||||||
@ -104,24 +101,24 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
|||||||
int PageManager::login(Account account)
|
int PageManager::login(Account account)
|
||||||
{
|
{
|
||||||
if(debugMode)
|
if(debugMode)
|
||||||
std::cout << "Melde mit neuem Account an: Email: " << account.Email << " Passowort: " << account.Password << std::endl;
|
std::cout << " > Melde mit neuem Account an: Email: " << account.Email << " Passowort: " << account.Password << std::endl;
|
||||||
|
|
||||||
std::string html = getServerRequest("https://s.to/login", false, std::string("email=" + account.Email + "&password=" + account.Password), true ).html;
|
std::string html = getServerRequest("https://s.to/login", false, std::string("email=" + account.Email + "&password=" + account.Password), true ).html;
|
||||||
if(html == "" )
|
if(html == "" )
|
||||||
return 0;
|
return 0;
|
||||||
else if (html.find("Das Feld Email muss eine gültige E-Mail-Adresse enthalten.") != std::string::npos)
|
else if (html.find("Das Feld Email muss eine gültige E-Mail-Adresse enthalten.") != std::string::npos)
|
||||||
std::cout << "Error: Login failed: Das Feld Email muss eine gültige E-Mail-Adresse enthalten." << std::endl
|
std::cout << " => Error: Login failed: Das Feld Email muss eine gültige E-Mail-Adresse enthalten." << std::endl
|
||||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||||
else if (html.find("Das Passwort ist nicht korrekt") != std::string::npos)
|
else if (html.find("Das Passwort ist nicht korrekt") != std::string::npos)
|
||||||
std::cout << "Error: Login failed: Das Passwort ist nicht korrekt." << std::endl
|
std::cout << " => Error: Login failed: Das Passwort ist nicht korrekt." << std::endl
|
||||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||||
else if (html.find("Ein Account mit dieser E-Mail Adresse wurde nicht gefunden.") != std::string::npos)
|
else if (html.find("Ein Account mit dieser E-Mail Adresse wurde nicht gefunden.") != std::string::npos)
|
||||||
std::cout << "Error: Login failed: Ein Account mit dieser E-Mail Adresse wurde nicht gefunden." << std::endl
|
std::cout << " => Error: Login failed: Ein Account mit dieser E-Mail Adresse wurde nicht gefunden." << std::endl
|
||||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||||
else if(html == "-1")
|
else if(html == "-1")
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
std::cout << "Error: Login failed: Keine Weiterleitung bei Login." << std::endl
|
std::cout << " => Error: Login failed: Keine Weiterleitung bei Login." << std::endl
|
||||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -134,14 +131,14 @@ std::string PageManager::getUrlAfterRedirect(std::string Url)
|
|||||||
std::string PageManager::checkName(std::string Name)
|
std::string PageManager::checkName(std::string Name)
|
||||||
{
|
{
|
||||||
std::string name = replace(Name, " ", "-");
|
std::string name = replace(Name, " ", "-");
|
||||||
std::cout << "Name: " << name << std::endl;
|
std::cout << " > Name: " << name << std::endl;
|
||||||
|
|
||||||
std::string html = getServerRequest("https://s.to/serie/stream/" + name).html;
|
std::string html = getServerRequest("https://s.to/serie/stream/" + name).html;
|
||||||
if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) {
|
if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) {
|
||||||
std::cout << "Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: " << Name << std::endl;
|
std::cout << " => Error: Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: " << Name << std::endl;
|
||||||
return "-1";
|
return "-1";
|
||||||
} else if (html.find("404 - Seite nicht gefunden") != std::string::npos) {
|
} else if (html.find("404 - Seite nicht gefunden") != std::string::npos) {
|
||||||
std::cout << "Ungültiger Name: " << Name << std::endl;
|
std::cout << " => Error: Ungültiger Name: " << Name << std::endl;
|
||||||
return "-1";
|
return "-1";
|
||||||
} else if (html == "-1") {
|
} else if (html == "-1") {
|
||||||
return "-1";
|
return "-1";
|
||||||
@ -155,7 +152,7 @@ std::string PageManager::getLinks(std::string HTML)
|
|||||||
{
|
{
|
||||||
size_t pos = HTML.find("<ul class=\"row\">");
|
size_t pos = HTML.find("<ul class=\"row\">");
|
||||||
if(pos == std::string::npos) {
|
if(pos == std::string::npos) {
|
||||||
std::cout << "Konnte Position von \"" << "<ul class=\"row\">" << " nicht finden" <<std::endl;
|
std::cout << " => Error: Konnte Position von \"" << "<ul class=\"row\">" << " nicht finden" <<std::endl;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +160,7 @@ std::string PageManager::getLinks(std::string HTML)
|
|||||||
|
|
||||||
pos = HTML.find("<script async=");
|
pos = HTML.find("<script async=");
|
||||||
if(pos == std::string::npos) {
|
if(pos == std::string::npos) {
|
||||||
std::cout << "Konnte Position von \"" << "<script async=" << "\" nicht finden" <<std::endl;
|
std::cout << " => Error: Konnte Position von \"" << "<script async=" << "\" nicht finden" <<std::endl;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,11 +219,10 @@ std::string PageManager::getLinks(std::string HTML)
|
|||||||
line.erase(pos,line.length()-pos);
|
line.erase(pos,line.length()-pos);
|
||||||
|
|
||||||
line = replace(line, "title=\"Hoster ", "hoster=\"");
|
line = replace(line, "title=\"Hoster ", "hoster=\"");
|
||||||
|
|
||||||
ReturnValue+=line+"\n";
|
ReturnValue+=line+"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ReturnValue.size() > 0)
|
if(ReturnValue.length() > 0)
|
||||||
return ReturnValue.erase( ReturnValue.size()-1 , 1);
|
return ReturnValue.erase( ReturnValue.size()-1 , 1);
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
@ -278,7 +274,7 @@ int PageManager::writeToFile(std::string path, std::string text)
|
|||||||
std::ofstream of;
|
std::ofstream of;
|
||||||
of.open(path, std::ios::out | std::ios::app);
|
of.open(path, std::ios::out | std::ios::app);
|
||||||
if(!of.is_open()) {
|
if(!of.is_open()) {
|
||||||
perror("Konnte output Datei nicht öffnen");
|
perror(" => Error: Konnte output Datei nicht öffnen");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
of << text << std::endl;
|
of << text << std::endl;
|
||||||
@ -306,7 +302,7 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho
|
|||||||
else if ( langId == "GerSub" )
|
else if ( langId == "GerSub" )
|
||||||
LangId=3;
|
LangId=3;
|
||||||
else {
|
else {
|
||||||
std::cout << "Unbekannte Sprache: " << langId << std::endl;
|
std::cout << " => Error: Unbekannte Sprache: " << langId << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,14 +324,14 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho
|
|||||||
Line = grep(LanguageSortedHoster, ("hoster=\"" + hoster + "\"" ) );
|
Line = grep(LanguageSortedHoster, ("hoster=\"" + hoster + "\"" ) );
|
||||||
pos = Line.find("href=\"");
|
pos = Line.find("href=\"");
|
||||||
if(pos == std::string::npos) {
|
if(pos == std::string::npos) {
|
||||||
std::cout << "Error: Konnte 'href=\"' nicht finden." << std::endl;
|
std::cout << "Error: Konnte 'href=\"' in chooseHosterLink() nicht finden." << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Line.erase(0, pos + static_cast<int>(strlen("href=\"")));
|
Line.erase(0, pos + static_cast<int>(strlen("href=\"")));
|
||||||
|
|
||||||
pos = Line.find("\"");
|
pos = Line.find("\"");
|
||||||
if(pos == std::string::npos) {
|
if(pos == std::string::npos) {
|
||||||
std::cout << "Error: Konnte '\"' nicht finden." << std::endl;
|
std::cout << "Error: Konnte '\"' in chooseHosterLink() nicht finden." << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
// if complied for windows; everything is in */projectfolder/curl/
|
// if complied for windows; everything is in */projectfolder/curl/
|
||||||
#include <curl/curl.h>
|
#include </home/markus/Qt/S_New4/curl/curl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
void setPaths(Settings &settings, std::string executablePathTo)
|
void setPaths(Settings &settings, std::string executablePathTo)
|
||||||
{
|
{
|
||||||
//Path settings
|
//Path settings
|
||||||
executablePathTo.erase(executablePathTo.find_last_of("/\\") + 1 , executablePathTo.length() - ( executablePathTo.find_last_of("/\\") + 1) );
|
executablePathTo.erase(executablePathTo.find_last_of(settings.pathSymbol) + 1 , executablePathTo.length() - ( executablePathTo.find_last_of(settings.pathSymbol) + 1) );
|
||||||
|
|
||||||
if(!dirExists(executablePathTo + "src/"))
|
if(!dirExists(executablePathTo + "src" + settings.pathSymbol))
|
||||||
system(std::string("mkdir \"" + executablePathTo + "src/\"").c_str());
|
system(std::string("mkdir \"" + executablePathTo + "src" + settings.pathSymbol + "\"").c_str());
|
||||||
if(dirExists(executablePathTo + "src/"))
|
if(dirExists(executablePathTo + "src" + settings.pathSymbol))
|
||||||
executablePathTo+="src/";
|
executablePathTo+="src" + std::string(1, settings.pathSymbol);
|
||||||
|
|
||||||
settings.cookieFilePath = executablePathTo + "S_New4_cookies";
|
settings.cookieFilePath = executablePathTo + "S_New4_cookies";
|
||||||
settings.accountFilePath = executablePathTo + "Accounts";
|
settings.accountFilePath = executablePathTo + "Accounts";
|
||||||
|
@ -44,7 +44,7 @@ struct Settings {
|
|||||||
stopSeason = 0,
|
stopSeason = 0,
|
||||||
proxy_port = 9050,
|
proxy_port = 9050,
|
||||||
default_maxDirs = 20;
|
default_maxDirs = 20;
|
||||||
|
const char pathSymbol = '/';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,33 +32,59 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
{
|
{
|
||||||
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
||||||
|
|
||||||
|
//Wenn kein Name mit -n Angegeben wurde:
|
||||||
if(settings->name == "") {
|
if(settings->name == "") {
|
||||||
std::cout << "Kein Name angegeben: Missing Parameter -n [Name]." << std::endl;
|
if(settings->default_checkDirPath != "") {
|
||||||
|
if(settings->default_checkDirPath[settings->default_checkDirPath.length()-1] == settings->pathSymbol)
|
||||||
|
settings->default_checkDirPath.pop_back();
|
||||||
|
size_t pos = settings->default_checkDirPath.find_last_of(std::string(1, settings->pathSymbol));
|
||||||
|
if( pos != std::string::npos) {
|
||||||
|
settings->name = settings->default_checkDirPath.substr(pos + 1);
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cout << " > Use Path for Name: " << settings->default_checkDirPath << " -> " << settings->name << std::endl;
|
||||||
|
}
|
||||||
|
} if(settings->name == "") {
|
||||||
|
std::cout << " => Error: Kein Name angegeben: Missing Parameter -n [Name]." << std::endl;
|
||||||
return 27;
|
return 27;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Liste alle Dateien in dem Ornder von -C auf und speichere diese
|
||||||
std::string dirFiles;
|
std::string dirFiles;
|
||||||
if(settings->default_checkDirPath != "")
|
if(settings->default_checkDirPath != "")
|
||||||
if(listDir(dirFiles, settings->default_checkDirPath, settings->default_maxDirs ) != 0)
|
if(listDir(dirFiles, settings->default_checkDirPath, settings->default_maxDirs ) != 0)
|
||||||
return 28;
|
return 28;
|
||||||
|
//Entferne von der liste das \n am ende
|
||||||
|
if(dirFiles.length() > 0)
|
||||||
|
dirFiles.pop_back();
|
||||||
|
|
||||||
|
//Wenn Debug Mode, gib die Liste aus
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cout << " > [-C] Files:\n" << dirFiles << std::endl;
|
||||||
|
|
||||||
|
//Führe Function aus, die überprüft ob die serie existiert
|
||||||
std::string nameInUrl =pageManager.checkName(settings->name);
|
std::string nameInUrl =pageManager.checkName(settings->name);
|
||||||
if(nameInUrl == "-1") {
|
if(nameInUrl == "-1") {
|
||||||
|
//Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch.
|
||||||
searchModus(settings);
|
searchModus(settings);
|
||||||
return 25;
|
return 25;
|
||||||
}
|
}
|
||||||
|
//Sonst melde sich bei s.to an und speicher cookies.
|
||||||
else if (pageManager.login(accountManager.getNextAccount()) != 0)
|
else if (pageManager.login(accountManager.getNextAccount()) != 0)
|
||||||
return 29;
|
return 29;
|
||||||
pageManager.writeToFile(settings->outputFilePath, "Name: " + settings->name);
|
pageManager.writeToFile(settings->outputFilePath, "Name: " + settings->name);
|
||||||
|
|
||||||
//Find out number of all seasons
|
//Finde die anzahl der staffel heraus:
|
||||||
|
//download html von der startpage einer serie
|
||||||
Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl);
|
Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl);
|
||||||
if(tmp_reply.html == "-1")
|
if(tmp_reply.html == "-1")
|
||||||
return 32;
|
return 32;
|
||||||
|
//speicher zahl -1, ab da wo /staffel-x nicht mehr vorkommt
|
||||||
int maxStaffel = pageManager.counterContains(tmp_reply.html, "/staffel-%i");
|
int maxStaffel = pageManager.counterContains(tmp_reply.html, "/staffel-%i");
|
||||||
|
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Die Serie " << settings->name << " hat " << maxStaffel << " Staffeln." << std::endl;
|
std::cout << " > Die Serie " << settings->name << " hat " << maxStaffel << " Staffeln." << std::endl;
|
||||||
|
|
||||||
//For every season
|
//For every season
|
||||||
for (int staffel = settings->startSeason; staffel <= maxStaffel; ++staffel) {
|
for (int staffel = settings->startSeason; staffel <= maxStaffel; ++staffel) {
|
||||||
|
|
||||||
@ -69,15 +95,17 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
int maxFolge = pageManager.counterContains(tmp_reply.html, "/episode-%i");
|
int maxFolge = pageManager.counterContains(tmp_reply.html, "/episode-%i");
|
||||||
|
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Die Staffel " << staffel << " hat " << maxFolge << " Folgen." << std::endl;
|
std::cout << " > Die Staffel " << staffel << " hat " << maxFolge << " Folgen." << std::endl;
|
||||||
|
|
||||||
//for every episode
|
//for every episode
|
||||||
for (int folge = settings->startEpisode; folge <= maxFolge; ++folge) {
|
for (int folge = settings->startEpisode; folge <= maxFolge; ++folge) {
|
||||||
|
|
||||||
|
//Überprüfe ob, wenn -C vorhanden, die Folge in dem Ordner bereits vorkommt.
|
||||||
if(settings->default_checkDirPath != "") {
|
if(settings->default_checkDirPath != "") {
|
||||||
if(dirFiles.find(pageManager.replace( pageManager.replace( settings->default_Searchmuster, "%Staffel%", ((staffel < 10) ? "0" : "") + std::to_string(staffel) ),
|
if(dirFiles.find(pageManager.replace( pageManager.replace( settings->default_Searchmuster, "%Staffel%", ((staffel < 10) ? "0" : "") + std::to_string(staffel) ),
|
||||||
"%Folge%", ((folge < 10) ? "0" : "") + std::to_string(folge) ) ) != std::string::npos) {
|
"%Folge%", ((folge < 10) ? "0" : "") + std::to_string(folge) ) ) != std::string::npos) {
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Skipping Folge: S" << staffel << "E" << folge << std::endl;
|
std::cout << " > Skippe Folge: S" << staffel << "E" << folge << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +117,7 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
std::string Link = pageManager.chooseHosterLink(allLinks, settings->genaueHoster, settings->languages);
|
std::string Link = pageManager.chooseHosterLink(allLinks, settings->genaueHoster, settings->languages);
|
||||||
|
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << allLinks << std::endl << " -> Link: '" << ( (Link == "") ? "" : "https://s.to") << Link << "'" << std::endl;
|
std::cout << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" );
|
||||||
if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0)
|
if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0)
|
||||||
return 51;
|
return 51;
|
||||||
|
|
||||||
@ -103,11 +131,12 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
|
|
||||||
if(staffel == settings->stopSeason) {
|
if(staffel == settings->stopSeason) {
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Stoppe, weil Staffel: " << staffel << " == StopStaffel " << settings->stopSeason << std::endl;
|
std::cout << " > Stoppe, weil Staffel: " << staffel << " == StopStaffel " << settings->stopSeason << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << " > Fertig" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +145,7 @@ int ProgramManager::directLinkModus(Settings *settings)
|
|||||||
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
||||||
|
|
||||||
if(settings->name == "") {
|
if(settings->name == "") {
|
||||||
std::cout << "Kein(e) Link(s) angegeben: Missing Parameter -u [Url]." << std::endl;
|
std::cout << " => Error: Kein(e) Link(s) angegeben: Missing Parameter -u [Url]." << std::endl;
|
||||||
return 76;
|
return 76;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +157,7 @@ int ProgramManager::directLinkModus(Settings *settings)
|
|||||||
|
|
||||||
while (getline(iStrStream, line).good()) {
|
while (getline(iStrStream, line).good()) {
|
||||||
if(line.find("https://s.to/redirect/") == std::string::npos) {
|
if(line.find("https://s.to/redirect/") == std::string::npos) {
|
||||||
std::cout << "Invalid Redirect Link: '" << line << "'" << std::endl;
|
std::cout << " => Error: Invalid Redirect Link: '" << line << "'" << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(convertLink(pageManager.replace(line, "https://s.to", ""), &accountManager, settings) != 0)
|
else if(convertLink(pageManager.replace(line, "https://s.to", ""), &accountManager, settings) != 0)
|
||||||
@ -146,11 +175,11 @@ int ProgramManager::searchModus(Settings *settings)
|
|||||||
if( res == 0)
|
if( res == 0)
|
||||||
std::cout << "Erfolgreich geupdatet: Die Serienliste ist nun auf dem neusten Stand." << std::endl;
|
std::cout << "Erfolgreich geupdatet: Die Serienliste ist nun auf dem neusten Stand." << std::endl;
|
||||||
else
|
else
|
||||||
std::cout << "Das updaten der Serienliste ist fehlgeschlagen." << std::endl;
|
std::cout << "Error: Das updaten der Serienliste ist fehlgeschlagen." << std::endl;
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
} else if(settings->name == "") {
|
} else if(settings->name == "") {
|
||||||
std::cout << "Kein Name angegeben: Missing Parameter -n [Name]." << std::endl;
|
std::cout << " => Error: Kein Name angegeben: Missing Parameter -n [Name]." << std::endl;
|
||||||
return 27;
|
return 27;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +191,7 @@ int ProgramManager::searchModus(Settings *settings)
|
|||||||
else {
|
else {
|
||||||
ifs.open(settings->serienListPath);
|
ifs.open(settings->serienListPath);
|
||||||
if(!ifs.is_open()) {
|
if(!ifs.is_open()) {
|
||||||
perror("Couldn't open SerienList file after update again.");
|
perror(" => Error: Couldn't open SerienList file after update again.");
|
||||||
return 434;
|
return 434;
|
||||||
}
|
}
|
||||||
std::cout << "Erfolgreich gedownloadet." << std::endl;
|
std::cout << "Erfolgreich gedownloadet." << std::endl;
|
||||||
@ -172,9 +201,11 @@ int ProgramManager::searchModus(Settings *settings)
|
|||||||
//Save file in string:
|
//Save file in string:
|
||||||
std::string serienListe((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
std::string serienListe((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
|
//Suche alle Möglichkeiten
|
||||||
std::string finds = pageManager.grep(serienListe, settings->name, settings->search_IgnoreUpperLower);
|
std::string finds = pageManager.grep(serienListe, settings->name, settings->search_IgnoreUpperLower);
|
||||||
serienListe.clear();
|
serienListe.clear(); // Speicher freigeben
|
||||||
|
|
||||||
|
//Text mit Farben versehen
|
||||||
if(!settings->colorless) {
|
if(!settings->colorless) {
|
||||||
for (size_t pos = pageManager.upper_string( finds ).find( pageManager.upper_string( settings->name ), 0);
|
for (size_t pos = pageManager.upper_string( finds ).find( pageManager.upper_string( settings->name ), 0);
|
||||||
pos != std::string::npos;
|
pos != std::string::npos;
|
||||||
@ -182,10 +213,14 @@ int ProgramManager::searchModus(Settings *settings)
|
|||||||
finds.insert(pos, ( (finds.find(settings->name, pos) == pos) ? "\033[32m" : "\033[36m" ) ).insert(pos + settings->name.length() + strlen("\033[37m"), "\033[0m");
|
finds.insert(pos, ( (finds.find(settings->name, pos) == pos) ? "\033[32m" : "\033[36m" ) ).insert(pos + settings->name.length() + strlen("\033[37m"), "\033[0m");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Ausgabe
|
||||||
|
if(finds == "") {
|
||||||
|
std::cout << " => Für '" << settings->name << "' wurde nichts gefunden." << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
std::stringstream strstream(finds);
|
std::stringstream strstream(finds);
|
||||||
std::string line;
|
std::string line;
|
||||||
std::cout << "Für '" << settings->name << "' wurde(n) folgende Serie(n) gefunden: " << std::endl;
|
std::cout << " => Für '" << settings->name << "' wurde(n) folgende Serie(n) gefunden: " << std::endl;
|
||||||
while (getline(strstream, line)) {
|
while (getline(strstream, line)) {
|
||||||
std::cout << " > " << line.substr(line.find("|", line.find("/")) + 1, line.length() - line.find("|", line.find("/")) -1 )
|
std::cout << " > " << line.substr(line.find("|", line.find("/")) + 1, line.length() - line.find("|", line.find("/")) -1 )
|
||||||
<< "\t[" << line.substr(line.find("/") + 1, line.find("|", line.find("/")) - line.find("/") - 1) << "]"
|
<< "\t[" << line.substr(line.find("/") + 1, line.find("|", line.find("/")) - line.find("/") - 1) << "]"
|
||||||
@ -248,8 +283,10 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth)
|
|||||||
{
|
{
|
||||||
if(maxDepth == 0)
|
if(maxDepth == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else if(!dirExists(path))
|
else if(!dirExists(path)) {
|
||||||
|
std::cout << " => Error: Verzeichnis '" << path << "' existiert nicht oder ist kein Ordner." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
maxDepth--;
|
maxDepth--;
|
||||||
|
|
||||||
@ -258,7 +295,7 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth)
|
|||||||
|
|
||||||
DIR* dirp = opendir(path.c_str());
|
DIR* dirp = opendir(path.c_str());
|
||||||
if(!dirp) {
|
if(!dirp) {
|
||||||
perror(std::string("Cannot open directory: " + path).c_str());
|
perror(std::string(" => Error: Konnte Verzeichnis nicht öffnen: " + path).c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +303,8 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth)
|
|||||||
while ((dp = readdir(dirp)) != nullptr) {
|
while ((dp = readdir(dirp)) != nullptr) {
|
||||||
if(strcmp( dp->d_name, "." ) == 0 || strcmp ( dp->d_name, ".." ) == 0)
|
if(strcmp( dp->d_name, "." ) == 0 || strcmp ( dp->d_name, ".." ) == 0)
|
||||||
continue;
|
continue;
|
||||||
else if(dp->d_type == DT_DIR) {
|
|
||||||
|
else if(dirExists((path + dp->d_name + "/"))) { //if(dp->d_type == DT_DIR) {
|
||||||
listDir(list, (path + dp->d_name + "/"), maxDepth);
|
listDir(list, (path + dp->d_name + "/"), maxDepth);
|
||||||
} else
|
} else
|
||||||
list.append( std::string(dp->d_name) + "\n" );
|
list.append( std::string(dp->d_name) + "\n" );
|
||||||
@ -279,7 +317,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou
|
|||||||
Settings * settings, int Staffel, int Folge, std::string allLinks)
|
Settings * settings, int Staffel, int Folge, std::string allLinks)
|
||||||
{
|
{
|
||||||
std::string folgenID = std::string((Staffel == -1 || Folge == -1 ) ? "" : "S" + std::string( (Staffel < 10) ? "0" : "" ) + std::to_string(Staffel)
|
std::string folgenID = std::string((Staffel == -1 || Folge == -1 ) ? "" : "S" + std::string( (Staffel < 10) ? "0" : "" ) + std::to_string(Staffel)
|
||||||
+ "E" + std::string( (Folge < 10) ? "0" : "" ) + std::to_string( Folge ) + ": ");
|
+ "E" + std::string( (Folge < 10) ? "0" : "" ) + std::to_string( Folge ) );
|
||||||
std::string green = ((settings->colorless) ? "" : "\033[32m"),
|
std::string green = ((settings->colorless) ? "" : "\033[32m"),
|
||||||
red = ((settings->colorless) ? "" : "\033[31m"),
|
red = ((settings->colorless) ? "" : "\033[31m"),
|
||||||
orange =((settings->colorless) ? "" : "\033[33m"),
|
orange =((settings->colorless) ? "" : "\033[33m"),
|
||||||
@ -307,20 +345,20 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou
|
|||||||
return 102;
|
return 102;
|
||||||
} else if(newUrl.find("/s.to/redirect/") != std::string::npos ) {
|
} else if(newUrl.find("/s.to/redirect/") != std::string::npos ) {
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cout << "Redirect Link nach umwandlung --> Neuer Account" << std::endl;
|
std::cout << "Warnung: Redirect Link nach umwandlung (Capcha?) --> Neuer Account" << std::endl;
|
||||||
if(pageManager.login(accountManager->getNextAccount()) != 0)
|
if(pageManager.login(accountManager->getNextAccount()) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
else {
|
} else {
|
||||||
std::cout << " => " << folgenID << green << newUrl << "\033[0m" << std::endl;
|
std::cout << " => " << folgenID << ": " << green << newUrl << "\033[0m" << std::endl;
|
||||||
if(settings->outputFilePath != "")
|
if(settings->outputFilePath != "")
|
||||||
if(pageManager.writeToFile(settings->outputFilePath,folgenID + newUrl) != 0)
|
if(pageManager.writeToFile(settings->outputFilePath,folgenID + newUrl) != 0)
|
||||||
return 108;
|
return 108;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << " => " << folgenID << red << "https://s.to" << redirectLink << "\033[0m" << std::endl;
|
std::cout << " => " << folgenID << ": " << red << "https://s.to" << redirectLink << "\033[0m" << std::endl;
|
||||||
if(settings->outputFilePath != "")
|
if(settings->outputFilePath != "")
|
||||||
if(pageManager.writeToFile(settings->outputFilePath, folgenID + redirectLink) != 0)
|
if(pageManager.writeToFile(settings->outputFilePath, folgenID + redirectLink) != 0)
|
||||||
return 114;
|
return 114;
|
||||||
|
Loading…
Reference in New Issue
Block a user