#include <boost/beast.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>
namespace http = boost::beast::http;
int main() {
const std::string host = "scooterlabs.com";
const std::string target = "/echo?input=test";
// I/O контекст, необходимый для всех I/O операций
boost::asio::io_context ioc;
// Resolver для определения endpoint'ов
boost::asio::ip::tcp::resolver resolver(ioc);
// Tcp сокет, использующейся для соединения
boost::asio::ip::tcp::socket socket(ioc);
// Резолвим адрес и устанавливаем соединение
boost::asio::connect(socket, resolver.resolve(host, "80"));
// Дальше необходимо создать HTTP GET реквест с указанием таргета
http::request<http::string_body> req(http::verb::get, target, 11);
// Задаём поля HTTP заголовка
req.set(http::field::host, host);
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
// Отправляем реквест через приконекченный сокет
http::write(socket, req);
// Часть, отвечающая за чтение респонса
{
boost::beast::flat_buffer buffer;
http::response<http::dynamic_body> res;
http::read(socket, buffer, res);
std::cout << res << std::endl;
}
// Закрываем соединение
socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
return 0;
}
g++ -lboost_system -pthread main.cpp
void writeEnum(st::Stream& st, int value, const char* names[]) {}
enum class Letter { A, B, C, …, Z, NN };
const char* natoNames[static_cast<int>(Letter::NN)] = { "alpha", "bravo", "charlie", … };
writeEnum(someStream, static_cast<int>(Letter::E), natoName);
void trim(const char*& beg, const char*& end);
struct ParasiteString { const char *beg, *end; };
wchar_t* myFtos(double value, wchar_t* buf, const FloatFormat& format) {}
wchar_t buf[100];
myFtos(100.500, buf, FloatFormat::NICE);
free(current);
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#define TSIZE 45
struct film
{
char title[TSIZE];
int rating;
struct film * next;
};
char * s_gets(char * str, int n);
int main(int argc, char * argv[])
{
struct film * head = NULL;
struct film * prev, *current;
char input[TSIZE];
puts("Input first name of movie: ");
while (s_gets(input, TSIZE) != NULL && input[0] != '\0')
{
current = (struct film *) malloc(sizeof(struct film));
if (head == NULL)
head = current;
else
prev->next = current;
current->next = NULL;
strcpy(current->title, input);
puts("Input your rating: ");
scanf("%d", ¤t->rating);
while (getchar() != '\n')
continue;
puts("Input the next name of movie: ");
prev = current;
}
if (head == NULL)
printf("Data not found");
else
printf("List of movies:\n");
current = head;
while (current != NULL)
{
printf("Movie: %s, rating: %d\n", current->title, current->rating);
current = current->next;
}
current = head;
while (current != NULL)
{
auto next = current->next;
free(current);
current = next;
}
printf("The programm is completed.\n");
_getch();
return 0;
}
char * s_gets(char * str, int n)
{
char * value;
char * find;
value = fgets(str, n, stdin);
if (value)
{
find = strchr(str, '\n');
if (find)
*find = '\0';
else
while (getchar() != '\n')
continue;
}
return value;
}
create anynodes hash:net family inet hashsize 1024 maxelem 65536
add anynodes 192.168.1.0/24
add anynodes 192.168.10.0/24
add anynodes 192.168.15.0/24
add anynodes 192.168.16.0/24
*filter
:INPUT DROP [0:0]
-A INPUT -p tcp --dport 22 -m set --match-set anynodes src -j ACCEPT
-A OUTPUT -p tcp --sport 22 -m set --match-set anynodes dst -j ACCEPT