/*
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 .
*/
/*
Implementation of distren_* functions from distren.h excluding distren_job_* functions.
*/
#include "common/config.h"
#include "common/options.h"
#include "common/remoteio.h"
#include "libdistren.h"
#include
#include
#include
int distren_init(distren_t *handle)
{
int tmp;
if(!handle)
return 1;
*handle = malloc(sizeof(struct distren));
if(!*handle)
return 1;
memset(*handle, 0, sizeof(struct distren));
/* now the environment is ready for general use */
if(_distren_getoptions(*handle))
{
fprintf(stderr, "error getting configuration\n");
distren_free(*handle);
return 1;
}
tmp = remoteio_open_server(&(*handle)->rem,
(*handle)->options->remoteio,
(remoteio_read_handle_func_t)&libdistren_remoteio_read_handle,
*handle,
(remoteio_close_handle_func_t)&libdistren_remoteio_close_handle,
(*handle)->server);
if(tmp)
{
fprintf(stderr, "error: unable to connect to server\n");
(*handle)->rem = NULL;
distren_free(*handle);
return 1;
}
multiio_poll((*handle)->multiio, 2000);
multiio_poll((*handle)->multiio, 2000);
multiio_poll((*handle)->multiio, 2000);
return 0;
}
/**
* @todo Stub
*/
int distren_submit_file(distren_t handle, distren_job_t *job, const char *filename)
{
return 1;
}
int distren_free(distren_t handle)
{
if(handle->rem)
remoteio_close(handle->rem);
free(handle);
return 0;
}