Recently developed a WiFi camera with HiSilicon hi3518e, now use HTTP to implement information push function, such as in the device when the alarm video will push a message "there is an abnormal intrusion." "And a snapshot of the image to the server, and then when the customer's mobile phone online, will be pushed information." Downloaded the Curl Open Source Library on the net, can implement HTTP function with C.
I. Compilation of Curl Library
Curl's download address is http://curl.haxx.se/download.html, detailed compilation steps refer to http://curl.haxx.se/docs/install.html. Here is a brief description of my compilation steps:
>tar Xvzf curl-7.37.0.tar.gz
>CD curl-7.37.0
>./configure--host=arm-none-linux--prefix=/home/hank/http/hisi_http CC=ARM-HISIV100NPTL-LINUX-GCC-- disable-shared--enable-static--without-libidn--without-ssl--without-librtmp--without-gnutls-- Without-libssh2--without-zlib--without-winidn--disable-rtsp--disable-ldap--disable-ldaps
>make
>make Install
Where the CC specifies the compiler,--prefix=/home/hank/http/hisi_http specifies the repository path for make install, which is compiled into a static library, removing some of the functionality.
Second, the use of Curl Library
The following examples refer to the http://blog.csdn.net/sxwyf248/article/details/7984776
Simulate the HTML to be implemented in the C program: [HTML] View plain copy
The C program code is:
[cpp] View plain copy #include <stdio.h> #include <string.h > #include <curl.h> int main (int argc, char *argv[]) { curl *curl; CURLcode res; struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=null; struct curl_slist * headerlist=null; static const char buf[] = "Expect : "; curl_global_init (curl_global_all); /* fill in the file upload field */ curl_formadd (&formpost, &lastptr,