Files @ d73a30892ea0
Branch filter:

Location: DistRen/src/client/libdistren.h - annotation

binki
merge
9d601d5c27c7
abcf8952747b
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
d95bffb2291b
d95bffb2291b
d95bffb2291b
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
2c0ae3006fa0
9d601d5c27c7
d1ba36f30e32
da79b5082151
da79b5082151
d1ba36f30e32
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
9d601d5c27c7
9d601d5c27c7
da79b5082151
17bf31a10aa6
d1ba36f30e32
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
7c0e60f07a51
da79b5082151
d1ba36f30e32
7c0e60f07a51
e0b7e9dd5b54
e0b7e9dd5b54
e0b7e9dd5b54
e0b7e9dd5b54
e0b7e9dd5b54
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
9d601d5c27c7
da79b5082151
9d601d5c27c7
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
5f565fa058ef
52937ad805ae
52937ad805ae
d1ba36f30e32
d1ba36f30e32
d1ba36f30e32
d1ba36f30e32
d1ba36f30e32
52937ad805ae
52937ad805ae
e736dd843da3
e736dd843da3
d1ba36f30e32
d1ba36f30e32
d1ba36f30e32
e736dd843da3
e736dd843da3
d95bffb2291b
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
da79b5082151
d95bffb2291b
d95bffb2291b
/*
  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;

  /*
   * The last-used per-connection DISTREN_REQUEST_FILE_POST
   * identifier.
   */
  uint32_t file_post_id;
};

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