003 File Manager
Current Path:
/usr/local/share/examples/curl
usr
/
local
/
share
/
examples
/
curl
/
📁
..
📄
10-at-a-time.c
(4.24 KB)
📄
Makefile.example
(1.86 KB)
📄
README.md
(1.35 KB)
📄
altsvc.c
(1.83 KB)
📄
anyauthput.c
(4.82 KB)
📄
cacertinmem.c
(7.14 KB)
📄
certinfo.c
(2.25 KB)
📄
chkspeed.c
(6.54 KB)
📄
cookie_interface.c
(4.03 KB)
📄
crawler.c
(6.53 KB)
📄
curlgtk.c
(2.94 KB)
📄
curlx.c
(16.41 KB)
📄
debug.c
(4.21 KB)
📄
ephiperfifo.c
(14.49 KB)
📄
evhiperfifo.c
(11.9 KB)
📄
externalsocket.c
(4.83 KB)
📄
fileupload.c
(2.78 KB)
📄
fopen.c
(13.87 KB)
📄
ftp-wildcard.c
(4.15 KB)
📄
ftpget.c
(2.59 KB)
📄
ftpgetinfo.c
(2.86 KB)
📄
ftpgetresp.c
(2.51 KB)
📄
ftpsget.c
(2.89 KB)
📄
ftpupload.c
(4.48 KB)
📄
ftpuploadfrommem.c
(3.81 KB)
📄
ftpuploadresume.c
(4.24 KB)
📄
getinfo.c
(1.62 KB)
📄
getinmemory.c
(3.24 KB)
📄
getredirect.c
(2.3 KB)
📄
getreferrer.c
(1.81 KB)
📄
ghiper.c
(12.04 KB)
📄
hiperfifo.c
(11.97 KB)
📄
href_extractor.c
(2.61 KB)
📄
htmltidy.c
(3.88 KB)
📄
htmltitle.cpp
(6.23 KB)
📄
http-post.c
(1.99 KB)
📄
http2-download.c
(6.19 KB)
📄
http2-pushinmemory.c
(5.02 KB)
📄
http2-serverpush.c
(7.1 KB)
📄
http2-upload.c
(8.05 KB)
📄
http3-present.c
(1.53 KB)
📄
http3.c
(1.81 KB)
📄
httpcustomheader.c
(2.27 KB)
📄
httpput-postfields.c
(3.36 KB)
📄
httpput.c
(3.6 KB)
📄
https.c
(2.53 KB)
📄
imap-append.c
(3.77 KB)
📄
imap-authzid.c
(2.21 KB)
📄
imap-copy.c
(2.35 KB)
📄
imap-create.c
(2.06 KB)
📄
imap-delete.c
(2.06 KB)
📄
imap-examine.c
(2.11 KB)
📄
imap-fetch.c
(1.95 KB)
📄
imap-list.c
(2.08 KB)
📄
imap-lsub.c
(2.08 KB)
📄
imap-multi.c
(2.29 KB)
📄
imap-noop.c
(2 KB)
📄
imap-search.c
(2.35 KB)
📄
imap-ssl.c
(3.25 KB)
📄
imap-store.c
(2.69 KB)
📄
imap-tls.c
(3.5 KB)
📄
makefile.dj
(1.58 KB)
📄
multi-app.c
(3.36 KB)
📄
multi-debugcallback.c
(4.21 KB)
📄
multi-double.c
(2.62 KB)
📄
multi-event.c
(6.01 KB)
📄
multi-formadd.c
(3.23 KB)
📄
multi-legacy.c
(5.13 KB)
📄
multi-post.c
(3.04 KB)
📄
multi-single.c
(2.49 KB)
📄
multi-uv.c
(5.97 KB)
📄
multithread.c
(2.59 KB)
📄
opensslthreadlock.c
(2.69 KB)
📄
parseurl.c
(2.13 KB)
📄
persistent.c
(2.15 KB)
📄
pop3-authzid.c
(2.18 KB)
📄
pop3-dele.c
(2.15 KB)
📄
pop3-list.c
(1.93 KB)
📄
pop3-multi.c
(2.29 KB)
📄
pop3-noop.c
(2.11 KB)
📄
pop3-retr.c
(1.93 KB)
📄
pop3-ssl.c
(3.22 KB)
📄
pop3-stat.c
(2.13 KB)
📄
pop3-tls.c
(3.47 KB)
📄
pop3-top.c
(2.09 KB)
📄
pop3-uidl.c
(2.03 KB)
📄
post-callback.c
(5.15 KB)
📄
postinmemory.c
(3.36 KB)
📄
postit2-formadd.c
(3.51 KB)
📄
postit2.c
(3.41 KB)
📄
progressfunc.c
(4.8 KB)
📄
resolve.c
(1.92 KB)
📄
rtsp.c
(9.02 KB)
📄
sampleconv.c
(3.25 KB)
📄
sendrecv.c
(4.52 KB)
📄
sepheaders.c
(2.67 KB)
📄
sessioninfo.c
(3.06 KB)
📄
sftpget.c
(3.25 KB)
📄
sftpuploadresume.c
(3.82 KB)
📄
shared-connection-cache.c
(2.51 KB)
📄
simple.c
(1.68 KB)
📄
simplepost.c
(1.83 KB)
📄
simplessl.c
(4.56 KB)
📄
smooth-gtk-thread.c
(6.01 KB)
📄
smtp-authzid.c
(5.33 KB)
📄
smtp-expn.c
(2.55 KB)
📄
smtp-mail.c
(4.86 KB)
📄
smtp-mime.c
(5.47 KB)
📄
smtp-multi.c
(4.54 KB)
📄
smtp-ssl.c
(5.75 KB)
📄
smtp-tls.c
(6.21 KB)
📄
smtp-vrfy.c
(2.62 KB)
📄
sslbackend.c
(2.29 KB)
📄
synctime.c
(12.6 KB)
📄
threaded-ssl.c
(4.34 KB)
📄
url2file.c
(2.43 KB)
📄
urlapi.c
(1.98 KB)
📄
usercertinmem.c
(8.87 KB)
📄
xmlstream.c
(4.94 KB)
Editing: threaded-ssl.c
/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ***************************************************************************/ /* <DESC> * Show the required mutex callback setups for GnuTLS and OpenSSL when using * libcurl multi-threaded. * </DESC> */ /* A multi-threaded example that uses pthreads and fetches 4 remote files at * once over HTTPS. The lock callbacks and stuff assume OpenSSL <1.1 or GnuTLS * (libgcrypt) so far. * * OpenSSL docs for this: * https://www.openssl.org/docs/man1.0.2/man3/CRYPTO_num_locks.html * gcrypt docs for this: * https://gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html */ #define USE_OPENSSL /* or USE_GNUTLS accordingly */ #include <stdio.h> #include <pthread.h> #include <curl/curl.h> #define NUMT 4 /* we have this global to let the callback get easy access to it */ static pthread_mutex_t *lockarray; #ifdef USE_OPENSSL #include <openssl/crypto.h> static void lock_callback(int mode, int type, char *file, int line) { (void)file; (void)line; if(mode & CRYPTO_LOCK) { pthread_mutex_lock(&(lockarray[type])); } else { pthread_mutex_unlock(&(lockarray[type])); } } static unsigned long thread_id(void) { unsigned long ret; ret = (unsigned long)pthread_self(); return ret; } static void init_locks(void) { int i; lockarray = (pthread_mutex_t *)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); for(i = 0; i<CRYPTO_num_locks(); i++) { pthread_mutex_init(&(lockarray[i]), NULL); } CRYPTO_set_id_callback((unsigned long (*)())thread_id); CRYPTO_set_locking_callback((void (*)())lock_callback); } static void kill_locks(void) { int i; CRYPTO_set_locking_callback(NULL); for(i = 0; i<CRYPTO_num_locks(); i++) pthread_mutex_destroy(&(lockarray[i])); OPENSSL_free(lockarray); } #endif #ifdef USE_GNUTLS #include <gcrypt.h> #include <errno.h> GCRY_THREAD_OPTION_PTHREAD_IMPL; void init_locks(void) { gcry_control(GCRYCTL_SET_THREAD_CBS); } #define kill_locks() #endif /* List of URLs to fetch.*/ const char * const urls[]= { "https://www.example.com/", "https://www2.example.com/", "https://www3.example.com/", "https://www4.example.com/", }; static void *pull_one_url(void *url) { CURL *curl; curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, url); /* this example doesn't verify the server's certificate, which means we might be downloading stuff from an impostor */ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_perform(curl); /* ignores error */ curl_easy_cleanup(curl); return NULL; } int main(int argc, char **argv) { pthread_t tid[NUMT]; int i; (void)argc; /* we don't use any arguments in this example */ (void)argv; /* Must initialize libcurl before any threads are started */ curl_global_init(CURL_GLOBAL_ALL); init_locks(); for(i = 0; i< NUMT; i++) { int error = pthread_create(&tid[i], NULL, /* default attributes please */ pull_one_url, (void *)urls[i]); if(0 != error) fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); else fprintf(stderr, "Thread %d, gets %s\n", i, urls[i]); } /* now wait for all threads to terminate */ for(i = 0; i< NUMT; i++) { pthread_join(tid[i], NULL); fprintf(stderr, "Thread %d terminated\n", i); } kill_locks(); return 0; }
Upload File
Create Folder