Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <string>
  3. #include <curl/curl.h>
  4.  
  5. using namespace std;
  6.  
  7. static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
  8. {
  9. ((std::string*)userp)->append((char*)contents, size * nmemb);
  10. return size * nmemb;
  11. }
  12.  
  13. int main(){
  14. CURL *curl;
  15. CURLcode res;
  16. std::string readBuffer;
  17. std::string password = "123456789";
  18. curl = curl_easy_init();
  19. if(curl) {
  20. curl_easy_setopt(curl, CURLOPT_URL, "");
  21. curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
  22. curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
  23. curl_easy_setopt(curl, CURLOPT_POST, 1);
  24. curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "pass="+password);
  25. res = curl_easy_perform(curl);
  26. curl_easy_cleanup(curl);
  27.  
  28. // std::cout << readBuffer << std::en;dl;
  29.  
  30. system("stty -F /dev/serial0 19200");
  31. echo(readBuffer);
  32. }
  33. else{
  34. return 200;
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement