This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
C socket server example, handles multiple clients using threads | |
Compile | |
gcc server.c -lpthread -o server | |
*/ | |
#include<stdio.h> | |
#include<string.h> //strlen | |
#include<stdlib.h> //strlen | |
#include<sys/socket.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdarg> | |
#include <string> | |
#include <fstream> | |
#include <memory> | |
#include <cstdio> | |
std::string exec(const char* cmd) { | |
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose); | |
if (!pipe) return "ERROR"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2007 Timo Bingmann <tb@panthema.net> | |
// Distributed under the Boost Software License, Version 1.0. | |
// (See http://www.boost.org/LICENSE_1_0.txt) | |
// | |
// Original link http://panthema.net/2007/0328-ZLibString.html | |
#include <string> | |
#include <stdexcept> | |
#include <iostream> | |
#include <iomanip> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# compile | |
g++ zlib.cpp -o zz -lz | |
# run | |
root@localhost:~# ./zz | |
Orignal string size: 43 | |
Original string: halloweeks halloweeks halloweeks halloweeks | |
-------------------- | |
Compressed string size: 22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdlib.h> | |
#include <string> | |
std::string url_decode(char *url) { | |
std::string temp, output; | |
char ch; | |
for (unsigned int index = 0; index < strlen(url)+1; index++) { | |
if (url[index] == '%') { | |
temp += url[index+1]; |