mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-17 23:56:05 +02:00
Initial checkin
This commit is contained in:
parent
c74712dad9
commit
078564ac9e
3242 changed files with 1616395 additions and 0 deletions
27
IDE/src/util/BfLog.bf
Normal file
27
IDE/src/util/BfLog.bf
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
|
||||
namespace IDE.util
|
||||
{
|
||||
class BfLog
|
||||
{
|
||||
[StdCall, CLink]
|
||||
static extern void BfLog_Log(char8* str);
|
||||
|
||||
[StdCall, CLink]
|
||||
static extern void BfLog_LogDbg(char8* str);
|
||||
|
||||
public static void Log(StringView str, params Object[] strParams)
|
||||
{
|
||||
var fStr = scope String();
|
||||
fStr.AppendF(str, params strParams);
|
||||
BfLog_Log(fStr);
|
||||
}
|
||||
|
||||
public static void LogDbg(StringView str, params Object[] strParams)
|
||||
{
|
||||
var fStr = scope String();
|
||||
fStr.AppendF(str, params strParams);
|
||||
BfLog_LogDbg(fStr);
|
||||
}
|
||||
}
|
||||
}
|
941
IDE/src/util/Curl.bf
Normal file
941
IDE/src/util/Curl.bf
Normal file
|
@ -0,0 +1,941 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CURL
|
||||
{
|
||||
class Easy
|
||||
{
|
||||
const int32 cOptionLong = 0;
|
||||
const int32 cOptionString = 10000;
|
||||
const int32 cOptionObject = 10000;
|
||||
const int32 cOptionFunction = 20000;
|
||||
const int32 cOptionOffT = 30000;
|
||||
|
||||
public enum Option
|
||||
{
|
||||
/* This is the FILE * or void * the regular output should be written to. */
|
||||
WriteData = cOptionObject + 1, /* The full URL to get/put */
|
||||
URL = cOptionString + 2, /* Port number to connect to, if other than default. */
|
||||
Port = cOptionLong + 3,
|
||||
/* Name of proxy to use. */
|
||||
Proxy = cOptionString + 4,
|
||||
/* "user:password;options" to use when fetching. */
|
||||
UserPwd = cOptionString + 5,
|
||||
/* "user:password" to use with proxy. */
|
||||
ProxyUserPwd = cOptionString + 6,
|
||||
/* Range to get, specified as an ASCII string. */
|
||||
Range = cOptionString + 7,
|
||||
/* not used */
|
||||
/* Specified file stream to upload from (use as input): */
|
||||
ReadData = cOptionObject + 9,
|
||||
/* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE
|
||||
* bytes big. If this is not used, error messages go to stderr instead: */
|
||||
ErrorBuffer = cOptionObject + 10,
|
||||
/* Function that will be called to store the output (instead of fwrite). The
|
||||
* parameters will use fwrite() syntax, make sure to follow them. */
|
||||
WriteFunction = cOptionFunction + 11,
|
||||
/* Function that will be called to read the input (instead of fread). The
|
||||
* parameters will use fread() syntax, make sure to follow them. */
|
||||
ReadFunction = cOptionFunction + 12,
|
||||
/* Time-out the read operation after this amount of seconds */
|
||||
Timeout = cOptionLong + 13,
|
||||
/* If the CURLOPT_INFILE is used, this can be used to inform libcurl about
|
||||
* how large the file being sent really is. That allows better error
|
||||
* checking and better verifies that the upload was successful. -1 means
|
||||
* unknown size.
|
||||
*
|
||||
* For large file support, there is also a _LARGE version of the key
|
||||
* which takes an off_t type, allowing platforms with larger off_t
|
||||
* sizes to handle larger files. See below for INFILESIZE_LARGE.
|
||||
*/
|
||||
InfileSize = cOptionLong + 14,
|
||||
/* POST static input fields. */
|
||||
Postfields = cOptionObject + 15,
|
||||
/* Set the referrer page (needed by some CGIs) */
|
||||
Referer = cOptionString + 16,
|
||||
/* Set the FTP PORT string (interface name, named or numerical IP address)
|
||||
Use i.e '-' to use default address. */
|
||||
FTPPort = cOptionString + 17,
|
||||
/* Set the User-Agent string (examined by some CGIs) */
|
||||
UserAgent = cOptionString + 18,
|
||||
/* If the download receives less than "low speed limit" bytes/second
|
||||
* during "low speed time" seconds, the operations is aborted.
|
||||
* You could i.e if you have a pretty high speed connection, abort if
|
||||
* it is less than 2000 bytes/sec during 20 seconds.
|
||||
*/
|
||||
/* Set the "low speed limit" */
|
||||
LowSpeedLimit = cOptionLong + 19,
|
||||
/* Set the "low speed time" */
|
||||
LowSpeedTime = cOptionLong + 20,
|
||||
/* Set the continuation offset.
|
||||
*
|
||||
* Note there is also a _LARGE version of this key which uses
|
||||
* off_t types, allowing for large file offsets on platforms which
|
||||
* use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE.
|
||||
*/
|
||||
ResumeFrom = cOptionLong + 21,
|
||||
/* Set cookie in request: */
|
||||
Cookie = cOptionString + 22,
|
||||
/* This points to a linked list of headers, struct curl_slist kind. This
|
||||
list is also used for RTSP (in spite of its name) */
|
||||
HTTPHeader = cOptionObject + 23,
|
||||
/* This points to a linked list of post entries, struct curl_HTTPpost */
|
||||
HTTPpost = cOptionObject + 24,
|
||||
/* name of the file keeping your private SSL-certificate */
|
||||
SSLCert = cOptionString + 25,
|
||||
/* password for the SSL or SSH private key */
|
||||
KeyPasswd = cOptionString + 26,
|
||||
/* send TYPE parameter? */
|
||||
CRLF = cOptionLong + 27,
|
||||
/* send linked-list of QUOTE commands */
|
||||
Quote = cOptionObject + 28,
|
||||
/* send FILE * or void * to store headers to, if you use a callback it
|
||||
is simply passed to the callback unmodified */
|
||||
HeaderData = cOptionObject + 29,
|
||||
/* point to a file to read the initial cookies from, also enables
|
||||
"cookie awareness" */
|
||||
CookieFile = cOptionString + 31,
|
||||
/* What version to specifically try to use.
|
||||
See CURL_SSLVERSION defines below. */
|
||||
SSLVersion = cOptionLong + 32,
|
||||
/* What kind of HTTP time condition to use, see defines */
|
||||
TimeCondition = cOptionLong + 33,
|
||||
/* Time to use with the above condition. Specified in number of seconds
|
||||
since 1 Jan 1970 */
|
||||
TimeValue = cOptionLong + 34,
|
||||
/* 35 = OBSOLETE */
|
||||
/* Custom request, for customizing the get command like
|
||||
HTTP: DELETE, TRACE and others
|
||||
FTP: to use a different list command
|
||||
*/
|
||||
Customrequest = cOptionString + 36,
|
||||
/* FILE handle to use instead of stderr */
|
||||
Stderr = cOptionObject + 37,
|
||||
/* 38 is not used */
|
||||
/* send linked-list of post-transfer QUOTE commands */
|
||||
Postquote = cOptionObject + 39,
|
||||
Verbose = cOptionLong + 41, /* talk a lot */
|
||||
Header = cOptionLong + 42, /* throw the header out too */
|
||||
NoProgress = cOptionLong + 43, /* shut off the progress meter */
|
||||
NoBody = cOptionLong + 44, /* use HEAD to get HTTP document */
|
||||
FailOnError = cOptionLong + 45, /* no output on HTTP error codes >= 400 */
|
||||
Upload = cOptionLong + 46, /* this is an upload */
|
||||
Post = cOptionLong + 47, /* HTTP POST method */
|
||||
Dirlistonly = cOptionLong + 48, /* bare names when listing directories */
|
||||
Append = cOptionLong + 50, /* Append instead of overwrite on upload! */
|
||||
/* Specify whether to read the user+password from the .netrc or the URL.
|
||||
* This must be one of the CURL_NETRC_* enums below. */
|
||||
NetRC = cOptionLong + 51,
|
||||
FollowLocation = cOptionLong + 52, /* use Location: Luke! */
|
||||
TransferText = cOptionLong + 53, /* transfer data in text/ASCII format */
|
||||
Put = cOptionLong + 54, /* HTTP PUT */
|
||||
/* 55 = OBSOLETE */
|
||||
/* DEPRECATED
|
||||
* Function that will be called instead of the internal progress display
|
||||
* function. This function should be defined as the curl_progress_callback
|
||||
* prototype defines. */
|
||||
ProgressFunction = cOptionFunction + 56,
|
||||
/* Data passed to the CURLOPT_PROGRESSFUNCTION and CURLOPT_XFERINFOFUNCTION
|
||||
callbacks */
|
||||
ProgressData = cOptionObject + 57,
|
||||
XferInfoData = cOptionObject + 57,
|
||||
/* We want the referrer field set automatically when following locations */
|
||||
AutoReferer = cOptionLong + 58,
|
||||
/* Port of the proxy, can be set in the proxy string as well with:
|
||||
"[host]:[port]" */
|
||||
ProxyPort = cOptionLong + 59,
|
||||
/* size of the POST input data, if strlen() is not good to use */
|
||||
PostfieldSize = cOptionLong + 60,
|
||||
/* tunnel non-HTTP operations through a HTTP proxy */
|
||||
HTTPProxyTunnel = cOptionLong + 61,
|
||||
/* Set the interface string to use as outgoing network interface */
|
||||
Interface = cOptionString + 62,
|
||||
/* Set the krb4/5 security level, this also enables krb4/5 awareness. This
|
||||
* is a string, 'clear', 'safe', 'confidential' or 'private'. If the string
|
||||
* is set but doesn't match one of these, 'private' will be used. */
|
||||
KrbLevel = cOptionString + 63,
|
||||
/* Set if we should verify the peer in SSL handshake, set 1 to verify. */
|
||||
SSLVerifyPeer = cOptionLong + 64,
|
||||
/* The CApath or CAfile used to validate the peer certificate
|
||||
this option is used only if SSL_VERIFYPEER is true */
|
||||
CAInfo = cOptionString + 65,
|
||||
/* 66 = OBSOLETE */ /* 67 = OBSOLETE */
|
||||
/* Maximum number of HTTP redirects to follow */
|
||||
MaxRedirs = cOptionLong + 68,
|
||||
/* Pass a long set to 1 to get the date of the requested document (if
|
||||
possible)! Pass a zero to shut it off. */
|
||||
FileTime = cOptionLong + 69,
|
||||
/* This points to a linked list of telnet options */
|
||||
TelnetOptions = cOptionObject + 70,
|
||||
/* Max amount of cached alive connections */
|
||||
MaxConnects = cOptionLong + 71,
|
||||
/* Set to explicitly use a new connection for the upcoming transfer.
|
||||
Do not use this unless you're absolutely sure of this, as it makes the
|
||||
operation slower and is less friendly for the network. */
|
||||
FreshConnect = cOptionLong + 74,
|
||||
/* Set to explicitly forbid the upcoming transfer's connection to be re-used
|
||||
when done. Do not use this unless you're absolutely sure of this, as it
|
||||
makes the operation slower and is less friendly for the network. */
|
||||
ForbidReuse = cOptionLong + 75,
|
||||
/* Set to a file name that contains random data for libcurl to use to
|
||||
seed the random engine when doing SSL connects. */
|
||||
RandomFile = cOptionString + 76,
|
||||
/* Set to the Entropy Gathering Daemon socket pathname */
|
||||
EGDSocket = cOptionString + 77,
|
||||
/* Time-out connect operations after this amount of seconds, if connects are
|
||||
OK within this time, then fine... This only aborts the connect phase. */
|
||||
ConnectTimeout = cOptionLong + 78,
|
||||
/* Function that will be called to store headers (instead of fwrite). The
|
||||
* parameters will use fwrite() syntax, make sure to follow them. */
|
||||
HeaderFunction = cOptionFunction + 79,
|
||||
/* Set this to force the HTTP request to get back to GET. Only really usable
|
||||
if POST, PUT or a custom request have been used first.
|
||||
*/
|
||||
HTTPGet = cOptionLong + 80,
|
||||
/* Set if we should verify the Common name from the peer certificate in SSL
|
||||
* handshake, set 1 to check existence, 2 to ensure that it matches the
|
||||
* provided hostname. */
|
||||
SSLVerifyHost = cOptionLong + 81,
|
||||
/* Specify which file name to write all known cookies in after completed
|
||||
operation. Set file name to "-" (dash) to make it go to stdout. */
|
||||
CookieJar = cOptionString + 82,
|
||||
/* Specify which SSL ciphers to use */
|
||||
SSLCipherList = cOptionString + 83,
|
||||
/* Specify which HTTP version to use! This must be set to one of the
|
||||
CURL_HTTP_VERSION* enums set below. */
|
||||
HTTPVersion = cOptionLong + 84,
|
||||
/* Specifically switch on or off the FTP engine's use of the EPSV command. By
|
||||
default, that one will always be attempted before the more traditional
|
||||
PASV command. */
|
||||
FTPUseEPSV = cOptionLong + 85,
|
||||
/* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */
|
||||
SSLCertType = cOptionString + 86,
|
||||
/* name of the file keeping your private SSL-key */
|
||||
SSLKey = cOptionString + 87,
|
||||
/* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */
|
||||
SSLKeyType = cOptionString + 88,
|
||||
/* crypto engine for the SSL-sub system */
|
||||
SSLEngine = cOptionString + 89,
|
||||
/* set the crypto engine for the SSL-sub system as default
|
||||
the param has no meaning...
|
||||
*/
|
||||
SSLEngineDefault = cOptionLong + 90,
|
||||
/* Non-zero value means to use the global dns cache */
|
||||
DnsUseGlobalCache = cOptionLong + 91, /* DEPRECATED, do not use! */
|
||||
/* DNS cache timeout */
|
||||
DnsCacheTimeout = cOptionLong + 92,
|
||||
/* send linked-list of pre-transfer QUOTE commands */
|
||||
PreQuote = cOptionObject + 93,
|
||||
/* set the debug function */
|
||||
DebugFunction = cOptionFunction + 94,
|
||||
/* set the data for the debug function */
|
||||
DebugData = cOptionObject + 95,
|
||||
/* mark this as start of a cookie session */
|
||||
CookieSession = cOptionLong + 96,
|
||||
/* The CApath directory used to validate the peer certificate
|
||||
this option is used only if SSL_VERIFYPEER is true */
|
||||
CAPath = cOptionString + 97,
|
||||
/* Instruct libcurl to use a smaller receive buffer */
|
||||
BufferSize = cOptionLong + 98,
|
||||
/* Instruct libcurl to not use any signal/alarm handlers, even when using
|
||||
timeouts. This option is useful for multi-threaded applications.
|
||||
See libcurl-the-guide for more background information. */
|
||||
NoSignal = cOptionLong + 99,
|
||||
/* Provide a CURLShare for mutexing non-ts data */
|
||||
Share = cOptionObject + 100,
|
||||
/* indicates type of proxy. accepted values are CURLPROXY_HTTP (default,
|
||||
CURLPROXY_HTTPS, CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and
|
||||
CURLPROXY_SOCKS5. */
|
||||
ProxyType = cOptionLong + 101,
|
||||
/* Set the Accept-Encoding string. Use this to tell a server you would like
|
||||
the response to be compressed. Before 7.21.6, this was known as
|
||||
CURLOPT_ENCODING */
|
||||
AcceptEncoding = cOptionString + 102,
|
||||
/* Set pointer to private data */
|
||||
Private = cOptionObject + 103,
|
||||
/* Set aliases for HTTP 200 in the HTTP Response header */
|
||||
HTTP200Aliases = cOptionObject + 104,
|
||||
/* Continue to send authentication (user+password) when following locations,
|
||||
even when hostname changed. This can potentially send off the name
|
||||
and password to whatever host the server decides. */
|
||||
UnrestrictedAuth = cOptionLong + 105,
|
||||
/* Specifically switch on or off the FTP engine's use of the EPRT command (
|
||||
it also disables the LPRT attempt). By default, those ones will always be
|
||||
attempted before the good old traditional PORT command. */
|
||||
FTPUseEPRT = cOptionLong + 106,
|
||||
/* Set this to a bitmask value to enable the particular authentications
|
||||
methods you like. Use this in combination with CURLOPT_USERPWD.
|
||||
Note that setting multiple bits may cause extra network round-trips. */
|
||||
HTTPAuth = cOptionLong + 107,
|
||||
/* Set the SSL context callback function, currently only for OpenSSL SSL_ctx
|
||||
in second argument. The function must be matching the
|
||||
curl_SSL_ctx_callback proto. */
|
||||
SSLCTXFunction = cOptionFunction + 108,
|
||||
/* Set the userdata for the SSL context callback function's third
|
||||
argument */
|
||||
SSLCTXData = cOptionObject + 109,
|
||||
/* FTP Option that causes missing dirs to be created on the remote server.
|
||||
In 7.19.4 we introduced the convenience enums for this option using the
|
||||
CURLFTP_CREATE_DIR prefix.
|
||||
*/
|
||||
FTPCreateMissingDirs = cOptionLong + 110,
|
||||
/* Set this to a bitmask value to enable the particular authentications
|
||||
methods you like. Use this in combination with CURLOPT_PROXYUSERPWD.
|
||||
Note that setting multiple bits may cause extra network round-trips. */
|
||||
ProxyAuth = cOptionLong + 111,
|
||||
/* FTP option that changes the timeout, in seconds, associated with
|
||||
getting a response. This is different from transfer timeout time and
|
||||
essentially places a demand on the FTP server to acknowledge commands
|
||||
in a timely manner. */
|
||||
FTPResponseTimeout = cOptionLong + 112,
|
||||
/* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to
|
||||
tell libcurl to resolve names to those IP versions only. This only has
|
||||
affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */
|
||||
IPResolve = cOptionLong + 113,
|
||||
/* Set this option to limit the size of a file that will be downloaded from
|
||||
an HTTP or FTP server.
|
||||
|
||||
Note there is also _LARGE version which adds large file support for
|
||||
platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */
|
||||
MaxFileSize = cOptionLong + 114,
|
||||
/* See the comment for INFILESIZE above, but in short, specifies
|
||||
* the size of the file being uploaded. -1 means unknown.
|
||||
*/
|
||||
InFileSizeLarge = cOptionOffT + 115,
|
||||
/* Sets the continuation offset. There is also a LONG version of this;
|
||||
* look above for RESUME_FROM.
|
||||
*/
|
||||
ResumeFromLarge = cOptionOffT + 116,
|
||||
/* Sets the maximum size of data that will be downloaded from
|
||||
* an HTTP or FTP server. See MAXFILESIZE above for the LONG version.
|
||||
*/
|
||||
MaxFileSizeLarge = cOptionOffT + 117,
|
||||
/* Set this option to the file name of your .netrc file you want libcurl
|
||||
to parse (using the CURLOPT_NETRC option). If not set, libcurl will do
|
||||
a poor attempt to find the user's home directory and check for a .netrc
|
||||
file in there. */
|
||||
NetRCFile = cOptionString + 118,
|
||||
/* Enable SSL/TLS for FTP, pick one of:
|
||||
CURLUSESSL_TRY - try using SSL, proceed anyway otherwise
|
||||
CURLUSESSL_CONTROL - SSL for the control connection or fail
|
||||
CURLUSESSL_ALL - SSL for all communication or fail
|
||||
*/
|
||||
UseSSL = cOptionLong + 119,
|
||||
/* The _LARGE version of the standard POSTFIELDSIZE option */
|
||||
PostfieldsizeLarge = cOptionOffT + 120,
|
||||
/* Enable/disable the TCP Nagle algorithm */
|
||||
TCPNoDelay = cOptionLong + 121,
|
||||
/* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ /* 123 OBSOLETE. Gone in 7.16.0 */ /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ /* 127 OBSOLETE. Gone in 7.16.0 */ /* 128 OBSOLETE. Gone in 7.16.0 */
|
||||
/* When FTP over SSL/TLS is selected (with CURLOPT_USE_SSL, this option
|
||||
can be used to change libcurl's default action which is to first try
|
||||
"AUTH SSL" and then "AUTH TLS" in this order, and proceed when a OK
|
||||
response has been received.
|
||||
|
||||
Available parameters are:
|
||||
CURLFTPAUTH_DEFAULT - let libcurl decide
|
||||
CURLFTPAUTH_SSL - try "AUTH SSL" first, then TLS
|
||||
CURLFTPAUTH_TLS - try "AUTH TLS" first, then SSL
|
||||
*/
|
||||
FTPSSLauth = cOptionLong + 129,
|
||||
IoctlFunction = cOptionFunction + 130,
|
||||
IoctlData = cOptionObject + 131,
|
||||
/* 132 OBSOLETE. Gone in 7.16.0 */ /* 133 OBSOLETE. Gone in 7.16.0 */
|
||||
/* zero terminated string for pass on to the FTP server when asked for
|
||||
"account" info */
|
||||
FTPAccount = cOptionString + 134,
|
||||
/* feed cookie into cookie engine */
|
||||
CookieList = cOptionString + 135,
|
||||
/* ignore Content-Length */
|
||||
IgnoreContentLength = cOptionLong + 136,
|
||||
/* Set to non-zero to skip the IP address received in a 227 PASV FTP server
|
||||
response. Typically used for FTP-SSL purposes but is not restricted to
|
||||
that. libcurl will then instead use the same IP address it used for the
|
||||
control connection. */
|
||||
FTPSkipPasvIP = cOptionLong + 137,
|
||||
/* Select "file method" to use when doing FTP, see the curl_FTPmethod
|
||||
above. */
|
||||
FTPFileMethod = cOptionLong + 138,
|
||||
/* Local port number to bind the socket to */
|
||||
LocalPort = cOptionLong + 139,
|
||||
/* Number of ports to try, including the first one set with LOCALPORT.
|
||||
Thus, setting it to 1 will make no additional attempts but the first.
|
||||
*/
|
||||
LocalPortRange = cOptionLong + 140,
|
||||
/* no transfer, set up connection and let application use the socket by
|
||||
extracting it with CURLINFO_LASTSOCKET */
|
||||
ConnectOnly = cOptionLong + 141,
|
||||
/* Function that will be called to convert from the
|
||||
network encoding (instead of using the iconv calls in libcurl) */
|
||||
ConvFromNetworkFunction = cOptionFunction + 142,
|
||||
/* Function that will be called to convert to the
|
||||
network encoding (instead of using the iconv calls in libcurl) */
|
||||
ConvToNetworkFunction = cOptionFunction + 143,
|
||||
/* Function that will be called to convert from UTF8
|
||||
(instead of using the iconv calls in libcurl)
|
||||
Note that this is used only for SSL certificate processing */
|
||||
ConvFromUTF8Function = cOptionFunction + 144,
|
||||
/* if the connection proceeds too quickly then need to slow it down */ /* limit-rate: maximum number of bytes per second to send or receive */
|
||||
MaxSendSpeedLarge = cOptionOffT + 145,
|
||||
MaxRecvSpeedLarge = cOptionOffT + 146,
|
||||
/* Pointer to command string to send if USER/PASS fails. */
|
||||
FTPAlternativeToUser = cOptionString + 147,
|
||||
/* callback function for setting socket options */
|
||||
SockoptFunction = cOptionFunction + 148,
|
||||
SockoptData = cOptionObject + 149,
|
||||
/* set to 0 to disable session ID re-use for this transfer, default is
|
||||
enabled (== 1) */
|
||||
SSLSessionIDCache = cOptionLong + 150,
|
||||
/* allowed SSH authentication methods */
|
||||
SSHAuthTypes = cOptionLong + 151,
|
||||
/* Used by scp/sftp to do public/private key authentication */
|
||||
SSHPublicKeyfile = cOptionString + 152,
|
||||
SSHPrivateKeyfile = cOptionString + 153,
|
||||
/* Send CCC (Clear Command Channel) after authentication */
|
||||
FtpSSLCcc = cOptionLong + 154,
|
||||
/* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */
|
||||
TimeoutMs = cOptionLong + 155,
|
||||
ConnecttimeoutMs = cOptionLong + 156,
|
||||
/* set to zero to disable the libcurl's decoding and thus pass the raw body
|
||||
data to the application even when it is encoded/compressed */
|
||||
HTTPTransferDecoding = cOptionLong + 157,
|
||||
HTTPContentDecoding = cOptionLong + 158,
|
||||
/* Permission used when creating new files and directories on the remote
|
||||
server for protocols that support it, SFTP/SCP/FILE */
|
||||
NewFilePerms = cOptionLong + 159,
|
||||
NewDirectoryPerms = cOptionLong + 160,
|
||||
/* Set the behaviour of POST when redirecting. Values must be set to one
|
||||
of CURL_REDIR* defines below. This used to be called CURLOPT_POST301 */
|
||||
POSTREDIR = cOptionLong + 161,
|
||||
/* used by scp/sftp to verify the host's public key */
|
||||
SSHHostPublicKeyMd5 = cOptionString + 162,
|
||||
|
||||
/* Callback function for opening socket (instead of socket(2)). Optionally,
|
||||
callback is able change the address or refuse to connect returning
|
||||
CURL_SOCKET_BAD. The callback should have type
|
||||
curl_opensocket_callback */
|
||||
Opensocketfunction = cOptionFunction + 163,
|
||||
Opensocketdata = cOptionObject + 164,
|
||||
/* POST volatile input fields. */
|
||||
Copypostfields = cOptionObject + 165,
|
||||
/* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */
|
||||
ProxyTransferMode = cOptionLong + 166,
|
||||
/* Callback function for seeking in the input stream */
|
||||
Seekfunction = cOptionFunction + 167,
|
||||
Seekdata = cOptionObject + 168,
|
||||
/* CRL file */
|
||||
Crlfile = cOptionString + 169,
|
||||
/* Issuer certificate */
|
||||
Issuercert = cOptionString + 170,
|
||||
/* (IPv6) Address scope */
|
||||
AddressScope = cOptionLong + 171,
|
||||
/* Collect certificate chain info and allow it to get retrievable with
|
||||
CURLINFO_CERTINFO after the transfer is complete. */
|
||||
Certinfo = cOptionLong + 172,
|
||||
/* "name" and "pwd" to use when fetching. */
|
||||
Username = cOptionString + 173,
|
||||
Password = cOptionString + 174,
|
||||
/* "name" and "pwd" to use with Proxy when fetching. */
|
||||
Proxyusername = cOptionString + 175,
|
||||
Proxypassword = cOptionString + 176,
|
||||
/* Comma separated list of hostnames defining no-proxy zones. These should
|
||||
match both hostnames directly, and hostnames within a domain. For
|
||||
example, local.com will match local.com and www.local.com, but NOT
|
||||
notlocal.com or www.notlocal.com. For compatibility with other
|
||||
implementations of this, .local.com will be considered to be the same as
|
||||
local.com. A single * is the only valid wildcard, and effectively
|
||||
disables the use of proxy. */
|
||||
Noproxy = cOptionString + 177,
|
||||
/* block size for TFTP transfers */
|
||||
TFTPBlksize = cOptionLong + 178,
|
||||
/* Socks Service */
|
||||
Socks5GssapiService = cOptionString + 179, /* DEPRECATED, do not use! */
|
||||
/* Socks Service */
|
||||
Socks5GssapiNec = cOptionLong + 180,
|
||||
/* set the bitmask for the protocols that are allowed to be used for the
|
||||
transfer, which thus helps the app which takes URLs from users or other
|
||||
external inputs and want to restrict what protocol(s) to deal
|
||||
with. Defaults to CURLPROTO_ALL. */
|
||||
Protocols = cOptionLong + 181,
|
||||
/* set the bitmask for the protocols that libcurl is allowed to follow to,
|
||||
as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs
|
||||
to be set in both bitmasks to be allowed to get redirected to. Defaults
|
||||
to all protocols except FILE and SCP. */
|
||||
RedirProtocols = cOptionLong + 182,
|
||||
/* set the SSH knownhost file name to use */
|
||||
SSHKnownhosts = cOptionString + 183,
|
||||
/* set the SSH host key callback, must point to a curl_SSHkeycallback
|
||||
function */
|
||||
SSHKeyfunction = cOptionFunction + 184,
|
||||
/* set the SSH host key callback custom pointer */
|
||||
SSHKeydata = cOptionObject + 185,
|
||||
/* set the SMTP mail originator */
|
||||
MailFrom = cOptionString + 186,
|
||||
/* set the list of SMTP mail receiver(s) */
|
||||
MailRcpt = cOptionObject + 187,
|
||||
/* FTP: send PRET before PASV */
|
||||
FtpUsePret = cOptionLong + 188,
|
||||
/* RTSP request method (OPTIONS, SETUP, PLAY, etc...) */
|
||||
RTSPRequest = cOptionLong + 189,
|
||||
/* The RTSP session identifier */
|
||||
RTSPSessionID = cOptionString + 190,
|
||||
/* The RTSP stream URI */
|
||||
RTSPStreamUri = cOptionString + 191,
|
||||
/* The Transport: header to use in RTSP requests */
|
||||
RTSPTransport = cOptionString + 192,
|
||||
/* Manually initialize the client RTSP CSeq for this handle */
|
||||
RTSPClientCseq = cOptionLong + 193,
|
||||
/* Manually initialize the server RTSP CSeq for this handle */
|
||||
RTSPServerCseq = cOptionLong + 194,
|
||||
/* The stream to pass to INTERLEAVEFUNCTION. */
|
||||
Interleavedata = cOptionObject + 195,
|
||||
/* Let the application define a custom write method for RTP data */
|
||||
Interleavefunction = cOptionFunction + 196,
|
||||
/* Turn on wildcard matching */
|
||||
Wildcardmatch = cOptionLong + 197,
|
||||
/* Directory matching callback called before downloading of an
|
||||
individual file (chunk) started */
|
||||
ChunkBgnFunction = cOptionFunction + 198,
|
||||
/* Directory matching callback called after the file (chunk)
|
||||
was downloaded, or skipped */
|
||||
ChunkEndFunction = cOptionFunction + 199,
|
||||
/* Change match (fnmatch-like) callback for wildcard matching */
|
||||
FnmatchFunction = cOptionFunction + 200,
|
||||
/* Let the application define custom chunk data pointer */
|
||||
ChunkData = cOptionObject + 201,
|
||||
/* FNMATCH_FUNCTION user pointer */
|
||||
FnmatchData = cOptionObject + 202,
|
||||
/* send linked-list of name:port:address sets */
|
||||
Resolve = cOptionObject + 203,
|
||||
/* Set a username for authenticated TLS */
|
||||
TLSAuthUsername = cOptionString + 204,
|
||||
/* Set a password for authenticated TLS */
|
||||
TLSAuthPassword = cOptionString + 205,
|
||||
/* Set authentication type for authenticated TLS */
|
||||
TLSAuthType = cOptionString + 206,
|
||||
|
||||
/* Set to 1 to enable the "TE:" header in HTTP requests to ask for
|
||||
compressed transfer-encoded responses. Set to 0 to disable the use of TE:
|
||||
in outgoing requests. The current default is 0, but it might change in a
|
||||
future libcurl release.
|
||||
|
||||
libcurl will ask for the compressed methods it knows of, and if that
|
||||
isn't any, it will not ask for transfer-encoding at all even if this
|
||||
option is set to 1.
|
||||
|
||||
*/
|
||||
TransferEncoding = cOptionLong + 207,
|
||||
/* Callback function for closing socket (instead of close(2)). The callback
|
||||
should have type curl_closesocket_callback */
|
||||
Closesocketfunction = cOptionFunction + 208,
|
||||
Closesocketdata = cOptionObject + 209,
|
||||
/* allow GSSAPI credential delegation */
|
||||
GssapiDelegation = cOptionLong + 210,
|
||||
/* Set the name servers to use for DNS resolution */
|
||||
DnsServers = cOptionString + 211,
|
||||
/* Time-out accept operations (currently for FTP only) after this amount
|
||||
of milliseconds. */
|
||||
AccepttimeoutMs = cOptionLong + 212,
|
||||
/* Set TCP keepalive */
|
||||
TCPKeepalive = cOptionLong + 213,
|
||||
/* non-universal keepalive knobs (Linux, AIX, HP-UX, more) */
|
||||
TCPKeepidle = cOptionLong + 214,
|
||||
TCPKeepintvl = cOptionLong + 215,
|
||||
/* Enable/disable specific SSL features with a bitmask, see CURLSSLOPT_* */
|
||||
SSLOptions = cOptionLong + 216,
|
||||
/* Set the SMTP auth originator */
|
||||
MailAuth = cOptionString + 217,
|
||||
/* Enable/disable SASL initial response */
|
||||
SASlIr = cOptionLong + 218,
|
||||
/* Function that will be called instead of the internal progress display
|
||||
* function. This function should be defined as the curl_xferinfo_callback
|
||||
* prototype defines. (Deprecates CURLOPT_PROGRESSFUNCTION) */
|
||||
XferInfoFunction = cOptionFunction + 219,
|
||||
/* The XOAUTH2 bearer token */
|
||||
Xoauth2Bearer = cOptionString + 220,
|
||||
/* Set the interface string to use as outgoing network
|
||||
* interface for DNS requests.
|
||||
* Only supported by the c-ares DNS backend */
|
||||
DnsInterface = cOptionString + 221,
|
||||
/* Set the local IPv4 address to use for outgoing DNS requests.
|
||||
* Only supported by the c-ares DNS backend */
|
||||
DnsLocalIp4 = cOptionString + 222,
|
||||
/* Set the local IPv4 address to use for outgoing DNS requests.
|
||||
* Only supported by the c-ares DNS backend */
|
||||
DnsLocalIp6 = cOptionString + 223,
|
||||
/* Set authentication options directly */
|
||||
LoginOptions = cOptionString + 224,
|
||||
/* Enable/disable TLS NPN extension (http2 over SSL might fail without) */
|
||||
SSLEnableNpn = cOptionLong + 225,
|
||||
/* Enable/disable TLS ALPN extension (http2 over SSL might fail without) */
|
||||
SSLEnableAlpn = cOptionLong + 226,
|
||||
/* Time to wait for a response to a HTTP request containing an
|
||||
* Expect: 100-continue header before sending the data anyway. */
|
||||
Expect100TimeoutMs = cOptionLong + 227,
|
||||
/* This points to a linked list of headers used for proxy requests only,
|
||||
struct curl_slist kind */
|
||||
ProxyHeader = cOptionObject + 228,
|
||||
/* Pass in a bitmask of "header options" */
|
||||
HeaderOpt = cOptionLong + 229,
|
||||
/* The public key in DER form used to validate the peer public key
|
||||
this option is used only if SSL_VERIFYPEER is true */
|
||||
Pinnedpublickey = cOptionString + 230,
|
||||
/* Path to Unix domain socket */
|
||||
UnixSocketPath = cOptionString + 231,
|
||||
/* Set if we should verify the certificate status. */
|
||||
SSLVerifystatus = cOptionLong + 232,
|
||||
/* Set if we should enable TLS false start. */
|
||||
SSLFalsestart = cOptionLong + 233,
|
||||
/* Do not squash dot-dot sequences */
|
||||
PathAsIs = cOptionLong + 234,
|
||||
/* Proxy Service Name */
|
||||
ProxyServiceName = cOptionString + 235,
|
||||
/* Service Name */
|
||||
ServiceName = cOptionString + 236,
|
||||
/* Wait/don't wait for pipe/mutex to clarify */
|
||||
Pipewait = cOptionLong + 237,
|
||||
/* Set the protocol used when curl is given a URL without a protocol */
|
||||
DefaultProtocol = cOptionString + 238,
|
||||
/* Set stream weight, 1 - 256 (default is 16) */
|
||||
StreamWeight = cOptionLong + 239,
|
||||
/* Set stream dependency on another CURL handle */
|
||||
StreamDepends = cOptionObject + 240,
|
||||
/* Set E-xclusive stream dependency on another CURL handle */
|
||||
StreamDependsE = cOptionObject + 241,
|
||||
/* Do not send any TFTP option requests to the server */
|
||||
TFTPNoOptions = cOptionLong + 242,
|
||||
/* Linked-list of host:port:connect-to-host:connect-to-port,
|
||||
overrides the URL's host:port (only for the network layer) */
|
||||
ConnectTo = cOptionObject + 243,
|
||||
/* Set TCP Fast Open */
|
||||
TCPFastOpen = cOptionLong + 244,
|
||||
/* Continue to send data if the server responds early with an
|
||||
* HTTP status code >= 300 */
|
||||
KeepSendingOnError = cOptionLong + 245,
|
||||
/* The CApath or CAfile used to validate the proxy certificate
|
||||
this option is used only if PROXY_SSL_VERIFYPEER is true */
|
||||
ProxyCainfo = cOptionString + 246,
|
||||
/* The CApath directory used to validate the proxy certificate
|
||||
this option is used only if PROXY_SSL_VERIFYPEER is true */
|
||||
ProxyCapath = cOptionString + 247,
|
||||
/* Set if we should verify the proxy in SSL handshake,
|
||||
set 1 to verify. */
|
||||
ProxySSLVerifypeer = cOptionLong + 248,
|
||||
/* Set if we should verify the Common name from the proxy certificate in SSL
|
||||
* handshake, set 1 to check existence, 2 to ensure that it matches
|
||||
* the provided hostname. */
|
||||
ProxySSLVerifyhost = cOptionLong + 249,
|
||||
/* What version to specifically try to use for proxy.
|
||||
See CURL_SSLVERSION defines below. */
|
||||
ProxySSLversion = cOptionLong + 250,
|
||||
/* Set a username for authenticated TLS for proxy */
|
||||
ProxyTLSAuthUsername = cOptionString + 251,
|
||||
/* Set a password for authenticated TLS for proxy */
|
||||
ProxyTLSAuthPassword = cOptionString + 252,
|
||||
/* Set authentication type for authenticated TLS for proxy */
|
||||
ProxyTLSAuthType = cOptionString + 253,
|
||||
/* name of the file keeping your private SSL-certificate for proxy */
|
||||
ProxySSLCert = cOptionString + 254,
|
||||
/* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") for
|
||||
proxy */
|
||||
ProxySSLCerttype = cOptionString + 255,
|
||||
/* name of the file keeping your private SSL-key for proxy */
|
||||
ProxySSLkey = cOptionString + 256,
|
||||
/* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") for
|
||||
proxy */
|
||||
ProxySSLkeytype = cOptionString + 257,
|
||||
/* password for the SSL private key for proxy */
|
||||
ProxyKeypasswd = cOptionString + 258,
|
||||
/* Specify which SSL ciphers to use for proxy */
|
||||
ProxySSLCipherList = cOptionString + 259,
|
||||
/* CRL file for proxy */
|
||||
ProxyCrlfile = cOptionString + 260,
|
||||
/* Enable/disable specific SSL features with a bitmask for proxy, see
|
||||
CURLSSLOPT_* */
|
||||
ProxySSLOptions = cOptionLong + 261,
|
||||
/* Name of pre proxy to use. */
|
||||
PreProxy = cOptionString + 262,
|
||||
/* The public key in DER form used to validate the proxy public key
|
||||
this option is used only if PROXY_SSL_VERIFYPEER is true */
|
||||
ProxyPinnedpublickey = cOptionString + 263,
|
||||
/* Path to an abstract Unix domain socket */
|
||||
AbstractUnixSocket = cOptionString + 264,
|
||||
/* Suppress proxy CONNECT response headers from user callbacks */
|
||||
SuppressConnectHeaders = cOptionLong + 265,
|
||||
}
|
||||
|
||||
const int32 cInfoString = 0x100000;
|
||||
const int32 cInfoLong = 0x200000;
|
||||
const int32 cInfoDouble = 0x300000;
|
||||
const int32 cInfoSList = 0x400000;
|
||||
const int32 cInfoSocket = 0x500000;
|
||||
const int32 cInfoMask = 0x0fffff;
|
||||
const int32 cInfoTypeMask = 0xf00000;
|
||||
|
||||
public enum CurlInfo
|
||||
{
|
||||
EffectiveUrl = cInfoString + 1,
|
||||
ResponseCode = cInfoLong + 2,
|
||||
TotalTime = cInfoDouble + 3,
|
||||
NameLookupTime = cInfoDouble + 4,
|
||||
ConnectTime = cInfoDouble + 5,
|
||||
PreTransferTime = cInfoDouble + 6,
|
||||
SizeUpload = cInfoDouble + 7,
|
||||
SiadDownload = cInfoDouble + 8,
|
||||
SpeedDownload = cInfoDouble + 9,
|
||||
SpeedUpload = cInfoDouble + 10,
|
||||
HeaderSize = cInfoLong + 11,
|
||||
RequestSize = cInfoLong + 12,
|
||||
SSLVerifyResult = cInfoLong + 13,
|
||||
FileTime = cInfoLong + 14,
|
||||
ContentLengthDownload = cInfoDouble + 15,
|
||||
ContentLengthUpload = cInfoDouble + 16,
|
||||
StartTransferTime= cInfoDouble + 17,
|
||||
ContentType = cInfoString + 18,
|
||||
RedirectTime = cInfoDouble + 19,
|
||||
RedirectCount = cInfoLong + 20,
|
||||
Private = cInfoString + 21,
|
||||
HTTPConntectCode = cInfoLong + 22,
|
||||
HTTPAuthAvail = cInfoLong + 23,
|
||||
ProxyAuthAvail = cInfoLong + 24,
|
||||
OsErrno = cInfoLong + 25,
|
||||
NumConnects = cInfoLong + 26,
|
||||
SSLEngines = cInfoSList + 27,
|
||||
CookieList = cInfoSList + 28,
|
||||
LastSocket = cInfoLong + 29,
|
||||
FTPEntryPath = cInfoString + 30,
|
||||
RedirectURL = cInfoString + 31,
|
||||
PrimaryIP = cInfoString + 32,
|
||||
AppConnectTime = cInfoDouble + 33,
|
||||
CertInfo = cInfoSList + 34,
|
||||
ConditionUnmet = cInfoLong + 35,
|
||||
RTSPSessionID = cInfoString + 36,
|
||||
RTSPClientSEQ = cInfoLong + 37,
|
||||
RTSPServerCSEQ = cInfoLong + 38,
|
||||
RTSPCSEQRecv = cInfoLong + 39,
|
||||
PriamryPort = cInfoLong + 40,
|
||||
LocalIP = cInfoString + 41,
|
||||
LocalPort = cInfoLong + 42,
|
||||
TLSSession = cInfoSList + 43,
|
||||
ActiveSocket = cInfoSocket + 44,
|
||||
TLSSSLPtr = cInfoSList + 45,
|
||||
HTTPVersion = cInfoLong + 46,
|
||||
ProxySSLVerifyResult = cInfoLong + 47,
|
||||
Protocol = cInfoLong + 48,
|
||||
Scheme = cInfoString + 49,
|
||||
};
|
||||
|
||||
public enum ReturnCode
|
||||
{
|
||||
Ok = 0,
|
||||
UnsupportedProtocol, /* 1 */
|
||||
FailedInit, /* 2 */
|
||||
URLMalformat, /* 3 */
|
||||
NotBuiltIn, /* 4 - [was obsoleted in August 2007 for
|
||||
7.17.0, reused in April 2011 for 7.21.5] */
|
||||
CouldntResolveProxy, /* 5 */
|
||||
CouldntResolveHost, /* 6 */
|
||||
CouldntConnect, /* 7 */
|
||||
WeirdServerReply, /* 8 */
|
||||
RemoteAccessDenied, /* 9 a service was denied by the server
|
||||
due to lack of access - when login fails
|
||||
this is not returned. */
|
||||
FTPAcceptFailed, /* 10 - [was obsoleted in April 2006 for
|
||||
7.15.4, reused in Dec 2011 for 7.24.0]*/
|
||||
FTPWeirdPassReply, /* 11 */
|
||||
FTPAcceptTimeout, /* 12 - timeout occurred accepting server
|
||||
[was obsoleted in August 2007 for 7.17.0,
|
||||
reused in Dec 2011 for 7.24.0]*/
|
||||
FTPWeirdPasvReply, /* 13 */
|
||||
FTPWeird227Format, /* 14 */
|
||||
FTPCantGetHost, /* 15 */
|
||||
HTTP2, /* 16 - A problem in the HTTP2 framing layer.
|
||||
[was obsoleted in August 2007 for 7.17.0,
|
||||
reused in July 2014 for 7.38.0] */
|
||||
FTPCouldntSetType, /* 17 */
|
||||
PartialFile, /* 18 */
|
||||
FTPCouldntRetrFile, /* 19 */
|
||||
Obsolete20, /* 20 - NOT USED */
|
||||
QuoteError, /* 21 - quote command failure */
|
||||
HTTPReturnedError, /* 22 */
|
||||
WriteError, /* 23 */
|
||||
Obsolete24, /* 24 - NOT USED */
|
||||
UploadFailed, /* 25 - failed upload "command" */
|
||||
ReadError, /* 26 - couldn't open/read from file */
|
||||
OutOfMemory, /* 27 */
|
||||
/* Note: OUT_OF_MEMORY may sometimes indicate a conversion error
|
||||
instead of a memory allocation error if CURL_DOES_CONVERSIONS
|
||||
is defined
|
||||
*/
|
||||
OperationTimedout, /* 28 - the timeout time was reached */
|
||||
Obsolete29, /* 29 - NOT USED */
|
||||
FTPPortFailed, /* 30 - FTP PORT operation failed */
|
||||
FTPCouldntUseRest, /* 31 - the REST command failed */
|
||||
Obsolete32, /* 32 - NOT USED */
|
||||
RangeError, /* 33 - RANGE "command" didn't work */
|
||||
HTTPPostError, /* 34 */
|
||||
SSLConnectError, /* 35 - wrong when connecting with SSL */
|
||||
BadDownloadResume, /* 36 - couldn't resume download */
|
||||
FileCouldntReadFile, /* 37 */
|
||||
LdapCannotBind, /* 38 */
|
||||
LdapSearchFailed, /* 39 */
|
||||
Obsolete40, /* 40 - NOT USED */
|
||||
FunctionNotFound, /* 41 - NOT USED starting with 7.53.0 */
|
||||
AbortedByCallback, /* 42 */
|
||||
BadFunctionArgument, /* 43 */
|
||||
Obsolete44, /* 44 - NOT USED */
|
||||
InterfaceFailed, /* 45 - CURLOPT_INTERFACE failed */
|
||||
Obsolete46, /* 46 - NOT USED */
|
||||
TooManyRedirects, /* 47 - catch endless re-direct loops */
|
||||
UnknownOption, /* 48 - User specified an unknown option */
|
||||
TelnetOptionSyntax, /* 49 - Malformed telnet option */
|
||||
Obsolete50, /* 50 - NOT USED */
|
||||
PeerFailedVerification, /* 51 - peer's certificate or fingerprint wasn't verified fine */
|
||||
GotNothing, /* 52 - when this is a specific error */
|
||||
SSLEngineNotfound, /* 53 - SSL crypto engine not found */
|
||||
SSLEngineSetfailed, /* 54 - can not set SSL crypto engine as
|
||||
default */
|
||||
SendError, /* 55 - failed sending network data */
|
||||
RecvError, /* 56 - failure in receiving network data */
|
||||
Obsolete57, /* 57 - NOT IN USE */
|
||||
SSLCertproblem, /* 58 - problem with the local certificate */
|
||||
SSLCipher, /* 59 - couldn't use specified cipher */
|
||||
SSLCacert, /* 60 - problem with the CA cert (path?) */
|
||||
BadContentEncoding, /* 61 - Unrecognized/bad encoding */
|
||||
LdapInvalidURL, /* 62 - Invalid LDAP URL */
|
||||
FilesizeExceeded, /* 63 - Maximum file size exceeded */
|
||||
UseSSLFailed, /* 64 - Requested FTP SSL level failed */
|
||||
SendFailRewind, /* 65 - Sending the data requires a rewind
|
||||
that failed */
|
||||
SSLEngineInitfailed, /* 66 - failed to initialise ENGINE */
|
||||
LoginDenied, /* 67 - user, password or similar was not
|
||||
accepted and we failed to login */
|
||||
TFTPNotfound, /* 68 - file not found on server */
|
||||
TFTPPerm, /* 69 - permission problem on server */
|
||||
RemoteDiskFull, /* 70 - out of disk space on server */
|
||||
TFTPIllegal, /* 71 - Illegal TFTP operation */
|
||||
TFTPUnknownid, /* 72 - Unknown transfer ID */
|
||||
RemoteFileExists, /* 73 - File already exists */
|
||||
TFTPNosuchuser, /* 74 - No such user */
|
||||
ConvFailed, /* 75 - conversion failed */
|
||||
ConvReqd, /* 76 - caller must register conversion
|
||||
callbacks using curl_easy_setopt options
|
||||
CURLOPT_CONV_FROM_NETWORK_FUNCTION,
|
||||
CURLOPT_CONV_TO_NETWORK_FUNCTION, and
|
||||
CURLOPT_CONV_FROM_UTF8_FUNCTION */
|
||||
SSLCacertBadfile, /* 77 - could not load CACERT file, missing
|
||||
or wrong format */
|
||||
RemoteFileNotFound, /* 78 - remote file not found */
|
||||
SSH, /* 79 - error from the SSH layer, somewhat
|
||||
generic so the error message will be of
|
||||
interest when this has happened */
|
||||
|
||||
SSLShutdownFailed, /* 80 - Failed to shut down the SSL
|
||||
connection */
|
||||
Again, /* 81 - socket is not ready for send/recv,
|
||||
wait till it's ready and try again (Added
|
||||
in 7.18.2) */
|
||||
SSLCrlBadfile, /* 82 - could not load CRL file, missing or
|
||||
wrong format (Added in 7.19.0) */
|
||||
SSLIssuerError, /* 83 - Issuer check failed. (Added in
|
||||
7.19.0) */
|
||||
FTPPretFailed, /* 84 - a PRET command failed */
|
||||
RtspCseqError, /* 85 - mismatch of RTSP CSeq numbers */
|
||||
RtspSessionError, /* 86 - mismatch of RTSP Session Ids */
|
||||
FTPBadFileList, /* 87 - unable to parse FTP file list */
|
||||
ChunkFailed, /* 88 - chunk callback reported error */
|
||||
NoConnectionAvailable, /* 89 - No connection available, the session will be queued */
|
||||
SSLPinnedpubkeynotmatch, /* 90 - specified pinned public key did not
|
||||
match */
|
||||
SSLInvalidcertstatus, /* 91 - invalid certificate status */
|
||||
HTTP2Stream, /* 92 - stream error in HTTP/2 framing layer */
|
||||
}
|
||||
|
||||
[CLink, StdCall]
|
||||
static extern void* curl_easy_init();
|
||||
|
||||
[CLink, StdCall]
|
||||
static extern int curl_easy_setopt(void* curl, int option, int optVal);
|
||||
|
||||
[CLink, StdCall]
|
||||
static extern void* curl_easy_duphandle(void* curl);
|
||||
|
||||
[CLink, StdCall]
|
||||
static extern void* curl_easy_cleanup(void* curl);
|
||||
|
||||
[CLink, StdCall]
|
||||
static extern int curl_easy_perform(void* curl);
|
||||
|
||||
[CLink, StdCall]
|
||||
static extern void* curl_easy_getinfo(void* curl, Option option, void* ptr);
|
||||
|
||||
[CLink, StdCall]
|
||||
static extern void* curl_easy_reset(void* curl);
|
||||
|
||||
void* mCURL;
|
||||
|
||||
public this()
|
||||
{
|
||||
mCURL = curl_easy_init();
|
||||
}
|
||||
|
||||
public this(Easy initFrom)
|
||||
{
|
||||
mCURL = curl_easy_duphandle(initFrom.mCURL);
|
||||
}
|
||||
|
||||
public ~this()
|
||||
{
|
||||
curl_easy_cleanup(mCURL);
|
||||
}
|
||||
|
||||
Result<void, ReturnCode> WrapResult(ReturnCode returnCode)
|
||||
{
|
||||
if (returnCode == .Ok)
|
||||
return .Ok;
|
||||
return .Err(returnCode);
|
||||
}
|
||||
|
||||
public Result<void, ReturnCode> SetOpt(Option option, bool val)
|
||||
{
|
||||
Debug.Assert((int)option / 10000 == 0);
|
||||
return WrapResult((ReturnCode)curl_easy_setopt(mCURL, (int)option, val ? 1 : 0));
|
||||
}
|
||||
|
||||
public Result<void, ReturnCode> SetOpt(Option option, String val)
|
||||
{
|
||||
Debug.Assert((int)option / 10000 == 1);
|
||||
return WrapResult((ReturnCode)curl_easy_setopt(mCURL, (int)option, (int)(void*)val.CStr()));
|
||||
}
|
||||
|
||||
public Result<void, ReturnCode> SetOpt(Option option, int val)
|
||||
{
|
||||
Debug.Assert(((int)option / 10000 == 0) || ((int)option / 10000 == 3));
|
||||
return WrapResult((ReturnCode)curl_easy_setopt(mCURL, (int)option, val));
|
||||
}
|
||||
|
||||
public Result<void, ReturnCode> SetOpt(Option option, void* val)
|
||||
{
|
||||
Debug.Assert((int)option / 10000 == 1);
|
||||
return WrapResult((ReturnCode)curl_easy_setopt(mCURL, (int)option, (int)val));
|
||||
}
|
||||
|
||||
public Result<void, ReturnCode> SetOptFunc(Option option, void* funcPtr)
|
||||
{
|
||||
Debug.Assert((int)option / 10000 == 2);
|
||||
return WrapResult((ReturnCode)curl_easy_setopt(mCURL, (int)option, (int)funcPtr));
|
||||
}
|
||||
|
||||
public Result<void, ReturnCode> Perform()
|
||||
{
|
||||
return WrapResult((ReturnCode)curl_easy_perform(mCURL));
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
curl_easy_reset(mCURL);
|
||||
}
|
||||
}
|
||||
}
|
621
IDE/src/util/Git.bf
Normal file
621
IDE/src/util/Git.bf
Normal file
|
@ -0,0 +1,621 @@
|
|||
#if true
|
||||
|
||||
using System;
|
||||
|
||||
namespace IDE.Util
|
||||
{
|
||||
typealias git_time_t = int64;
|
||||
typealias git_off_t = int64;
|
||||
|
||||
class Git
|
||||
{
|
||||
|
||||
|
||||
public struct git_repository {}
|
||||
public struct git_index {}
|
||||
public struct git_note {}
|
||||
public struct git_tree {}
|
||||
public struct git_cred {}
|
||||
public struct git_oid {}
|
||||
public struct git_cert {}
|
||||
public struct git_push_update {}
|
||||
public struct git_transport {}
|
||||
public struct git_remote {}
|
||||
|
||||
public function int32 git_transport_certificate_check_cb(git_cert *cert, int32 valid, char8* host, void* payload);
|
||||
public function int32 git_packbuilder_progress(
|
||||
int32 stage,
|
||||
uint32 current,
|
||||
uint32 total,
|
||||
void* payload);
|
||||
public function int32 git_push_transfer_progress(
|
||||
uint32 current,
|
||||
uint32 total,
|
||||
int bytes,
|
||||
void* payload);
|
||||
public function int32 git_push_negotiation(git_push_update** updates, int len, void *payload);
|
||||
public function int32 git_transport_cb(git_transport** outTrans, git_remote *owner, void *param);
|
||||
|
||||
public enum git_fetch_prune_t : int32
|
||||
{
|
||||
/**
|
||||
* Use the setting from the configuration
|
||||
*/
|
||||
GIT_FETCH_PRUNE_UNSPECIFIED,
|
||||
/**
|
||||
* Force pruning on
|
||||
*/
|
||||
GIT_FETCH_PRUNE,
|
||||
/**
|
||||
* Force pruning off
|
||||
*/
|
||||
GIT_FETCH_NO_PRUNE,
|
||||
}
|
||||
|
||||
public enum git_remote_autotag_option_t : int32
|
||||
{
|
||||
/**
|
||||
* Use the setting from the configuration.
|
||||
*/
|
||||
GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED = 0,
|
||||
/**
|
||||
* Ask the server for tags pointing to objects we're already
|
||||
* downloading.
|
||||
*/
|
||||
GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
|
||||
/**
|
||||
* Don't ask for any tags beyond the refspecs.
|
||||
*/
|
||||
GIT_REMOTE_DOWNLOAD_TAGS_NONE,
|
||||
/**
|
||||
* Ask for the all the tags.
|
||||
*/
|
||||
GIT_REMOTE_DOWNLOAD_TAGS_ALL,
|
||||
}
|
||||
|
||||
public enum git_proxy_t : int32
|
||||
{
|
||||
/**
|
||||
* Do not attempt to connect through a proxy
|
||||
*
|
||||
* If built against libcurl, it itself may attempt to connect
|
||||
* to a proxy if the environment variables specify it.
|
||||
*/
|
||||
GIT_PROXY_NONE,
|
||||
/**
|
||||
* Try to auto-detect the proxy from the git configuration.
|
||||
*/
|
||||
GIT_PROXY_AUTO,
|
||||
/**
|
||||
* Connect via the URL given in the options
|
||||
*/
|
||||
GIT_PROXY_SPECIFIED,
|
||||
}
|
||||
|
||||
[CRepr]
|
||||
public struct git_proxy_options
|
||||
{
|
||||
public uint32 version;
|
||||
|
||||
/**
|
||||
* The type of proxy to use, by URL, auto-detect.
|
||||
*/
|
||||
public git_proxy_t type;
|
||||
|
||||
/**
|
||||
* The URL of the proxy.
|
||||
*/
|
||||
public char8* url;
|
||||
|
||||
/**
|
||||
* This will be called if the remote host requires
|
||||
* authentication in order to connect to it.
|
||||
*
|
||||
* Returning GIT_PASSTHROUGH will make libgit2 behave as
|
||||
* though this field isn't set.
|
||||
*/
|
||||
public git_cred_acquire_cb credentials;
|
||||
|
||||
/**
|
||||
* If cert verification fails, this will be called to let the
|
||||
* user make the final decision of whether to allow the
|
||||
* connection to proceed. Returns 1 to allow the connection, 0
|
||||
* to disallow it or a negative value to indicate an error.
|
||||
*/
|
||||
public git_transport_certificate_check_cb certificate_check;
|
||||
|
||||
/**
|
||||
* Payload to be provided to the credentials and certificate
|
||||
* check callbacks.
|
||||
*/
|
||||
public void *payload;
|
||||
}
|
||||
|
||||
public enum git_clone_local_t : int32
|
||||
{
|
||||
/**
|
||||
* Auto-detect (default), libgit2 will bypass the git-aware
|
||||
* transport for local paths, but use a normal fetch for
|
||||
* `file://` urls.
|
||||
*/
|
||||
GIT_CLONE_LOCAL_AUTO,
|
||||
/**
|
||||
* Bypass the git-aware transport even for a `file://` url.
|
||||
*/
|
||||
GIT_CLONE_LOCAL,
|
||||
/**
|
||||
* Do no bypass the git-aware transport
|
||||
*/
|
||||
GIT_CLONE_NO_LOCAL,
|
||||
/**
|
||||
* Bypass the git-aware transport, but do not try to use
|
||||
* hardlinks.
|
||||
*/
|
||||
GIT_CLONE_LOCAL_NO_LINKS,
|
||||
}
|
||||
|
||||
public function int32 git_repository_create_cb(
|
||||
git_repository** outRepo,
|
||||
char8* path,
|
||||
int32 bare,
|
||||
void *payload);
|
||||
|
||||
public function int32 git_remote_create_cb(
|
||||
git_remote** outRemote,
|
||||
git_repository* repo,
|
||||
char8* name,
|
||||
char8* url,
|
||||
void* payload);
|
||||
|
||||
/** Basic type (loose or packed) of any Git object. */
|
||||
public enum git_otype
|
||||
{
|
||||
GIT_OBJ_ANY = -2, /**< Object can be any of the following */
|
||||
GIT_OBJ_BAD = -1, /**< Object is invalid. */
|
||||
GIT_OBJ__EXT1 = 0, /**< Reserved for future use. */
|
||||
GIT_OBJ_COMMIT = 1, /**< A commit object. */
|
||||
GIT_OBJ_TREE = 2, /**< A tree (directory listing) object. */
|
||||
GIT_OBJ_BLOB = 3, /**< A file revision object. */
|
||||
GIT_OBJ_TAG = 4, /**< An annotated tag object. */
|
||||
GIT_OBJ__EXT2 = 5, /**< Reserved for future use. */
|
||||
GIT_OBJ_OFS_DELTA = 6, /**< A delta, base is given by an offset. */
|
||||
GIT_OBJ_REF_DELTA = 7, /**< A delta, base is given by object id. */
|
||||
}
|
||||
|
||||
[CRepr]
|
||||
public struct git_strarray
|
||||
{
|
||||
char8** strings;
|
||||
int count;
|
||||
}
|
||||
|
||||
|
||||
[StdCall, CLink]
|
||||
public static extern void git_strarray_free(git_strarray *array);
|
||||
|
||||
[StdCall, CLink]
|
||||
public static extern int32 git_strarray_copy(git_strarray *tgt, git_strarray *src);
|
||||
|
||||
/** Time in a signature */
|
||||
[CRepr]
|
||||
public struct git_time
|
||||
{
|
||||
git_time_t time; /**< time in seconds from epoch */
|
||||
int32 offset; /**< timezone offset, in minutes */
|
||||
}
|
||||
|
||||
/** An action signature (e.g. for committers, taggers, etc) */
|
||||
[CRepr]
|
||||
public struct git_signature
|
||||
{
|
||||
char8* name; /**< full name of the author */
|
||||
char8* email; /**< email of the author */
|
||||
git_time timeWhen; /**< time when the action happened */
|
||||
}
|
||||
|
||||
/** Basic type of any Git reference. */
|
||||
public enum git_ref_t : int32
|
||||
{
|
||||
GIT_REF_INVALID = 0, /**< Invalid reference */
|
||||
GIT_REF_OID = 1, /**< A reference which points at an object id */
|
||||
GIT_REF_SYMBOLIC = 2, /**< A reference which points at another reference */
|
||||
GIT_REF_LISTALL = GIT_REF_OID|GIT_REF_SYMBOLIC,
|
||||
}
|
||||
|
||||
/** Basic type of any Git branch. */
|
||||
public enum git_branch_t : int32
|
||||
{
|
||||
GIT_BRANCH_LOCAL = 1,
|
||||
GIT_BRANCH_REMOTE = 2,
|
||||
GIT_BRANCH_ALL = GIT_BRANCH_LOCAL|GIT_BRANCH_REMOTE,
|
||||
}
|
||||
|
||||
/** Valid modes for index and tree entries. */
|
||||
public enum git_filemode_t : int32
|
||||
{
|
||||
GIT_FILEMODE_UNREADABLE = 0000000,
|
||||
GIT_FILEMODE_TREE = 0040000,
|
||||
GIT_FILEMODE_BLOB = 0100644,
|
||||
GIT_FILEMODE_BLOB_EXECUTABLE = 0100755,
|
||||
GIT_FILEMODE_LINK = 0120000,
|
||||
GIT_FILEMODE_COMMIT = 0160000,
|
||||
}
|
||||
|
||||
/**
|
||||
* This is passed as the first argument to the callback to allow the
|
||||
* user to see the progress.
|
||||
*
|
||||
* - total_objects: number of objects in the packfile being downloaded
|
||||
* - indexed_objects: received objects that have been hashed
|
||||
* - received_objects: objects which have been downloaded
|
||||
* - local_objects: locally-available objects that have been injected
|
||||
* in order to fix a thin pack.
|
||||
* - received-bytes: size of the packfile received up to now
|
||||
*/
|
||||
[CRepr]
|
||||
public struct git_transfer_progress
|
||||
{
|
||||
public uint32 total_objects;
|
||||
public uint32 indexed_objects;
|
||||
public uint32 received_objects;
|
||||
public uint32 local_objects;
|
||||
public uint32 total_deltas;
|
||||
public uint32 indexed_deltas;
|
||||
public int received_bytes;
|
||||
}
|
||||
|
||||
public enum git_remote_completion_type : int32
|
||||
{
|
||||
GIT_REMOTE_COMPLETION_DOWNLOAD,
|
||||
GIT_REMOTE_COMPLETION_INDEXING,
|
||||
GIT_REMOTE_COMPLETION_ERROR,
|
||||
}
|
||||
|
||||
/**
|
||||
* Type for progress callbacks during indexing. Return a value less than zero
|
||||
* to cancel the transfer.
|
||||
*
|
||||
* @param stats Structure containing information about the state of the transfer
|
||||
* @param payload Payload provided by caller
|
||||
*/
|
||||
public function int32 git_transfer_progress_cb(git_transfer_progress *stats, void* payload);
|
||||
|
||||
/**
|
||||
* Type for messages delivered by the transport. Return a negative value
|
||||
* to cancel the network operation.
|
||||
*
|
||||
* @param str The message from the transport
|
||||
* @param len The length of the message
|
||||
* @param payload Payload provided by the caller
|
||||
*/
|
||||
public function int32 git_transport_message_cb(char8* str, int32 len, void *payload);
|
||||
|
||||
public function int git_cred_acquire_cb(
|
||||
git_cred **cred,
|
||||
char8 *url,
|
||||
char8 *username_from_url,
|
||||
uint32 allowed_types,
|
||||
void *payload);
|
||||
|
||||
public enum git_checkout_notify_t : int32
|
||||
{
|
||||
GIT_CHECKOUT_NOTIFY_NONE = 0,
|
||||
GIT_CHECKOUT_NOTIFY_CONFLICT = (1u << 0),
|
||||
GIT_CHECKOUT_NOTIFY_DIRTY = (1u << 1),
|
||||
GIT_CHECKOUT_NOTIFY_UPDATED = (1u << 2),
|
||||
GIT_CHECKOUT_NOTIFY_UNTRACKED = (1u << 3),
|
||||
GIT_CHECKOUT_NOTIFY_IGNORED = (1u << 4),
|
||||
|
||||
GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFFu
|
||||
}
|
||||
|
||||
[CRepr]
|
||||
public struct git_checkout_perfdata
|
||||
{
|
||||
public int mkdir_calls;
|
||||
public int stat_calls;
|
||||
public int chmod_calls;
|
||||
}
|
||||
|
||||
public struct git_diff_file
|
||||
{
|
||||
/*git_oid id;
|
||||
const char *path;
|
||||
git_off_t size;
|
||||
uint32_t flags;
|
||||
uint16_t mode;
|
||||
uint16_t id_abbrev;*/
|
||||
}
|
||||
|
||||
/** Checkout notification callback function */
|
||||
public function int32 git_checkout_notify_cb(
|
||||
git_checkout_notify_t why,
|
||||
char8* path,
|
||||
git_diff_file* baseline,
|
||||
git_diff_file* target,
|
||||
git_diff_file* workdir,
|
||||
void *payload);
|
||||
|
||||
/** Checkout progress notification function */
|
||||
public function void git_checkout_progress_cb(
|
||||
char8* path,
|
||||
int completed_steps,
|
||||
int total_steps,
|
||||
void *payload);
|
||||
|
||||
/** Checkout perfdata notification function */
|
||||
public function void git_checkout_perfdata_cb(
|
||||
git_checkout_perfdata *perfdata,
|
||||
void *payload);
|
||||
|
||||
[CRepr]
|
||||
public struct git_checkout_options
|
||||
{
|
||||
public uint32 version;
|
||||
|
||||
public uint32 checkout_strategy; /**< default will be a dry run */
|
||||
|
||||
public int32 disable_filters; /**< don't apply filters like CRLF conversion */
|
||||
public uint32 dir_mode; /**< default is 0755 */
|
||||
public uint32 file_mode; /**< default is 0644 or 0755 as dictated by blob */
|
||||
public int32 file_open_flags; /**< default is O_CREAT | O_TRUNC | O_WRONLY */
|
||||
|
||||
public uint32 notify_flags; /**< see `git_checkout_notify_t` above */
|
||||
public git_checkout_notify_cb notify_cb;
|
||||
public void *notify_payload;
|
||||
|
||||
/** Optional callback to notify the consumer of checkout progress. */
|
||||
public git_checkout_progress_cb progress_cb;
|
||||
public void *progress_payload;
|
||||
|
||||
/** When not zeroed out, array of fnmatch patterns specifying which
|
||||
* paths should be taken into account, otherwise all files. Use
|
||||
* GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as simple list.
|
||||
*/
|
||||
public git_strarray paths;
|
||||
|
||||
/** The expected content of the working directory; defaults to HEAD.
|
||||
* If the working directory does not match this baseline information,
|
||||
* that will produce a checkout conflict.
|
||||
*/
|
||||
public git_tree* baseline;
|
||||
|
||||
/** Like `baseline` above, though expressed as an index. This
|
||||
* option overrides `baseline`.
|
||||
*/
|
||||
public git_index* baseline_index; /**< expected content of workdir, expressed as an index. */
|
||||
|
||||
public char8* target_directory; /**< alternative checkout path to workdir */
|
||||
|
||||
public char8* ancestor_label; /**< the name of the common ancestor side of conflicts */
|
||||
public char8* our_label; /**< the name of the "our" side of conflicts */
|
||||
public char8* their_label; /**< the name of the "their" side of conflicts */
|
||||
|
||||
/** Optional callback to notify the consumer of performance data. */
|
||||
public git_checkout_perfdata_cb perfdata_cb;
|
||||
public void *perfdata_payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback settings structure
|
||||
*
|
||||
* Set the callbacks to be called by the remote when informing the user
|
||||
* about the progress of the network operations.
|
||||
*/
|
||||
[CRepr]
|
||||
public struct git_remote_callbacks
|
||||
{
|
||||
public uint32 version;
|
||||
/**
|
||||
* Textual progress from the remote. Text send over the
|
||||
* progress side-band will be passed to this function (this is
|
||||
* the 'counting objects' output).
|
||||
*/
|
||||
public git_transport_message_cb sideband_progress;
|
||||
|
||||
/**
|
||||
* Completion is called when different parts of the download
|
||||
* process are done (currently unused).
|
||||
*/
|
||||
public function int32(git_remote_completion_type type, void *data) completion;
|
||||
|
||||
/**
|
||||
* This will be called if the remote host requires
|
||||
* authentication in order to connect to it.
|
||||
*
|
||||
* Returning GIT_PASSTHROUGH will make libgit2 behave as
|
||||
* though this field isn't set.
|
||||
*/
|
||||
public git_cred_acquire_cb credentials;
|
||||
|
||||
/**
|
||||
* If cert verification fails, this will be called to let the
|
||||
* user make the final decision of whether to allow the
|
||||
* connection to proceed. Returns 1 to allow the connection, 0
|
||||
* to disallow it or a negative value to indicate an error.
|
||||
*/
|
||||
public git_transport_certificate_check_cb certificate_check;
|
||||
|
||||
/**
|
||||
* During the download of new data, this will be regularly
|
||||
* called with the current count of progress done by the
|
||||
* indexer.
|
||||
*/
|
||||
public git_transfer_progress_cb transfer_progress;
|
||||
|
||||
/**
|
||||
* Each time a reference is updated locally, this function
|
||||
* will be called with information about it.
|
||||
*/
|
||||
public function int32 (char8* refname, git_oid *a, git_oid *b, void *data) update_tips;
|
||||
|
||||
/**
|
||||
* Function to call with progress information during pack
|
||||
* building. Be aware that this is called inline with pack
|
||||
* building operations, so performance may be affected.
|
||||
*/
|
||||
public git_packbuilder_progress pack_progress;
|
||||
|
||||
/**
|
||||
* Function to call with progress information during the
|
||||
* upload portion of a push. Be aware that this is called
|
||||
* inline with pack building operations, so performance may be
|
||||
* affected.
|
||||
*/
|
||||
public git_push_transfer_progress push_transfer_progress;
|
||||
|
||||
/**
|
||||
* Called for each updated reference on push. If `status` is
|
||||
* not `NULL`, the update was rejected by the remote server
|
||||
* and `status` contains the reason given.
|
||||
*/
|
||||
public function int32 (char8* refname, char8* status, void *data) push_update_reference;
|
||||
|
||||
/**
|
||||
* Called once between the negotiation step and the upload. It
|
||||
* provides information about what updates will be performed.
|
||||
*/
|
||||
public git_push_negotiation push_negotiation;
|
||||
|
||||
/**
|
||||
* Create the transport to use for this operation. Leave NULL
|
||||
* to auto-detect.
|
||||
*/
|
||||
public git_transport_cb transport;
|
||||
|
||||
/**
|
||||
* This will be passed to each of the callbacks in this struct
|
||||
* as the last parameter.
|
||||
*/
|
||||
public void *payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch options structure.
|
||||
*
|
||||
* Zero out for defaults. Initialize with `GIT_FETCH_OPTIONS_INIT` macro to
|
||||
* correctly set the `version` field. E.g.
|
||||
*
|
||||
* git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
|
||||
*/
|
||||
[CRepr]
|
||||
public struct git_fetch_options
|
||||
{
|
||||
public int32 version;
|
||||
|
||||
/**
|
||||
* Callbacks to use for this fetch operation
|
||||
*/
|
||||
public git_remote_callbacks callbacks;
|
||||
|
||||
/**
|
||||
* Whether to perform a prune after the fetch
|
||||
*/
|
||||
public git_fetch_prune_t prune;
|
||||
|
||||
/**
|
||||
* Whether to write the results to FETCH_HEAD. Defaults to
|
||||
* on. Leave this default in order to behave like git.
|
||||
*/
|
||||
public int32 update_fetchhead;
|
||||
|
||||
/**
|
||||
* Determines how to behave regarding tags on the remote, such
|
||||
* as auto-downloading tags for objects we're downloading or
|
||||
* downloading all of them.
|
||||
*
|
||||
* The default is to auto-follow tags.
|
||||
*/
|
||||
public git_remote_autotag_option_t download_tags;
|
||||
|
||||
/**
|
||||
* Proxy options to use, by default no proxy is used.
|
||||
*/
|
||||
public git_proxy_options proxy_opts;
|
||||
|
||||
/**
|
||||
* Extra headers for this fetch operation
|
||||
*/
|
||||
public git_strarray custom_headers;
|
||||
}
|
||||
|
||||
[CRepr]
|
||||
public struct git_clone_options
|
||||
{
|
||||
public uint32 version;
|
||||
|
||||
/**
|
||||
* These options are passed to the checkout step. To disable
|
||||
* checkout, set the `checkout_strategy` to
|
||||
* `GIT_CHECKOUT_NONE`.
|
||||
*/
|
||||
public git_checkout_options checkout_opts;
|
||||
|
||||
/**
|
||||
* Options which control the fetch, including callbacks.
|
||||
*
|
||||
* The callbacks are used for reporting fetch progress, and for acquiring
|
||||
* credentials in the event they are needed.
|
||||
*/
|
||||
public git_fetch_options fetch_opts;
|
||||
|
||||
/**
|
||||
* Set to zero (false) to create a standard repo, or non-zero
|
||||
* for a bare repo
|
||||
*/
|
||||
public int32 bare;
|
||||
|
||||
/**
|
||||
* Whether to use a fetch or copy the object database.
|
||||
*/
|
||||
public git_clone_local_t local;
|
||||
|
||||
/**
|
||||
* The name of the branch to checkout. NULL means use the
|
||||
* remote's default branch.
|
||||
*/
|
||||
public char8* checkout_branch;
|
||||
|
||||
/**
|
||||
* A callback used to create the new repository into which to
|
||||
* clone. If NULL, the 'bare' field will be used to determine
|
||||
* whether to create a bare repository.
|
||||
*/
|
||||
public git_repository_create_cb repository_cb;
|
||||
|
||||
/**
|
||||
* An opaque payload to pass to the git_repository creation callback.
|
||||
* This parameter is ignored unless repository_cb is non-NULL.
|
||||
*/
|
||||
public void* repository_cb_payload;
|
||||
|
||||
/**
|
||||
* A callback used to create the git_remote, prior to its being
|
||||
* used to perform the clone operation. See the documentation for
|
||||
* git_remote_create_cb for details. This parameter may be NULL,
|
||||
* indicating that git_clone should provide default behavior.
|
||||
*/
|
||||
public git_remote_create_cb remote_cb;
|
||||
|
||||
/**
|
||||
* An opaque payload to pass to the git_remote creation callback.
|
||||
* This parameter is ignored unless remote_cb is non-NULL.
|
||||
*/
|
||||
public void* remote_cb_payload;
|
||||
}
|
||||
|
||||
[CLink, StdCall]
|
||||
public static extern int32 git_libgit2_init();
|
||||
|
||||
[CLink, StdCall]
|
||||
public static extern int32 git_libgit2_shutdown();
|
||||
|
||||
[CLink, StdCall]
|
||||
public static extern int32 git_clone(git_repository** repoOut, char8* url, char8* local_path, git_clone_options* options);
|
||||
|
||||
[CLink, StdCall]
|
||||
public static extern void git_repository_free(git_repository *repo);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
186
IDE/src/util/GlobalUndoManager.bf
Normal file
186
IDE/src/util/GlobalUndoManager.bf
Normal file
|
@ -0,0 +1,186 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Beefy.utils;
|
||||
|
||||
namespace IDE.Util
|
||||
{
|
||||
public class GlobalUndoAction : UndoAction
|
||||
{
|
||||
public GlobalUndoData mUndoData;
|
||||
public bool mPerforming;
|
||||
public FileEditData mFileEditData;
|
||||
|
||||
public this(FileEditData fileEditData, GlobalUndoData undoData)
|
||||
{
|
||||
mFileEditData = fileEditData;
|
||||
mUndoData = undoData;
|
||||
}
|
||||
|
||||
public ~this()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
public void Detach()
|
||||
{
|
||||
if (mUndoData == null)
|
||||
return;
|
||||
if (mUndoData.mFileEditDatas.Count == 0)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
mUndoData.mFileEditDatas.Remove(mFileEditData);
|
||||
}
|
||||
mUndoData = null;
|
||||
mFileEditData = null;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
mUndoData.mFileEditDatas.Remove(mFileEditData);
|
||||
if (mUndoData.mFileEditDatas.Count == 0)
|
||||
{
|
||||
mUndoData.mDeleted = true;
|
||||
IDEApp.sApp.mGlobalUndoManager.mDeletingGlobalUndoList.Add(mUndoData);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Undo()
|
||||
{
|
||||
Debug.Assert(!mUndoData.mDeleted);
|
||||
if (mUndoData.mDeleted)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
mUndoData.mUndoCount++;
|
||||
if (mUndoData.mPerforming)
|
||||
return true;
|
||||
|
||||
mUndoData.mPerforming = true;
|
||||
for (var editData in mUndoData.mFileEditDatas)
|
||||
{
|
||||
if (editData == mFileEditData)
|
||||
continue;
|
||||
|
||||
var editWidgetContent = editData.mEditWidget.Content;
|
||||
while (true)
|
||||
{
|
||||
int32 prevUndoCount = mUndoData.mUndoCount;
|
||||
bool success = editWidgetContent.mData.mUndoManager.Undo();
|
||||
Debug.Assert(success);
|
||||
if (mUndoData.mUndoCount != prevUndoCount)
|
||||
break;
|
||||
}
|
||||
|
||||
if (IDEApp.IsBeefFile(editData.mFilePath))
|
||||
{
|
||||
for (var projectSource in editData.mProjectSources)
|
||||
{
|
||||
projectSource.HasChangedSinceLastCompile = true;
|
||||
IDEApp.sApp.mBfResolveCompiler.QueueProjectSource(projectSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
mUndoData.mPerforming = false;
|
||||
IDEApp.sApp.mBfResolveCompiler.QueueDeferredResolveAll();
|
||||
|
||||
return base.Undo();
|
||||
}
|
||||
|
||||
public override bool Redo()
|
||||
{
|
||||
if (mUndoData.mDeleted)
|
||||
{
|
||||
// Someone has already overwritten this location in the redo buffer
|
||||
// so this is no longer valid
|
||||
return false;
|
||||
}
|
||||
|
||||
mUndoData.mRedoCount++;
|
||||
if (mUndoData.mPerforming)
|
||||
return true;
|
||||
|
||||
mUndoData.mPerforming = true;
|
||||
for (var editData in mUndoData.mFileEditDatas)
|
||||
{
|
||||
if (editData == mFileEditData)
|
||||
continue;
|
||||
|
||||
var editWidgetContent = editData.mEditWidget.Content;
|
||||
while (true)
|
||||
{
|
||||
int32 prevRedoCount = mUndoData.mRedoCount;
|
||||
bool success = editWidgetContent.mData.mUndoManager.Redo();
|
||||
Debug.Assert(success);
|
||||
if (mUndoData.mRedoCount != prevRedoCount)
|
||||
break;
|
||||
}
|
||||
|
||||
if (IDEApp.IsBeefFile(editData.mFilePath))
|
||||
{
|
||||
for (var projectSource in editData.mProjectSources)
|
||||
{
|
||||
projectSource.HasChangedSinceLastCompile = true;
|
||||
IDEApp.sApp.mBfResolveCompiler.QueueProjectSource(projectSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
mUndoData.mPerforming = false;
|
||||
IDEApp.sApp.mBfResolveCompiler.QueueDeferredResolveAll();
|
||||
|
||||
return base.Redo();
|
||||
}
|
||||
}
|
||||
|
||||
public class GlobalUndoData
|
||||
{
|
||||
public bool mPerforming;
|
||||
public bool mDeleted;
|
||||
public int32 mUndoCount;
|
||||
public int32 mRedoCount;
|
||||
public HashSet<FileEditData> mFileEditDatas = new HashSet<FileEditData>() ~ delete _;
|
||||
|
||||
public ~this()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class GlobalUndoManager
|
||||
{
|
||||
public List<GlobalUndoData> mGlobalUndoDataList = new List<GlobalUndoData>() ~ delete _;
|
||||
public List<GlobalUndoData> mDeletingGlobalUndoList = new List<GlobalUndoData>() ~ DeleteContainerAndItems!(_);
|
||||
|
||||
public ~this()
|
||||
{
|
||||
}
|
||||
|
||||
public GlobalUndoData CreateUndoData()
|
||||
{
|
||||
var globalUndoData = new GlobalUndoData();
|
||||
mGlobalUndoDataList.Add(globalUndoData);
|
||||
return globalUndoData;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
/*foreach (var globalUndoData in mDeletingGlobalUndoList)
|
||||
{
|
||||
mGlobalUndoDataList.Remove(globalUndoData);
|
||||
}
|
||||
mDeletingGlobalUndoList.Clear();*/
|
||||
ClearAndDeleteItems(mDeletingGlobalUndoList);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
mGlobalUndoDataList.Clear();
|
||||
ClearAndDeleteItems(mDeletingGlobalUndoList);
|
||||
}
|
||||
}
|
||||
}
|
114
IDE/src/util/RecentFiles.bf
Normal file
114
IDE/src/util/RecentFiles.bf
Normal file
|
@ -0,0 +1,114 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Beefy.sys;
|
||||
|
||||
namespace IDE.util
|
||||
{
|
||||
class RecentFiles
|
||||
{
|
||||
public enum RecentKind
|
||||
{
|
||||
OpenedWorkspace,
|
||||
OpenedProject,
|
||||
OpenedFile,
|
||||
OpenedCrashDump,
|
||||
OpenedDebugSession,
|
||||
|
||||
COUNT
|
||||
}
|
||||
|
||||
public class Entry
|
||||
{
|
||||
public List<String> mList = new List<String>() ~ DeleteContainerAndItems!(_);
|
||||
public SysMenu mMenu;
|
||||
public List<SysMenu> mMenuItems = new List<SysMenu>() ~ delete _;
|
||||
}
|
||||
|
||||
public List<Entry> mRecents = new .() ~ DeleteContainerAndItems!(_);
|
||||
|
||||
public this()
|
||||
{
|
||||
for (RecentFiles.RecentKind recentKind = default; recentKind < RecentFiles.RecentKind.COUNT; recentKind++)
|
||||
{
|
||||
mRecents.Add(new Entry());
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> GetRecentList(RecentKind recentKind)
|
||||
{
|
||||
return mRecents[(int)recentKind].mList;
|
||||
}
|
||||
|
||||
public static void UpdateMenu(List<String> items, SysMenu menu, List<SysMenu> menuItems, delegate void(int idx, SysMenu sysMenu) onNewEntry)
|
||||
{
|
||||
int32 i;
|
||||
for (i = 0; i < items.Count; i++)
|
||||
{
|
||||
String title = scope String();
|
||||
if (i + 1 == 10)
|
||||
title.AppendF("1&0 {1}", i + 1, items[i]);
|
||||
else
|
||||
title.AppendF("&{0} {1}", i + 1, items[i]);
|
||||
if (i < menuItems.Count)
|
||||
{
|
||||
menuItems[i].Modify(title);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((menuItems.IsEmpty) && (menu.mChildren != null) && (!menu.mChildren.IsEmpty))
|
||||
menu.AddMenuItem(null, null);
|
||||
|
||||
int32 idx = i;
|
||||
|
||||
let newMenuItem = menu.AddMenuItem(title);
|
||||
menuItems.Add(newMenuItem);
|
||||
if (onNewEntry != null)
|
||||
onNewEntry(idx, newMenuItem);
|
||||
//menuItems.Add(menu.AddMenuItem(title, null, new (evt) => openEntry(idx)));
|
||||
}
|
||||
}
|
||||
|
||||
while (i < menuItems.Count)
|
||||
{
|
||||
menuItems[i].Dispose();
|
||||
menuItems.RemoveAt(i);
|
||||
}
|
||||
|
||||
if (menu.ChildCount == 0)
|
||||
{
|
||||
let newMenuItem = menu.AddMenuItem("< None >", null, null, null, null, false);
|
||||
menuItems.Add(newMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Add(List<String> list, StringView path, int32 maxCount = 10)
|
||||
{
|
||||
int32 idx = -1;
|
||||
for (int32 i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (Path.Equals(list[i], path))
|
||||
idx = i;
|
||||
}
|
||||
|
||||
if (idx != -1)
|
||||
{
|
||||
String entry = list[idx];
|
||||
list.RemoveAt(idx);
|
||||
list.Insert(0, entry);
|
||||
}
|
||||
else
|
||||
list.Insert(0, new String(path));
|
||||
|
||||
while (list.Count > maxCount)
|
||||
{
|
||||
delete list.PopBack();
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(RecentKind recentKind, StringView path)
|
||||
{
|
||||
Add(mRecents[(int32)recentKind].mList, path);
|
||||
}
|
||||
}
|
||||
}
|
357
IDE/src/util/ResourceGen.bf
Normal file
357
IDE/src/util/ResourceGen.bf
Normal file
|
@ -0,0 +1,357 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
namespace IDE.util
|
||||
{
|
||||
class ResourceGen
|
||||
{
|
||||
[CRepr]
|
||||
struct IconDir
|
||||
{
|
||||
public uint16 mReserved;
|
||||
public uint16 mType;
|
||||
public uint16 mCount;
|
||||
}
|
||||
|
||||
[CRepr]
|
||||
struct IconDirectoryEntry
|
||||
{
|
||||
public uint8 mWidth;
|
||||
public uint8 mHeight;
|
||||
public uint8 mColorCount;
|
||||
public uint8 mReserved;
|
||||
public uint16 mPlanes;
|
||||
public uint16 mBitCount;
|
||||
public uint32 mBytesInRes;
|
||||
public uint32 mImageOffset;
|
||||
}
|
||||
|
||||
[CRepr]
|
||||
struct ResourceHeader
|
||||
{
|
||||
public uint32 mDataSize;
|
||||
public uint32 mHeaderSize;
|
||||
public uint32 mType;
|
||||
public uint32 mName;
|
||||
public uint32 mDataVersion;
|
||||
public uint16 mMemoryFlags;
|
||||
public uint16 mLanguageId;
|
||||
public uint32 mVersion;
|
||||
public uint32 mCharacteristics;
|
||||
}
|
||||
|
||||
[CRepr]
|
||||
struct VsFixedFileInfo
|
||||
{
|
||||
public uint32 mSignature;
|
||||
public uint32 mStrucVersion;
|
||||
public uint32 mFileVersionMS;
|
||||
public uint32 mFileVersionLS;
|
||||
public uint32 mProductVersionMS;
|
||||
public uint32 mProductVersionLS;
|
||||
public uint32 mFileFlagsMask;
|
||||
public uint32 mFileFlags;
|
||||
public uint32 mFileOS;
|
||||
public uint32 mFileType;
|
||||
public uint32 mFileSubtype;
|
||||
public uint32 mFileDateMS;
|
||||
public uint32 mFileDateLS;
|
||||
};
|
||||
|
||||
FileStream mOutStream = new FileStream() ~ delete _;
|
||||
|
||||
public Result<void> AddIcon(String iconFile)
|
||||
{
|
||||
if (!iconFile.EndsWith(".ico", .OrdinalIgnoreCase))
|
||||
{
|
||||
gApp.OutputErrorLine("Invalid icon file: {0}. Expected '.ico' file.", iconFile);
|
||||
return .Err;
|
||||
}
|
||||
|
||||
FileStream stream = scope FileStream();
|
||||
if (stream.Open(iconFile, .Read) case .Err)
|
||||
{
|
||||
gApp.OutputErrorLine("Failed to open icon file: {0}", iconFile);
|
||||
return .Err;
|
||||
}
|
||||
|
||||
let iconDir = Try!(stream.Read<IconDir>());
|
||||
|
||||
if ((iconDir.mReserved != 0) || (iconDir.mType != 1) || (iconDir.mCount > 0x100))
|
||||
{
|
||||
gApp.OutputErrorLine("Invalid file format: {0}", iconFile);
|
||||
return .Err;
|
||||
}
|
||||
|
||||
var entries = scope List<IconDirectoryEntry>();
|
||||
|
||||
for (int idx < iconDir.mCount)
|
||||
{
|
||||
entries.Add(Try!(stream.Read<IconDirectoryEntry>()));
|
||||
}
|
||||
|
||||
for (int idx < iconDir.mCount)
|
||||
{
|
||||
let iconEntry = ref entries[idx];
|
||||
|
||||
Try!(stream.Seek(iconEntry.mImageOffset));
|
||||
|
||||
uint8* data = new:ScopedAlloc! uint8[iconEntry.mBytesInRes]*;
|
||||
|
||||
Try!(stream.TryRead(.(data, iconEntry.mBytesInRes)));
|
||||
|
||||
ResourceHeader res;
|
||||
res.mDataSize = iconEntry.mBytesInRes;
|
||||
res.mHeaderSize = 32;
|
||||
res.mType = 0xFFFF | (3 << 16);
|
||||
res.mName = 0xFFFF | ((uint32)(idx + 1) << 16);
|
||||
res.mDataVersion = 0;
|
||||
res.mMemoryFlags = 0x1010;
|
||||
res.mLanguageId = 1033;
|
||||
res.mVersion = 0;
|
||||
res.mCharacteristics = 0;
|
||||
Try!(mOutStream.Write(res));
|
||||
Try!(mOutStream.TryWrite(Span<uint8>(data, iconEntry.mBytesInRes)));
|
||||
mOutStream.Align(4);
|
||||
}
|
||||
|
||||
ResourceHeader res;
|
||||
res.mDataSize = 6 + 14 * iconDir.mCount;
|
||||
res.mHeaderSize = 32;
|
||||
res.mType = 0xFFFF | (14 << 16);
|
||||
res.mName = 0xFFFF | (101 << 16);
|
||||
res.mDataVersion = 0;
|
||||
res.mMemoryFlags = 0x1030;
|
||||
res.mLanguageId = 1033;
|
||||
res.mVersion = 0;
|
||||
res.mCharacteristics = 0;
|
||||
Try!(mOutStream.Write(res));
|
||||
|
||||
Try!(mOutStream.Write(iconDir));
|
||||
|
||||
for (int idx < iconDir.mCount)
|
||||
{
|
||||
var iconEntry = ref entries[idx];
|
||||
|
||||
// Write entry without mImageOffset
|
||||
Try!(mOutStream.TryWrite(Span<uint8>((uint8*)&iconEntry, 12)));
|
||||
Try!(mOutStream.Write((int16)idx + 1));
|
||||
}
|
||||
|
||||
mOutStream.Align(4);
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public Result<void> Start(String resFileName)
|
||||
{
|
||||
if (mOutStream.Create(resFileName) case .Err)
|
||||
{
|
||||
return .Err;
|
||||
}
|
||||
|
||||
ResourceHeader res;
|
||||
res.mDataSize = 0;
|
||||
res.mHeaderSize = 32;
|
||||
res.mType = 0xFFFF;
|
||||
res.mName = 0xFFFF;
|
||||
res.mDataVersion = 0;
|
||||
res.mMemoryFlags = 0;
|
||||
res.mLanguageId = 0;
|
||||
res.mVersion = 0;
|
||||
res.mCharacteristics = 0;
|
||||
Try!(mOutStream.Write(res));
|
||||
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public Result<void> AddVersion(String description, String comments, String company, String product, String copyright, String fileVersion, String productVersion, String originalFileName)
|
||||
{
|
||||
MemoryStream strStream = scope MemoryStream();
|
||||
|
||||
void AddString(String key, String value)
|
||||
{
|
||||
if (value.IsEmpty)
|
||||
return;
|
||||
|
||||
let key16 = scope EncodedString(key, Encoding.UTF16);
|
||||
let value16 = scope EncodedString(value, Encoding.UTF16);
|
||||
|
||||
int keyPadding = ((key16.Size / 2) & 1) + 1;
|
||||
int valuePadding = 2 - ((value16.Size / 2) & 1);
|
||||
|
||||
if (value16.Size != 0)
|
||||
{
|
||||
strStream.Write((uint16)(key16.Size + keyPadding*2 + value16.Size + 8)); //wLength
|
||||
strStream.Write((uint16)(value16.Size / 2) + 1); //wValueLength
|
||||
}
|
||||
else
|
||||
{
|
||||
strStream.Write((uint16)(key16.Size + keyPadding*2 + value16.Size + 6)); //wLength
|
||||
valuePadding = 0;
|
||||
strStream.Write((uint16)0); //wValueLength
|
||||
}
|
||||
|
||||
strStream.Write((uint16)1); //wType
|
||||
|
||||
strStream.TryWrite(.(key16.Ptr, key16.Size));
|
||||
for (int pad < keyPadding)
|
||||
strStream.Write((char16)0);
|
||||
strStream.TryWrite(.(value16.Ptr, value16.Size));
|
||||
for (int pad < valuePadding)
|
||||
strStream.Write((char16)0);
|
||||
}
|
||||
|
||||
void WriteStr16(Stream stream, String str, int length)
|
||||
{
|
||||
for (var c in str.RawChars)
|
||||
stream.Write((char16)c);
|
||||
for (int i = str.Length; i < length; i++)
|
||||
stream.Write((char16)0);
|
||||
}
|
||||
|
||||
let ext = scope String();
|
||||
Path.GetExtension(originalFileName, ext);
|
||||
|
||||
let internalName = scope String();
|
||||
Path.GetFileNameWithoutExtension(originalFileName, internalName);
|
||||
|
||||
AddString("CompanyName", company);
|
||||
AddString("FileDescription", description);
|
||||
AddString("Comments", comments);
|
||||
AddString("FileVersion", fileVersion);
|
||||
AddString("InternalName", internalName);
|
||||
AddString("LegalCopyright", copyright);
|
||||
AddString("OriginalFilename", originalFileName);
|
||||
AddString("ProductName", product);
|
||||
AddString("ProductVersion", productVersion);
|
||||
|
||||
int verSectionCount = 0;
|
||||
uint64 version = 0;
|
||||
for (let verSection in fileVersion.Split('.'))
|
||||
{
|
||||
int32 verSect = 0;
|
||||
bool endNow = false;
|
||||
switch (int32.Parse(verSection))
|
||||
{
|
||||
case .Ok(out verSect):
|
||||
case .Err(.InvalidChar(out verSect)):
|
||||
endNow = true;
|
||||
default:
|
||||
}
|
||||
|
||||
version <<= 16;
|
||||
version |= (uint64)verSect;
|
||||
if (++verSectionCount == 4)
|
||||
break;
|
||||
if (endNow)
|
||||
break;
|
||||
}
|
||||
|
||||
if (verSectionCount < 4)
|
||||
version <<= (int)(16 * (4 - verSectionCount));
|
||||
|
||||
int strTableSize = strStream.Length;
|
||||
|
||||
ResourceHeader res;
|
||||
res.mDataSize = (uint32)strTableSize + 0xDC;
|
||||
res.mHeaderSize = 32;
|
||||
res.mType = 0xFFFF | (16 << 16);
|
||||
res.mName = 0xFFFF | (1 << 16);
|
||||
res.mDataVersion = 0;
|
||||
res.mMemoryFlags = 0x30;
|
||||
res.mLanguageId = 1033;
|
||||
res.mVersion = 0;
|
||||
res.mCharacteristics = 0;
|
||||
Try!(mOutStream.Write(res));
|
||||
|
||||
Try!(mOutStream.Write((uint16)(strTableSize + 0xDC)));
|
||||
Try!(mOutStream.Write((uint16)0x34));
|
||||
Try!(mOutStream.Write((uint16)0)); // wType = binary
|
||||
|
||||
WriteStr16(mOutStream, "VS_VERSION_INFO", 17);
|
||||
|
||||
VsFixedFileInfo ffi;
|
||||
ffi.mSignature = 0xFEEF04BD;
|
||||
ffi.mStrucVersion = 0x10000;
|
||||
ffi.mFileVersionMS = (uint32)(version >> 32);
|
||||
ffi.mFileVersionLS = (uint32)(version);
|
||||
ffi.mProductVersionMS = (uint32)(version >> 32);
|
||||
ffi.mProductVersionLS = (uint32)(version);
|
||||
ffi.mFileFlagsMask = 0x3F;
|
||||
ffi.mFileFlags = 0;
|
||||
ffi.mFileOS = 0x40004;
|
||||
if (ext.Equals(".DLL", .OrdinalIgnoreCase))
|
||||
ffi.mFileType = 2; //DLL
|
||||
else
|
||||
ffi.mFileType = 1; //APP
|
||||
ffi.mFileSubtype = 0;
|
||||
ffi.mFileDateMS = 0;
|
||||
ffi.mFileDateLS = 0;
|
||||
Try!(mOutStream.Write(ffi));
|
||||
|
||||
// StringFileInfo
|
||||
Try!(mOutStream.Write((uint16)(strTableSize + 0x3A)));
|
||||
Try!(mOutStream.Write((uint16)0)); // wValueLength
|
||||
Try!(mOutStream.Write((uint16)1)); // wType
|
||||
WriteStr16(mOutStream, "StringFileInfo", 15);
|
||||
|
||||
// StringTable
|
||||
Try!(mOutStream.Write((uint16)(strTableSize + 0x16))); // wLength
|
||||
Try!(mOutStream.Write((uint16)0)); // mValueLength
|
||||
Try!(mOutStream.Write((uint16)1)); // mType
|
||||
WriteStr16(mOutStream, "040904b0", 9); // szKey
|
||||
strStream.Position = 0;
|
||||
strStream.CopyTo(mOutStream);
|
||||
|
||||
// StringTable
|
||||
mOutStream.Write((uint16)0x44);
|
||||
mOutStream.Write((uint16)0x0);
|
||||
mOutStream.Write((uint16)0x1);
|
||||
WriteStr16(mOutStream, "VarFileInfo", 13);
|
||||
|
||||
mOutStream.Write((uint16)0x24);
|
||||
mOutStream.Write((uint16)0x4);
|
||||
mOutStream.Write((uint16)0x0);
|
||||
WriteStr16(mOutStream, "Translation", 13);
|
||||
mOutStream.Write((uint32)0x04B00409);
|
||||
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public Result<void> AddManifest(String manifestPath)
|
||||
{
|
||||
String manifestText = scope String();
|
||||
if (File.ReadAllText(manifestPath, manifestText) case .Err)
|
||||
{
|
||||
gApp.OutputLine("Failed to open manifest file: {0}", manifestPath);
|
||||
return .Err;
|
||||
}
|
||||
|
||||
ResourceHeader res;
|
||||
res.mDataSize = (uint32)manifestText.Length + 3;
|
||||
res.mHeaderSize = 32;
|
||||
res.mType = 0xFFFF | (0x18 << 16);
|
||||
res.mName = 0xFFFF | (2 << 16);
|
||||
res.mDataVersion = 0;
|
||||
res.mMemoryFlags = 0x1030;
|
||||
res.mLanguageId = 1033;
|
||||
res.mVersion = 0;
|
||||
res.mCharacteristics = 0;
|
||||
Try!(mOutStream.Write(res));
|
||||
|
||||
Try!(mOutStream.Write(uint8[3] (0xEF, 0xBB, 0xBF))); // UTF8 BOM
|
||||
if (manifestText.Length > 0)
|
||||
Try!(mOutStream.TryWrite(Span<uint8>((uint8*)manifestText.Ptr, manifestText.Length)));
|
||||
|
||||
mOutStream.Align(4);
|
||||
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public Result<void> Finish()
|
||||
{
|
||||
return .Ok;
|
||||
}
|
||||
}
|
||||
}
|
15
IDE/src/util/SemVer.bf
Normal file
15
IDE/src/util/SemVer.bf
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace IDE.Util
|
||||
{
|
||||
class SemVer
|
||||
{
|
||||
public String mVersion ~ delete _;
|
||||
|
||||
public Result<void> Parse(StringView ver)
|
||||
{
|
||||
mVersion = new String(ver);
|
||||
return .Ok;
|
||||
}
|
||||
}
|
||||
}
|
85
IDE/src/util/SettingHistoryManager.bf
Normal file
85
IDE/src/util/SettingHistoryManager.bf
Normal file
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IDE.util
|
||||
{
|
||||
class SettingHistoryManager
|
||||
{
|
||||
public List<PropertyBag> mHistory = new .() ~ DeleteContainerAndItems!(_);
|
||||
public int mHistoryIdx;
|
||||
public PropertyBag mEmptyEnd ~ delete _;
|
||||
|
||||
public this(bool endOnEmpty)
|
||||
{
|
||||
if (endOnEmpty)
|
||||
mEmptyEnd = new PropertyBag();
|
||||
}
|
||||
|
||||
public bool HasPrev()
|
||||
{
|
||||
if ((mHistoryIdx == 0) || (mHistory == null))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public PropertyBag GetPrev()
|
||||
{
|
||||
if ((mHistoryIdx == 0) || (mHistory == null))
|
||||
return null;
|
||||
return mHistory[--mHistoryIdx];
|
||||
}
|
||||
|
||||
public bool HasNext()
|
||||
{
|
||||
if (mHistoryIdx >= mHistory.Count - 1)
|
||||
{
|
||||
if (mEmptyEnd != null)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public PropertyBag GetNext()
|
||||
{
|
||||
if ((mHistoryIdx >= mHistory.Count - 1) && (mEmptyEnd != null))
|
||||
{
|
||||
if (mHistoryIdx == mHistory.Count - 1)
|
||||
mHistoryIdx++;
|
||||
return mEmptyEnd;
|
||||
}
|
||||
|
||||
if (mHistoryIdx >= mHistory.Count - 1)
|
||||
return null;
|
||||
return mHistory[++mHistoryIdx];
|
||||
}
|
||||
|
||||
public void Add(PropertyBag propertyBag)
|
||||
{
|
||||
while (mHistoryIdx < mHistory.Count - 1)
|
||||
{
|
||||
var prevEntry = mHistory.Back;
|
||||
mHistory.PopBack();
|
||||
delete prevEntry;
|
||||
}
|
||||
|
||||
if (!mHistory.IsEmpty)
|
||||
{
|
||||
// Ignore duplicate
|
||||
if (propertyBag == mHistory.Back)
|
||||
{
|
||||
delete propertyBag;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mHistory.Add(propertyBag);
|
||||
mHistoryIdx++;
|
||||
}
|
||||
|
||||
public void ToEnd()
|
||||
{
|
||||
mHistoryIdx = mHistory.Count;
|
||||
}
|
||||
}
|
||||
}
|
193
IDE/src/util/Transfer.bf
Normal file
193
IDE/src/util/Transfer.bf
Normal file
|
@ -0,0 +1,193 @@
|
|||
using IDE;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IDE.Util
|
||||
{
|
||||
class Transfer
|
||||
{
|
||||
CURL.Easy mCurl = new CURL.Easy() ~ delete _;
|
||||
bool mCancelling = false;
|
||||
List<uint8> mData = new List<uint8>() ~ delete _;
|
||||
Stopwatch mStatsTimer = new Stopwatch() ~ delete _;
|
||||
WaitEvent mDoneEvent ~ delete _;
|
||||
Result<Span<uint8>> mResult;
|
||||
|
||||
int mTotalBytes = -1;
|
||||
int mBytesReceived = 0;
|
||||
|
||||
int mLastBytesPerSecond = -1;
|
||||
int mBytesAtLastPeriod = 0;
|
||||
bool mRunning;
|
||||
|
||||
public int BytesPerSecond
|
||||
{
|
||||
get
|
||||
{
|
||||
UpdateBytesPerSecond();
|
||||
if (mLastBytesPerSecond != -1)
|
||||
return mLastBytesPerSecond;
|
||||
return GetCurBytesPerSecond();
|
||||
}
|
||||
}
|
||||
|
||||
public int TotalBytes
|
||||
{
|
||||
get
|
||||
{
|
||||
return mTotalBytes;
|
||||
}
|
||||
}
|
||||
|
||||
public int BytesReceived
|
||||
{
|
||||
get
|
||||
{
|
||||
return mBytesReceived;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRunning
|
||||
{
|
||||
get
|
||||
{
|
||||
return mRunning;
|
||||
}
|
||||
}
|
||||
|
||||
public this()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ~this()
|
||||
{
|
||||
mCancelling = true;
|
||||
if (mRunning)
|
||||
mDoneEvent.WaitFor();
|
||||
}
|
||||
|
||||
int GetCurBytesPerSecond()
|
||||
{
|
||||
int elapsedTime = mStatsTimer.ElapsedMilliseconds;
|
||||
if (elapsedTime == 0)
|
||||
return 0;
|
||||
|
||||
return (int)((int64)(mBytesReceived - mBytesAtLastPeriod) * 1000 / elapsedTime);
|
||||
}
|
||||
|
||||
void UpdateBytesPerSecond()
|
||||
{
|
||||
if (mStatsTimer.ElapsedMilliseconds >= 500)
|
||||
{
|
||||
mLastBytesPerSecond = GetCurBytesPerSecond();
|
||||
mBytesAtLastPeriod = mBytesReceived;
|
||||
mStatsTimer.Restart();
|
||||
}
|
||||
}
|
||||
|
||||
void Update(int dltotal, int dlnow)
|
||||
{
|
||||
if (dltotal > mTotalBytes)
|
||||
mTotalBytes = dltotal;
|
||||
mBytesReceived = dlnow;
|
||||
UpdateBytesPerSecond();
|
||||
}
|
||||
|
||||
[StdCall]
|
||||
static int Callback(void *p, int dltotal, int dlnow, int ultotal, int ulnow)
|
||||
{
|
||||
Transfer transfer = (Transfer)Internal.UnsafeCastToObject(p);
|
||||
if (transfer.mCancelling)
|
||||
return 1;
|
||||
|
||||
transfer.Update(dltotal, dlnow);
|
||||
|
||||
//Debug.WriteLine("{0} of {1}", dlnow, dltotal);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
[StdCall]
|
||||
static int Write(void* dataPtr, int size, int count, void* ctx)
|
||||
{
|
||||
Transfer transfer = (Transfer)Internal.UnsafeCastToObject(ctx);
|
||||
int byteCount = size * count;
|
||||
if (byteCount > 0)
|
||||
{
|
||||
Internal.MemCpy(transfer.mData.GrowUnitialized(byteCount), dataPtr, byteCount);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public void Setup(String url)
|
||||
{
|
||||
function int(void *p, int dltotal, int dlnow, int ultotal, int ulnow) callback = => Callback;
|
||||
mCurl.SetOptFunc(.XferInfoFunction, (void*)callback);
|
||||
mCurl.SetOpt(.XferInfoData, Internal.UnsafeCastToPtr(this));
|
||||
|
||||
function int(void* ptr, int size, int count, void* ctx) writeFunc = => Write;
|
||||
mCurl.SetOptFunc(.WriteFunction, (void*)writeFunc);
|
||||
mCurl.SetOpt(.WriteData, Internal.UnsafeCastToPtr(this));
|
||||
|
||||
mCurl.SetOpt(.FollowLocation, true);
|
||||
mCurl.SetOpt(.URL, url);
|
||||
mCurl.SetOpt(.NoProgress, false);
|
||||
}
|
||||
|
||||
public Result<Span<uint8>> Perform()
|
||||
{
|
||||
//mCurl.SetOpt(.Verbose, true);
|
||||
//mCurl.SetOpt(.X)
|
||||
mStatsTimer.Start();
|
||||
var result = mCurl.Perform();
|
||||
mStatsTimer.Stop();
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case .Err:
|
||||
return .Err;
|
||||
default:
|
||||
if (mData.Count > 0)
|
||||
return .Ok(.(&mData[0], mData.Count));
|
||||
else
|
||||
return .Ok(.());
|
||||
}
|
||||
}
|
||||
|
||||
void DoBackground()
|
||||
{
|
||||
mResult = Perform();
|
||||
mRunning = false;
|
||||
mDoneEvent.Set(true);
|
||||
}
|
||||
|
||||
public Result<void> PerformBackground()
|
||||
{
|
||||
// This is a one-use object
|
||||
if (mDoneEvent != null)
|
||||
return .Err;
|
||||
mDoneEvent = new WaitEvent();
|
||||
mRunning = true;
|
||||
ThreadPool.QueueUserWorkItem(new => DoBackground);
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public Result<Span<uint8>> GetResult()
|
||||
{
|
||||
if (mDoneEvent != null)
|
||||
mDoneEvent.WaitFor();
|
||||
return mResult;
|
||||
}
|
||||
|
||||
public void Cancel(bool wait = false)
|
||||
{
|
||||
mCancelling = true;
|
||||
if ((wait) && (mRunning))
|
||||
mDoneEvent.WaitFor();
|
||||
}
|
||||
}
|
||||
}
|
124
IDE/src/util/VerSpec.bf
Normal file
124
IDE/src/util/VerSpec.bf
Normal file
|
@ -0,0 +1,124 @@
|
|||
using System;
|
||||
using Beefy.utils;
|
||||
using IDE;
|
||||
using Beefy;
|
||||
|
||||
namespace IDE.Util
|
||||
{
|
||||
enum VerSpec
|
||||
{
|
||||
case SemVer(SemVer ver);
|
||||
case Path(String path);
|
||||
case Git(String url);
|
||||
}
|
||||
|
||||
class VerSpecRecord
|
||||
{
|
||||
public VerSpec mVerSpec;
|
||||
public Object mVerObject;
|
||||
|
||||
public ~this()
|
||||
{
|
||||
/*switch (mVerSpec)
|
||||
{
|
||||
case .SemVer(let ver): delete ver;
|
||||
case .Path(let path): delete path;
|
||||
case .Git(let url): delete url;
|
||||
}*/
|
||||
delete mVerObject;
|
||||
}
|
||||
|
||||
public void SetPath(StringView path)
|
||||
{
|
||||
delete mVerObject;
|
||||
String pathStr = new String(path);
|
||||
mVerObject = pathStr;
|
||||
|
||||
mVerSpec = .Path(pathStr);
|
||||
}
|
||||
|
||||
public void SetSemVer(StringView ver)
|
||||
{
|
||||
delete mVerObject;
|
||||
String pathStr = new String(ver);
|
||||
|
||||
SemVer semVer = new SemVer();
|
||||
semVer.mVersion = pathStr;
|
||||
mVerObject = semVer;
|
||||
|
||||
mVerSpec = .SemVer(semVer);
|
||||
}
|
||||
|
||||
public Result<void> Parse(StructuredData data)
|
||||
{
|
||||
if (data.IsObject)
|
||||
{
|
||||
for (var valName in data.Enumerate())
|
||||
{
|
||||
if (valName == "Path")
|
||||
{
|
||||
var pathStr = new String();
|
||||
data.GetCurString(pathStr);
|
||||
mVerObject = pathStr;
|
||||
mVerSpec = .Path(pathStr);
|
||||
}
|
||||
else if (valName == "Git")
|
||||
{
|
||||
var pathStr = new String();
|
||||
data.GetCurString(pathStr);
|
||||
mVerObject = pathStr;
|
||||
mVerSpec = .Git(pathStr);
|
||||
}
|
||||
else if (valName == "Ver")
|
||||
{
|
||||
var pathStr = new String();
|
||||
data.GetCurString(pathStr);
|
||||
|
||||
SemVer semVer = new SemVer();
|
||||
mVerObject = semVer;
|
||||
|
||||
semVer.mVersion = pathStr;
|
||||
mVerSpec = .SemVer(semVer);
|
||||
}
|
||||
else
|
||||
{
|
||||
//gApp.Fail("Invalid ver path");
|
||||
return .Err;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
let verString = scope String();
|
||||
data.GetCurString(verString);
|
||||
let semVer = new SemVer();
|
||||
mVerSpec = .SemVer(semVer);
|
||||
|
||||
mVerObject = semVer;
|
||||
|
||||
Try!(semVer.Parse(verString));
|
||||
}
|
||||
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public void Serialize(String name, StructuredData data)
|
||||
{
|
||||
switch (mVerSpec)
|
||||
{
|
||||
case .Git(var path):
|
||||
using (data.CreateObject(name))
|
||||
{
|
||||
data.Add("Git", path);
|
||||
}
|
||||
case .SemVer(var ver):
|
||||
data.Add(name, ver.mVersion);
|
||||
case .Path(var path):
|
||||
using (data.CreateObject(name))
|
||||
{
|
||||
data.Add("Path", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
4616
IDE/src/util/Zip.bf
Normal file
4616
IDE/src/util/Zip.bf
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue