Files
@ f6e991030a70
Branch filter:
Location: DistRen/src/common/request.c - annotation
f6e991030a70
2.4 KiB
text/plain
tabletennis_del_client() actually deletes the client if it's not at the front of one of the PING or PONG queues (fixing a segfault).
eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 92659c5651ef 92659c5651ef eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 27eb6c6418f6 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 eb391af42d62 27eb6c6418f6 eb391af42d62 | /*
* Copyright 2010 Nathan Phillip Brink
*
* This file is a part of DistRen.
*
* DistRen is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DistRen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with DistRen. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/config.h"
#include "common/protocol.h"
#include <stdlib.h>
#include <string.h>
int distren_request_free_with_data(struct distren_request *req, void *data)
{
free(data);
return distren_request_free(req);
}
int distren_request_version(struct distren_request **req, void **data, uint32_t servertype, const char *package_string)
{
struct distren_request_version *version;
distren_request_new(req, sizeof(struct distren_request_version), DISTREN_REQUEST_VERSION);
version = malloc(sizeof(struct distren_request_version));
if(!version || !*req)
{
free(version);
if(*req)
distren_request_free(*req);
return 1;
}
memset(version, 0, sizeof(struct distren_request_version));
version->servertype = servertype;
strncpy(version->package_string, package_string, DISTREN_REQUEST_VERSION_PACKAGE_STRING_LEN);
*data = version;
return 0;
}
int distren_request_parse_version(struct distren_request *req, void *data, struct distren_request_version *version)
{
if(req->len < sizeof(struct distren_request_version))
return 1;
memcpy(version, data, sizeof(struct distren_request_version));
/* there is space for another '\0' */
version->package_string[DISTREN_REQUEST_VERSION_PACKAGE_STRING_LEN] = '\0';
return 0;
}
int distren_request_poing(struct distren_request **req, void **data, short is_ping, const void *poing_cookie, size_t poing_data_len)
{
enum distren_request_type type;
if(is_ping)
type = DISTREN_REQUEST_PING;
else
type = DISTREN_REQUEST_PONG;
distren_request_new(req, poing_data_len, type);
(*data) = malloc(poing_data_len);
memcpy(*data, poing_cookie, poing_data_len);
return 0;
}
|