#include <curl/curl.h>
#include <stdio.h>
-size_t writefunction( void *ptr, size_t size, size_t nmemb, void *stream)
+size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream)
{
fwrite(ptr, size, nmemb, stream);
return (nmemb*size);
goto err;
}
- if(!(p12bio = BIO_new_file(p.p12file , "rb"))) {
+ if(!(p12bio = BIO_new_file(p.p12file, "rb"))) {
BIO_printf(p.errorbio, "Error opening P12 file %s\n", p.p12file);
goto err;
}
{
int lu; int i=0;
- while((lu = BIO_read (in, &binaryptr[i], tabLength-i)) >0 ) {
+ while((lu = BIO_read (in, &binaryptr[i], tabLength-i)) >0) {
i+=lu;
if(i== tabLength) {
tabLength+=100;
/* Create a new easy handle, and add it to the global curl_multi */
-static void new_conn(char *url, GlobalInfo *g )
+static void new_conn(char *url, GlobalInfo *g)
{
ConnInfo *conn;
CURLMcode rc;
curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
/* Create the socket "manually" */
- if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == CURL_SOCKET_BAD ) {
+ if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == CURL_SOCKET_BAD) {
printf("Error creating listening socket.\n");
return 3;
}
if(!fdp) {
MSG_OUT("Adding data: %s%s\n",
what&CURL_POLL_IN?"READ":"",
- what&CURL_POLL_OUT?"WRITE":"" );
+ what&CURL_POLL_OUT?"WRITE":"");
addsock(s, e, what, g);
}
else {
}
/* Create a new easy handle, and add it to the global curl_multi */
-static void new_conn(char *url, GlobalInfo *g )
+static void new_conn(char *url, GlobalInfo *g)
{
ConnInfo *conn;
CURLMcode rc;
mcode_or_die("event_cb: curl_multi_socket_action", rc);
check_multi_info(g);
- if(g->still_running <= 0 ) {
+ if(g->still_running <= 0) {
fprintf(MSG_OUT, "last transfer done, kill timeout\n");
if(evtimer_pending(g->timer_event, NULL)) {
evtimer_del(g->timer_event);
/* Create a new easy handle, and add it to the global curl_multi */
-static void new_conn(char *url, GlobalInfo *g )
+static void new_conn(char *url, GlobalInfo *g)
{
ConnInfo *conn;
CURLMcode rc;
s[0]='\0';
rv=fscanf(g->input, "%1023s%n", s, &n);
s[n]='\0';
- if(n && s[0] ) {
+ if(n && s[0]) {
new_conn(s, arg); /* if we read a URL, go get it! */
}
else
{
uint r;
r = size * nmemb;
- tidyBufAppend( out, in, r );
+ tidyBufAppend(out, in, r);
return r;
}
/* Traverse the document tree */
-void dumpNode(TidyDoc doc, TidyNode tnod, int indent )
+void dumpNode(TidyDoc doc, TidyNode tnod, int indent)
{
TidyNode child;
for(child = tidyGetChild(tnod); child; child = tidyGetNext(child) ) {
- ctmbstr name = tidyNodeGetName( child );
+ ctmbstr name = tidyNodeGetName(child);
if(name) {
/* if it has a name, then it's an HTML tag ... */
TidyAttr attr;
- printf( "%*.*s%s ", indent, indent, "<", name);
+ printf("%*.*s%s ", indent, indent, "<", name);
/* walk the attribute list */
for(attr=tidyAttrFirst(child); attr; attr=tidyAttrNext(attr) ) {
printf(tidyAttrName(attr));
tidyAttrValue(attr)?printf("=\"%s\" ",
tidyAttrValue(attr)):printf(" ");
}
- printf( ">\n");
+ printf(">\n");
}
else {
/* if it doesn't have a name, then it's probably text, cdata, etc... */
printf("%*.*s\n", indent, indent, buf.bp?(char *)buf.bp:"");
tidyBufFree(&buf);
}
- dumpNode( doc, child, indent + 4 ); /* recursive */
+ dumpNode(doc, child, indent + 4); /* recursive */
}
}
-int main(int argc, char **argv )
+int main(int argc, char **argv)
{
CURL *curl;
char curl_errbuf[CURL_ERROR_SIZE];
tdoc = tidyCreate();
tidyOptSetBool(tdoc, TidyForceOutput, yes); /* try harder */
tidyOptSetInt(tdoc, TidyWrapLen, 4096);
- tidySetErrorBuffer( tdoc, &tidy_errbuf );
+ tidySetErrorBuffer(tdoc, &tidy_errbuf);
tidyBufInit(&docbuf);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &docbuf);
if(err >= 0) {
err = tidyRunDiagnostics(tdoc); /* load tidy error buffer */
if(err >= 0) {
- dumpNode( tdoc, tidyGetRoot(tdoc), 0 ); /* walk the tree */
+ dumpNode(tdoc, tidyGetRoot(tdoc), 0); /* walk the tree */
fprintf(stderr, "%s\n", tidy_errbuf.bp); /* show errors */
}
}
}
else
- printf( "usage: %s <url>\n", argv[0] );
+ printf("usage: %s <url>\n", argv[0]);
return 0;
}
headp = curl_pushheader_byname(headers, ":path");
if(headp) {
- fprintf(stderr, "**** The PATH is %s\n", headp /* skip :path + colon */ );
+ fprintf(stderr, "**** The PATH is %s\n", headp /* skip :path + colon */);
}
(*transfers)++; /* one more */
#define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x))
#define MUTEX_LOCK(x) pthread_mutex_lock(&(x))
#define MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x))
-#define THREAD_ID pthread_self( )
+#define THREAD_ID pthread_self()
void handle_error(const char *file, int lineno, const char *msg)
{
int i;
- mutex_buf = malloc(CRYPTO_num_locks( ) * sizeof(MUTEX_TYPE));
+ mutex_buf = malloc(CRYPTO_num_locks() * sizeof(MUTEX_TYPE));
if(!mutex_buf)
return 0;
- for(i = 0; i < CRYPTO_num_locks( ); i++)
+ for(i = 0; i < CRYPTO_num_locks(); i++)
MUTEX_SETUP(mutex_buf[i]);
CRYPTO_set_id_callback(id_function);
CRYPTO_set_locking_callback(locking_function);
return 0;
CRYPTO_set_id_callback(NULL);
CRYPTO_set_locking_callback(NULL);
- for(i = 0; i < CRYPTO_num_locks( ); i++)
+ for(i = 0; i < CRYPTO_num_locks(); i++)
MUTEX_CLEANUP(mutex_buf[i]);
free(mutex_buf);
mutex_buf = NULL;
{
struct termios oldt, newt;
int ch;
- tcgetattr( STDIN_FILENO, &oldt );
+ tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
- newt.c_lflag &= ~( ICANON | ECHO );
- tcsetattr( STDIN_FILENO, TCSANOW, &newt );
+ newt.c_lflag &= ~( ICANON | ECHO);
+ tcsetattr(STDIN_FILENO, TCSANOW, &newt);
ch = getchar();
- tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
+ tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
#endif
g_strdup_printf("xoap.weather.com/weather/local/%s?cc=*&dayf=5&unit=i\n",
urls[j]);
- printf( "http %s", http );
+ printf("http %s", http);
curl = curl_easy_init();
if(curl) {
static const char *pagefilename = "page.out";
FILE *pagefile;
- if(argc < 2 ) {
+ if(argc < 2) {
printf("Usage: %s <URL>\n", argv[0]);
return 1;
}