Files
@ f6e991030a70
Branch filter:
Location: DistRen/src/client/libdistren.h
f6e991030a70
3.0 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).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | /*
Copyright 2010 Nathan Phillip Brink, Ethan Zonca, Matt Orlando
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/>.
*/
#ifndef LIBDISTREN_H_
#define LIBDISTREN_H_ 1
/*
Private definitions for libdistren.
*/
#include "distren.h"
#include "common/multiio.h"
#include "common/options.h"
#include "common/remoteio.h"
#include <stdint.h>
enum distren_state
{
/**
* client is waiting for a VERSION packet from the server.
*/
DISTREN_STATE_VERSION,
/**
* We are waiting to be authenticated.
*/
DISTREN_STATE_AUTH,
DISTREN_STATE_NORMAL,
DISTREN_STATE_UPLOADING,
};
struct distren
{
struct options_common *options;
char *server;
enum distren_state state;
/*
* If rem is NULL, we're not connected to the server. This is the
* way to detect a communication error.
*/
struct remoteio *rem;
/*
* for libdistren_remoteio_read_handle(): determine whether or not
* we've passed through the server's hacky MOTD
*/
short done_ad;
/*
* The servertype bitmask of the remote server.
*/
uint32_t servertype;
/* something on which to call multiio_poll() ;-) */
multiio_context_t multiio;
};
struct distren_job
{
char *joburi;
};
/*
functions
*/
/**
Avoid poluting the public namespace until we fix visibility.
*/
#define _malloc _distren_malloc
/**
All of libdistren should use this rather than malloc.h's malloc.
*/
void *_malloc(distren_t distren, size_t size);
/**
Avoid poluting the public namespace until we fix visibility.
*/
#define _free _distren_free
/**
All of libdisren should use this instead of malloc.h's free()
*/
void _free(distren_t distren, void *tofree);
/**
* Sets up the distren handle with information garnered from
* configuration files, etc. Uses the environment variable
* DISTREN_CONFIG or the built-in default config file location.
*
* Also initializes multiio.
*/
int _distren_getoptions(distren_t handle);
/**
* Unsets-up the distren handle with options loadable from a config file.
*
* Also unloads multiio.
*/
int _distren_loseoptions(distren_t handle);
/**
* Handle newly read data.
*
* Matches remoteio_read_handle_func_t
*/
size_t libdistren_remoteio_read_handle(struct remoteio *rem, void *garbage, void *buf, size_t len, distren_t distren);
/**
* React to a remoteio-based connection closing.
*
* Matches remoteio_close_handle_func_t
*/
void libdistren_remoteio_close_handle(void *garbage, distren_t distren);
#endif
|