tdlight/td/telegram/td_json_client.cpp
levlam 5cbda834bd Update copyright year.
GitOrigin-RevId: 1369d3af1195221f6ddb9462d5f8b74fb5fef20f
2018-01-02 16:45:09 +03:00

46 lines
1.2 KiB
C++

//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/telegram/td_json_client.h"
#include "td/telegram/ClientJson.h"
#include "td/utils/Slice.h"
extern "C" int td_json_client_square(int x, const char *str) {
return x * x;
}
void *td_json_client_create() {
return new td::ClientJson();
}
void td_json_client_destroy(void *client) {
delete static_cast<td::ClientJson *>(client);
}
void td_json_client_send(void *client, const char *request) {
static_cast<td::ClientJson *>(client)->send(td::Slice(request));
}
const char *td_json_client_receive(void *client, double timeout) {
auto slice = static_cast<td::ClientJson *>(client)->receive(timeout);
if (slice.empty()) {
return nullptr;
} else {
return slice.c_str();
}
}
const char *td_json_client_execute(void *client, const char *request) {
auto slice = static_cast<td::ClientJson *>(client)->execute(td::Slice(request));
if (slice.empty()) {
return nullptr;
} else {
return slice.c_str();
}
}