Changeset - 92659c5651ef
[Not reviewed]
default
1 23 0
Nathan Brink (binki) - 15 years ago 2010-07-22 00:03:45
ohnobinki@ohnopublishing.net
Reformed buildsystem.
- replace malloc.h with stdlib.h
- use AC_CONFIG_HEADERS for cleaner compile output
- clean out some useless AC_* macros and add useful AC_TYPE_UINT* macros
24 files changed with 95 insertions and 97 deletions:
0 comments (0 inline, 0 general)
configure.ac
Show inline comments
 
@@ -17,33 +17,28 @@
 

	
 
AC_PREREQ(2.61)
 
AC_INIT([distren],[0.0],[http://bugs.ohnopub.net/], [], [http://ohnopub.net/distren/])
 
AC_CONFIG_HEADERS([src/common/config.h])
 
AC_CONFIG_SRCDIR([src/server/distrend.c])
 
AC_CONFIG_MACRO_DIR([m4])
 

	
 
AC_PROG_CC
 
AC_PROG_LIBTOOL
 
#AC_PROG_RANLIB #don't add this even if autoscan says to, because AC_PROG_LIBTOOL is enough
 

	
 
AM_INIT_AUTOMAKE([gnu dist-bzip2 subdir-objects -Wall])
 
AM_PROG_CC_C_O
 

	
 
#basic low-level checks (suggested by autoscan)
 
AC_CHECK_FUNCS([dup2])
 
AC_CHECK_FUNCS([memset])
 
AC_CHECK_FUNCS([strdup])
 

	
 
AC_CHECK_HEADERS([fcntl.h])
 
AC_CHECK_HEADERS([malloc.h])
 

	
 
AC_FUNC_FORK
 
AC_FUNC_MALLOC
 

	
 
dnl these macros force the refered to types to be available without me
 
dnl writing my own magic :-)
 
AC_TYPE_PID_T
 
AC_TYPE_SIZE_T
 

	
 
# selective compilation
 
# For now, this is only left for when the C-based client is
 
# reintroducded.
 
AC_TYPE_UINT8_T
 
AC_TYPE_UINT16_T
 
AC_TYPE_UINT32_T
 

	
 
dnl selective compilation
 
dnl For now, this is only left for when the C-based client is
 
dnl reintroducded.
 
AC_ARG_ENABLE([server],
 
	[AS_HELP_STRING([--disable-server],[Don't build the distren server])],
 
	[enable_server=$enableval],
 
@@ -51,30 +46,24 @@ AC_ARG_ENABLE([server],
 
AM_CONDITIONAL([ENABLE_SERVER],
 
	[test "x$enable_server" = "xyes"])
 

	
 
# to grab GNU-specific function prototypes for the following functions:
 
# getline
 
AC_DEFINE([_GNU_SOURCE], [1])
 
dnl package dependencies:
 

	
 
#package dependencies:
 

	
 
PKG_PROG_PKG_CONFIG(0.17.2)
 

	
 

	
 
PKGCONFIG_OHNOWRAP([DISTLIBS], [libconfuse >= 2.5 libcurl libxml-2.0 liblist >= 2.2.1 libarchive >= 2.8.0 ])
 
PKG_CHECK_MODULES([DISTLIBS], [libconfuse >= 2.5 libcurl libxml-2.0 liblist >= 2.3.1 libarchive >= 2.8.0])
 
AX_LIB_MYSQL
 
AS_IF( [test "x${MYSQL_VERSION}" = "x"],
 
	[ AC_MSG_ERROR([I need mysql]) ] )
 

	
 
PKGCONFIG_OHNOWRAP([CHECK], [check >= 0.9.3])
 
PKG_CHECK_MODULES([CHECK], [check >= 0.9.3])
 

	
 
# define paths for configuration files:
 
dnl define paths for configuration files until a better arrangement is
 
dnl made:
 

	
 
AC_DEFINE_DIR([LOCALSTATEDIR], [localstatedir], [Default directory for storing state information])
 
AC_DEFINE_DIR([RUNSTATEDIR], [localstatedir/run], [Default directory for registering runtime information like pid-files])
 

	
 
AC_CONFIG_FILES([Makefile
 
etc/distrendaemon.conf
 
etc/distrenslave.conf
 
	etc/distrendaemon.conf
 
	etc/distrenslave.conf
 
])
 

	
 
AC_OUTPUT
m4/pkgconfig_ohnowrap.m4
Show inline comments
 
deleted file
src/client/distren.c
Show inline comments
 
@@ -29,6 +29,8 @@
 
 */
 

	
 

	
 
#include "common/config.h"
 

	
 
#include "distren.h"
 

	
 
#include <stdio.h> /* sprintf, printf */
 
@@ -37,7 +39,6 @@
 
#include <confuse.h>
 
#include <string.h> // for strcat
 

	
 

	
 
int main(int argc, char *argv[])
 
{
 
  int doLogin = 0;
src/client/libdistren.c
Show inline comments
 
@@ -21,10 +21,12 @@
 
  Implementation of distren_* functions from distren.h excluding distren_job_* functions.
 
 */
 

	
 
#include "common/config.h"
 

	
 
#include "libdistren.h"
 

	
 
#include <malloc.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 

	
 
/**
 
   @todo needs to read configuration in
src/client/libdistren_config.c
Show inline comments
 
@@ -21,6 +21,8 @@
 
  Functions and code for retrieving the client's configuration information.
 
 */
 

	
 
#include "common/config.h"
 

	
 
#include "client/libdistren.h"
 
#include "common/options.h"
 

	
src/client/libdistren_job.c
Show inline comments
 
@@ -21,6 +21,8 @@
 
  Implementation of distren_job_* functions from distren.h.
 
 */
 

	
 
#include "common/config.h"
 

	
 
#include "libdistren.h"
 

	
 
/**
src/client/libdistren_unbias.c
Show inline comments
 
@@ -21,6 +21,8 @@
 
  Implementation of libdistren functions that exist to prevent this library from being biased toward certain methods of reporting errors/debug info or free()ing and malloc()ing
 
 */
 

	
 
#include "common/config.h"
 

	
 
#include "libdistren.h"
 

	
 
void *_malloc(distren_t distren, size_t size)
src/common/asprintf.c
Show inline comments
 
@@ -17,6 +17,8 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <stdarg.h>
src/common/execio.c
Show inline comments
 
@@ -17,7 +17,9 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "execio.h"
 
#include "common/config.h"
 

	
 
#include "common/execio.h"
 

	
 
#include <unistd.h>
 
#include <sys/types.h>
 
@@ -25,7 +27,6 @@
 
#include <sys/wait.h>
 
#endif
 
#include <signal.h>
 
#include <malloc.h>
 
#include <fcntl.h>
 
#include <stdio.h>
 
#include <stdlib.h>
src/common/misc.c
Show inline comments
 
@@ -17,12 +17,14 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "common/misc.h"
 

	
 
#include <errno.h>
 
#include <malloc.h>
 
#include <unistd.h>
 
#include <stddef.h>
 
#include <stdlib.h>
 

	
 
char *distren_getcwd()
 
{
src/common/multiio.c
Show inline comments
 
@@ -18,13 +18,15 @@
 

	
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "common/multiio.h"
 

	
 
#include <list.h>
 
#include <fcntl.h>
 
#include <malloc.h>
 
#include <poll.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 

	
 
struct multiio_socket_info
src/common/options.c
Show inline comments
 
@@ -17,6 +17,8 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "common/options.h"
 

	
 
#include "common/asprintf.h"
src/common/protocol.c
Show inline comments
 
@@ -17,11 +17,13 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "protocol.h"
 
#include "remoteio.h"
 
#include "common/config.h"
 

	
 
#include <malloc.h>
 
#include "common/protocol.h"
 
#include "common/remoteio.h"
 

	
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 

	
 
#define DISTREN_REQUEST_MAGIC ((uint32_t)0x32423434)
src/common/remoteio.c
Show inline comments
 
@@ -18,9 +18,11 @@
 

	
 
*/
 

	
 
#include "libremoteio.h"
 
#include "execio.h"
 
#include "asprintf.h"
 
#include "common/config.h"
 

	
 
#include "common/libremoteio.h"
 
#include "common/execio.h"
 
#include "common/asprintf.h"
 

	
 
#include <list.h>
 

	
 
@@ -116,12 +118,12 @@ int remoteio_config(cfg_t *cfg, struct r
 

	
 
  multiio_event_handler_register(opts->multiio,
 
				 opts->socket_type,
 
				 POLLWRNORM,
 
				 POLLOUT,
 
				 (multiio_event_handler_func_t)&_remoteio_handle_write,
 
				 opts);
 
  multiio_event_handler_register(opts->multiio,
 
				 opts->socket_type,
 
				 POLLRDNORM,
 
				 POLLIN,
 
				 (multiio_event_handler_func_t)&_remoteio_handle_read,
 
				 opts);
 

	
 
@@ -224,7 +226,7 @@ int remoteio_open_socket(struct remoteio
 
  rem = *remoteio;
 

	
 
  rem->sock = fd;
 
  multiio_socket_add(opts->multiio, rem->sock, opts->socket_type, rem, POLLRDNORM);
 
  multiio_socket_add(opts->multiio, rem->sock, opts->socket_type, rem, POLLIN);
 

	
 
  return 0;
 
}
 
@@ -281,7 +283,7 @@ int remoteio_open_server(struct remoteio
 
   * execio's multi-sockets by letting execio register itself with
 
   * multiio instead of us registering here perhaps
 
   */
 
  multiio_socket_add(opts->multiio, rem->sock, opts->socket_type, rem, POLLRDNORM);
 
  multiio_socket_add(opts->multiio, rem->sock, opts->socket_type, rem, POLLIN);
 
  
 
  return 0;
 
}
 
@@ -371,10 +373,10 @@ int remoteio_write(struct remoteio *rem,
 
  if(q_empty(rem->outmsgs))
 
    {
 
      pollfd.fd = rem->sock;
 
      pollfd.revents = POLLWRNORM;
 
      pollfd.revents = POLLOUT;
 
      pollfd.events = 0;
 
      poll(&pollfd, 1, 0);
 
      if(pollfd.events & POLLWRNORM)
 
      if(pollfd.events & POLLOUT)
 
	{
 
	  bytes_written = write(rem->sock, buf, len);
 
	  if(bytes_written > 0)
 
@@ -411,7 +413,7 @@ int remoteio_write(struct remoteio *rem,
 
  memcpy(packet->data, buf, len);
 

	
 
  q_enqueue(rem->outmsgs, packet, 0);
 
  multiio_socket_event_enable(rem->opts->multiio, rem->sock, POLLWRNORM);
 
  multiio_socket_event_enable(rem->opts->multiio, rem->sock, POLLOUT);
 

	
 
  return 0;
 
}
 
@@ -435,7 +437,7 @@ int _remoteio_handle_write(multiio_conte
 
   */
 
  if(q_empty(rem->outmsgs))
 
    {
 
      multiio_socket_event_disable(multiio, fd, POLLWRNORM);
 
      multiio_socket_event_disable(multiio, fd, POLLOUT);
 
      return 0;
 
    }
 

	
 
@@ -455,7 +457,7 @@ int _remoteio_handle_write(multiio_conte
 
      remoteio_packet_free(packet);
 

	
 
      if(q_empty(rem->outmsgs))
 
	multiio_socket_event_disable(multiio, fd, POLLWRNORM);
 
	multiio_socket_event_disable(multiio, fd, POLLOUT);
 
    }
 
  else
 
    {
src/common/request.c
Show inline comments
 
@@ -17,6 +17,8 @@
 
 * along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
#include "common/config.h"
 

	
 
#include "common/protocol.h"
 

	
 
#include <stdlib.h>
src/server/distrend.c
Show inline comments
 
@@ -20,6 +20,8 @@
 

	
 
/* This file contains the code which both processes (renders) jobs as a slave, and the code which distributes frames to slaves after receiving them from the client portion of the codebase. */
 

	
 
#include "common/config.h"
 

	
 
#include "distrenjob.h"
 
#include "listen.h"
 
#include "slavefuncs.h"
 
@@ -31,7 +33,6 @@
 
#include "common/protocol.h"
 

	
 
#include <confuse.h>
 
#include <malloc.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
src/server/distrenjob.c
Show inline comments
 
@@ -17,6 +17,8 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "distrenjob.h"
 
#include "slavefuncs.h"
 

	
 
@@ -25,6 +27,7 @@
 
#include <libxml/parser.h>
 
#include <libxml/tree.h>
 
#include <libxml/xmlwriter.h>
 
#include <time.h>
 

	
 
void distrenjob_free(struct distrenjob **distrenjob)
 
{
src/server/listen.c
Show inline comments
 
@@ -17,15 +17,18 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "listen.h"
 

	
 
#include "common/protocol.h"
 
#include "common/remoteio.h"
 

	
 
#include <errno.h>
 
#include <list.h>
 
#include <malloc.h>
 
#include <netinet/in.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 
#include <sys/types.h>
 
#include <poll.h>
 
@@ -103,7 +106,7 @@ struct distrend_listens *distrend_listen
 
				 listens);
 
  multiio_event_handler_register(multiio,
 
				 listens->socket_type,
 
				 POLLRDNORM,
 
				 POLLIN,
 
				 (multiio_event_handler_func_t)&listen_handle_accept,
 
				 listens);
 

	
 
@@ -156,7 +159,7 @@ int distrend_listen_add(struct distrend_
 
    }
 
  *saved_port = port;
 

	
 
  tmp = multiio_socket_add(listens->multiio, fd, listens->socket_type, saved_port, POLLRDNORM);
 
  tmp = multiio_socket_add(listens->multiio, fd, listens->socket_type, saved_port, POLLIN);
 
  if(tmp)
 
    {
 
      close(fd);
src/server/mysql.c
Show inline comments
 
@@ -18,6 +18,8 @@
 

	
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "mysql.h"
 
#include <mysql/mysql.h>
 

	
src/server/simpleslave.c
Show inline comments
 
@@ -18,6 +18,8 @@
 

	
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "slavefuncs.h"
 

	
 
#include "common/asprintf.h"
src/server/slave.c
Show inline comments
 
@@ -18,6 +18,8 @@
 

	
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "slavefuncs.h"
 

	
 
#include "common/asprintf.h"
src/server/slavefuncs.c
Show inline comments
 
@@ -17,6 +17,8 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "distrenjob.h"
 
#include "slavefuncs.h"
 

	
src/server/tabletennis.c
Show inline comments
 
@@ -17,6 +17,8 @@
 
 * along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
#include "common/config.h"
 

	
 
#include "distrend.h"
 
#include "listen.h"
 
#include "tabletennis.h"
src/server/user_mgr.c
Show inline comments
 
@@ -17,6 +17,8 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "common/config.h"
 

	
 
#include "user_mgr.h"
 

	
 
#include "common/asprintf.h"
 
@@ -29,7 +31,6 @@
 
#include <libxml/xmlwriter.h>
 
#include <libxml/xmlreader.h>
 

	
 
#include <malloc.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 
@@ -80,8 +81,10 @@ struct user *findUser(char *nameOfUser)
 
	int low;
 
	int middle;
 
	int result;
 

	
 
	high = user_mgr_info.user_array_size - 1;
 
	low = 0;
 
	result = -1;
 

	
 
	for(middle = (low+high)/2; 1 == 1; middle = (low+high)/2)
 
	{
 
@@ -89,9 +92,9 @@ struct user *findUser(char *nameOfUser)
 
		while(user_mgr_info.user_array[middle].username == 0)
 
		{
 
			if(result < 0)
 
				middle--;
 
				middle --;
 
			else
 
				middle++;
 
				middle ++;
 
		}
 

	
 
		// this is where the array is cut in half and the half that the nameOfUser is on is kept
 
@@ -142,6 +145,8 @@ int placeUser(int index, char *nameOfUse
 
	int lower;
 
	int total_moves;
 

	
 
	total_moves = 0;
 

	
 
	// I shift data in the array to create an open the space where the user should be added
 
	// but first I figure out which way is the shortest
 
	if(user_mgr_info.user_array[index].username != 0)
 
@@ -172,9 +177,9 @@ int placeUser(int index, char *nameOfUse
 
	// add the user to the array
 
	createUser(&user_mgr_info.user_array[index], nameOfUser);
 

	
 
	if(total_moves > 50){
 
	if(total_moves > 50)
 
	  resize_user_array();
 
	}
 

	
 
	return 1;
 
}
 

	
 
@@ -184,8 +189,10 @@ int addUser(char *nameOfUser)
 
	int low;
 
	int middle;
 
	int result;
 

	
 
	high = user_mgr_info.user_array_size - 1;
 
	low = 0;
 
	result = -1;
 

	
 
	for(middle = (low+high)/2; 1 == 1; middle = (low+high)/2)
 
	{
0 comments (0 inline, 0 general)