Exemple #1
0
int main()
{

int a = 9;
int b = 8;

call_back(max,a,b);
call_back(min,a,b);

}
 void call_back(
     std::vector<implementation_type> const & tasks)
 {
     for (size_t i = 0; i < tasks.size(); ++i) {
         call_back(tasks[i], tasks[i]->ec);
     }
 }
Exemple #3
0
bool IClient::ConnectTo(const char * const &pAddressToConnectServer, unsigned short usPortToConnectServer) {
	int nReturn;
	if (bConnected)
		return false;
	nSocket = socket(AF_INET, SOCK_STREAM, 0);
	if (nSocket == -1)
		return false;
    struct sockaddr_in addrServer;
	
	memset((void*)&addrServer, 0, sizeof(addrServer));
	addrServer.sin_family = AF_INET;
	addrServer.sin_port = htons(usPortToConnectServer);
	addrServer.sin_addr.s_addr = inet_addr(pAddressToConnectServer);
	//memset(&addrServer.sin_zero, 0, 8);

	nReturn = connect(nSocket,(struct sockaddr *)&addrServer, sizeof(addrServer));
	if(nReturn < 0) 
		return false;
/*	read_index = buffer->getConnection();
	if (read_index == -1)
	{
		return false;
	}
	write_index = buffer->getConnection();
	if (write_index == -1) 
		return false;*/
	if (call_back) 
		call_back(call_back_param, enumServerConnectCreate);
	bStop = false;
	thread->start();
	bConnected = true;
	return true;
}
Exemple #4
0
int Sqlhandler::Select_Sql_Exec(char* sql,void (*call_back)(char** result,int column,void* param),void* param)
{
	pthread_mutex_lock(&mutex);
	if(mysql_query(sock,sql))
	{
		printf("error making query:%s\n",mysql_error(sock));
		pthread_mutex_unlock(&mutex);
		return -1;
	}
	MYSQL_RES* res=mysql_use_result(sock);//获取查询结果
	if(!res)
	{
		printf("err use_result:%s\n",mysql_error(sock));
		pthread_mutex_unlock(&mutex);
		return -2;
	}
	MYSQL_ROW row;
//	int row_count=mysql_num_rows(res);
	int column_count=mysql_field_count(sock);
//	for(int i=0;i<=(row_count=mysql_num_rows(res));++i)
	while(1)
	{
//	printf("row_count=========%d,,,column_count======%d\n",row_count,column_count);
		row=mysql_fetch_row(res);
		if(!row)break;
		call_back((char**)row,column_count,param);
	}
	mysql_free_result(res);
	pthread_mutex_unlock(&mutex);
	return 1;
}
Exemple #5
0
void
tm_window_rep::interactive_return () {
    *text_ptr= get_interactive_input (wid);
    text_ptr= NULL;
    set_interactive_mode (false);
    call_back ();
}
Exemple #6
0
void avl_preorder(avl_node * root, void (*call_back)(avl_node * n, void * d), void * user_data)
{
	if (root != NULL)
	{
		call_back(root, user_data);
		avl_preorder(root->left, call_back, user_data);
		avl_preorder(root->right, call_back, user_data);
	}
}
            void work_thread(sync_data * sync_data_)
            {
                boost::posix_time::seconds const delay(5);
                boost::mutex::scoped_lock lock(sync_data_->mtx);
                while (!sync_data_->stop) {
                    if (tasks_.empty() && tasks2_.empty()) {
                        boost::system_time const start = boost::get_system_time();
                        boost::system_time const timeout = start + delay;
                        sync_data_->cond.timed_wait(lock, timeout);
                        // 检查用没有超时的域名
                        if (sync_data_->stop)
                            break;
                        check_host_cache();
                        continue;
                    }

                    implementation_type impl;
                    if (!tasks_.empty()) {
                        impl = tasks_.front();
                    } else {
                        impl = tasks2_.front();
                    }

                    if (impl->state != ResolveTask::waiting) {
                        if (!tasks_.empty() && impl == tasks_.front()) {
                            tasks_.pop_front();
                        } else {
                            tasks2_.pop_front();
                        }
                        continue;
                    } else {
                        boost::system::error_code ec;
                        lock.unlock();
                        EndpointList endpoints;
                        host_cache_.resolve(impl->name, endpoints, ec);
                        lock.lock();
                        if (sync_data_->stop)
                            break;
                        if (!ec)
                            host_cache_.update(impl->name, endpoints);
                        LOG_TRACE("[work_thread] resolved (name = %1%, endpoints = %2%)" 
                            % impl->name.to_string() % format(endpoints));
                        std::vector<implementation_type> call_back_tasks;
                        update(impl->name, ec, endpoints, tasks_, call_back_tasks);
                        update(impl->name, ec, endpoints, tasks2_, call_back_tasks);
                        sync_data_->cond.notify_all();
                        lock.unlock();
                        call_back(call_back_tasks);
                        lock.lock();
                    }
                }
                lock.unlock();
                delete sync_data_;
            }
Exemple #8
0
int main() {
    int x = 0;
    
    bound_function<void> bf([&] {
        std::cout << "Hello, world!\n";
        std::cout << "x = " << x++ << "!\n";
    });
    
    for (auto i = 0; i < 10; ++i) {
        call_back(bf);
    }
}
//メインループ
void 
mainLoop(int (*call_back)(int ))
{
    int sum=0;
    int i=0;

    while (i<10) {
	sum=call_back(i);
	printf("result : %d! = %d\n", i, sum);
	i++;
    }
    return;
}
Exemple #10
0
static VOID WINAPI RasDialFunc1 (
  HRASCONN hrasconn,    // handle to RAS connection
  UINT unMsg,           // type of event that has occurred
  RASCONNSTATE rasconnstate,   // connection state about to be entered
  DWORD dwError,        // error that may have occurred
  DWORD dwExtendedError // extended error information for some errors
   )

{
   if ( cb_info.mt )
      leave_blocking_section ();
      
   textout ( dwError?mtERR:(( RASCS_DONE & rasconnstate )?mtOK:mtINFO),
	     GetRasConnState ( rasconnstate ) );

   if ( dwError ) 
   {
      char 		szMessage[256];
      
      if ( RasGetErrorString( dwError, szMessage, 256 ) != 0 )
	 wsprintf( (LPSTR)szMessage, "Undefined RAS Dial Error." );
      
      textout ( mtERR, szMessage );

      call_back ( hrasconn, rasconnstate, GetRasConnState ( rasconnstate ),
		  dwError, szMessage );
      cb_info.g_status = -1;
   }
   else {
      if ( RASCS_DONE & rasconnstate )
	 cb_info.g_status = 1;
      call_back (  hrasconn, rasconnstate, GetRasConnState ( rasconnstate ), 0, 0 );
   }
   
   if ( cb_info.mt )
      enter_blocking_section ();
}
 void async_resolve(
     implementation_type & impl,
     NetName const & name,
     ResolveHandler * handler)
 {
     boost::mutex::scoped_lock lock(sync_data_->mtx);
     LOG_DEBUG("[async_resolve] (name = %1%)" 
         % name.to_string());
     impl->handler = handler;
     error_code ec;
     resolve_no_block(impl, name, ec);
     if (ec != boost::asio::error::would_block) {
         call_back(impl, ec);
     }
 }
 error_code cancel(
     implementation_type & impl, 
     error_code & ec)
 {
     boost::mutex::scoped_lock lock(sync_data_->mtx);
     if (impl->state == ResolveTask::waiting) {
         impl->state = ResolveTask::canceled;
         impl->ec = boost::asio::error::operation_aborted;
         sync_data_->cond.notify_one();
         if (impl->handler) {
             call_back(impl, impl->ec);
         }
     }
     ec.clear();
     return ec;
 }
Exemple #13
0
/**
 * Execute the minimiser to solve the model
 */
void GammaDiff::Execute() {
  LOG_TRACE();
  // Variables
  LOG_FINE() << "model_: " << model_;

  gammadiff::CallBack  call_back(model_);
  estimates::Manager* estimate_manager = model_->managers().estimate();
  LOG_FINE() << "estimate_manager: " << estimate_manager;

  vector<double>  lower_bounds;
  vector<double>  upper_bounds;
  vector<double>  start_values;

  model_->managers().estimate_transformation()->TransformEstimates();
  vector<Estimate*> estimates = estimate_manager->GetIsEstimated();
  LOG_FINE() << "estimates.size(): " << estimates.size();
  for (Estimate* estimate : estimates) {
    if (!estimate->estimated())
      continue;

    LOG_FINE() << "Estimate: " << estimate;
    LOG_FINE() << "transformed value: " << estimate->value();
    LOG_FINE() << "Parameter: " << estimate->parameter();

    lower_bounds.push_back((double)estimate->lower_bound());
    upper_bounds.push_back((double)estimate->upper_bound());
    start_values.push_back((double)estimate->value());

    if (estimate->value() < estimate->lower_bound()) {
      LOG_FATAL() << "When starting the GammDiff numerical_differences minimiser the starting value (" << estimate->value() << ") for estimate "
          << estimate->parameter() << " was less than the lower bound (" << estimate->lower_bound() << ")";
    } else if (estimate->value() > estimate->upper_bound()) {
      LOG_FATAL() << "When starting the GammDiff numerical_differences minimiser the starting value (" << estimate->value() << ") for estimate "
          << estimate->parameter() << " was greater than the upper bound (" << estimate->upper_bound() << ")";
    }
  }

  LOG_FINE() << "Launching minimiser";
  int status = 0;
  gammadiff::Engine clGammaDiff;
  clGammaDiff.optimise_finite_differences(call_back,
      start_values, lower_bounds, upper_bounds,
      status, max_iterations_, max_evaluations_, gradient_tolerance_,
      hessian_,1,step_size_);

  model_->managers().estimate_transformation()->RestoreEstimates();
}
static int enumerate_symbol_table (Context * ctx, ELF_Section * sec,
        EnumerateSymbols * enum_syms, EnumerateBatchSymbolsCallBack * call_back, void * args) {
    uint32_t sym_idx;
    int cont = 1;
    int has_more = 0;

    for (sym_idx = enum_syms->batch_idx; cont == 1 && sym_idx < sec->sym_count; sym_idx++) {
        ELF_SymbolInfo sym_info;
        Symbol * sym;

        unpack_elf_symbol_info(sec, sym_idx, &sym_info);

        if (elf_tcf_symbol (ctx, &sym_info, &sym) < 0) exception (errno);

        cont = call_back (args, sym);
    }
    enum_syms->batch_idx = sym_idx;
    if (sym_idx < sec->sym_count && cont != -1) has_more = 1;
    return has_more;
}
Exemple #15
0
/**
* Aplica una funcion a todos los nodos de la lista
* @param Lista a iterar
* @param Segundo parametro
* @param Funcion a aplicar
* @return Devuelve 1 si f(param1, param2) es igual a 1, 0 en otro caso
*/
int lista_iterate_function(lista *l, void *obj, int (*call_back)(nodo *, void *))
{
	nodo *caja;
	if (l == NULL)
		return 0;
	pthread_mutex_lock(&(l->lock));

	caja = l->primero;
	while (caja != NULL)
	{
		if (call_back(caja, obj) == 1)
		{
			pthread_mutex_unlock(&(l->lock));
			return 1;
		}
		caja = caja->next;
	}
	pthread_mutex_unlock(&(l->lock));
	return 0;
}
Exemple #16
0
int stores_Sql_Exec(MYSQL* mysql, char* sql, void (*call_back)(char** result, int column, void* param), void* param)
{
	if(mysql_query(mysql,sql)) {
		printf("error making query:%s\n",mysql_error(mysql));
		return -1;
	}
	MYSQL_RES* res=mysql_use_result(mysql);//获取查询结果
	if(!res) {
		printf("err use_result:%s\n",mysql_error(mysql));
		return -2;
	}
	MYSQL_ROW row;
	int column_count=mysql_field_count(mysql);
	while(1)
	{
		row=mysql_fetch_row(res);
		if(!row)break;
		call_back((char**)row,column_count,param);
	}
	mysql_free_result(res);
	return 1;
}
Exemple #17
0
/**
 * Execute the minimiser to solve the model
 */
void ADOLC::Execute() {
    LOG_TRACE();
    // Variables
    adolc::CallBack  call_back(model_);

    auto estimate_manager = model_->managers().estimate();

    vector<Double>  lower_bounds;
    vector<Double>  upper_bounds;
    vector<Double>  start_values;

    model_->managers().estimate_transformation()->TransformEstimates();
    auto estimates = estimate_manager->GetIsEstimated();
    for (auto estimate : estimates) {

        lower_bounds.push_back(estimate->lower_bound());
        upper_bounds.push_back(estimate->upper_bound());
        start_values.push_back(estimate->value());

        if (estimate->value() < estimate->lower_bound()) {
            LOG_ERROR() << "When starting the GammDiff numerical_differences minimiser the starting value (" << estimate->value() << ") for estimate "
                        << estimate->parameter() << " was less than the lower bound (" << estimate->lower_bound() << ")";
        } else if (estimate->value() > estimate->upper_bound()) {
            LOG_ERROR() << "When starting the GammDiff numerical_differences minimiser the starting value (" << estimate->value() << ") for estimate "
                        << estimate->parameter() << " was greater than the upper bound (" << estimate->upper_bound() << ")";
        }
    }

    int status = 0;
    adolc::Engine adolc;
    adolc.optimise(call_back,
                   start_values, lower_bounds, upper_bounds,
                   status, max_iterations_, max_evaluations_, gradient_tolerance_,
                   hessian_,1,step_size_);

    model_->managers().estimate_transformation()->RestoreEstimates();
}
Exemple #18
0
long vm_execute(VMContext ctx, ScriptCInstruction inst) {
  static const void *table[] = {
#define DEFINE_TABLE(NAME) &&OP_##NAME,
    IR_EACH(DEFINE_TABLE)
#undef DEFINE_TABLE
  };

  if(inst == NULL) {
    return (long)table;
  }

  register ScriptCInstruction pc = inst+1;

  goto *GET_ADDR(pc);

  OP(exit) {
    return 0;
  }
  OP(call) {
    ctx = createVMContext(ctx, pc-inst+1);
    JUMP(inst + pc->call_point);
  }
  OP(ret) {
    long retPoint = ctx->retPoint;
    Type top = pop_sp(ctx);
    VMContext next = call_back(ctx);
    if(top->type == TYPE_INT) {
      push_i(next, top->int_val);
    } else if(top->type == TYPE_FLOAT) {
      push_d(next, top->double_val);
    } else if(top->type == TYPE_STRING) {
      push_s(next, top->string);
    } else if(top->type == TYPE_BOOL) {
      push_b(next, top->bool_val);
    } else {
      fprintf(stderr, "type error of return statement\n");
      return 1;
    }
    disposeVMContext(ctx);
    ctx = next;
    JUMP(inst + retPoint);
  }
  OP(ret_void) {
    long retPoint = ctx->retPoint;
    VMContext next = call_back(ctx);
    disposeVMContext(ctx);
    ctx = next;
    JUMP(inst + retPoint);
  }
  OP(iconst) {
    push_i(ctx, pc->int_val);
    DISPATCH_NEXT;
  }
  OP(dconst) {
    push_d(ctx, pc->double_val);
    DISPATCH_NEXT;
  }
  OP(sconst) {
    push_s(ctx, pc->string);
    DISPATCH_NEXT;
  }
  OP(bconst) {
    push_b(ctx, pc->bool_val);
    DISPATCH_NEXT;
  }
  OP(jump) {
    JUMP(inst + pc->jump);
  }
  OP(ifcmp) {
    Type top = pop_sp(ctx);
    if(top->type != TYPE_BOOL) {
      fprintf(stderr, "type error of ifcmp\n");
    }
    if(!top->bool_val) {
      JUMP(inst + pc->jump);
    }
    DISPATCH_NEXT;
  }
  OP(gt) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_b(ctx, left->int_val > right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_b(ctx, left->double_val > right->double_val);
    } else {
      fprintf(stderr, "type error of gt expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(ge) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_b(ctx, left->int_val >= right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_b(ctx, left->double_val >= right->double_val);
    } else {
      fprintf(stderr, "type error of ge expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(lt) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_b(ctx, left->int_val < right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_b(ctx, left->double_val < right->double_val);
    } else {
      fprintf(stderr, "type error of lt expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(le) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_b(ctx, left->int_val <= right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_b(ctx, left->double_val <= right->double_val);
    } else {
      fprintf(stderr, "type error of le expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(eq) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_b(ctx, left->int_val == right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_b(ctx, left->double_val == right->double_val);
    } else if(right->type == TYPE_STRING && left->type == TYPE_STRING) {
      push_b(ctx, !strcmp(left->string, right->string));
    } else if(right->type == TYPE_BOOL && left->type == TYPE_BOOL) {
      push_b(ctx, left->bool_val == right->bool_val);
    } else {
      fprintf(stderr, "type error of le expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(ne) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_b(ctx, left->int_val != right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_b(ctx, left->double_val != right->double_val);
    } else if(right->type == TYPE_STRING && left->type == TYPE_STRING) {
      push_b(ctx, strcmp(left->string, right->string));
    } else if(right->type == TYPE_BOOL && left->type == TYPE_BOOL) {
      push_b(ctx, left->bool_val != right->bool_val);
    } else {
      fprintf(stderr, "type error of le expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(add) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_i(ctx, left->int_val + right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_d(ctx, left->double_val + right->double_val);
    } else if(right->type == TYPE_STRING && left->type == TYPE_STRING) {
      strcat(left->string, right->string);
      push_s(ctx, left->string);
    } else {
      fprintf(stderr, "type error of add expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(sub) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_i(ctx, left->int_val - right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_d(ctx, left->double_val - right->double_val);
    } else {
      fprintf(stderr, "type error of sub expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(mul) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_i(ctx, left->int_val * right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_d(ctx, left->double_val * right->double_val);
    } else {
      fprintf(stderr, "type error of mul expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(div) {
    Type right = pop_sp(ctx);
    Type left = pop_sp(ctx);
    if(right->type == TYPE_INT && left->type == TYPE_INT) {
      push_i(ctx, left->int_val / right->int_val);
    } else if(right->type == TYPE_FLOAT && left->type == TYPE_FLOAT) {
      push_d(ctx, left->double_val / right->double_val);
    } else {
      fprintf(stderr, "type error of div expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(minus) {
    Type left = pop_sp(ctx);
    if(left->type == TYPE_INT) {
      push_i(ctx, -left->int_val);
    } else if(left->type == TYPE_FLOAT) {
      push_d(ctx, -left->double_val);
    } else {
      fprintf(stderr, "type error of add expression\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(loadl) {
    Type val = ctx->var_list+pc->var_id;
    if(val->type == TYPE_INT) {
      push_i(ctx, val->int_val);
    } else if(val->type == TYPE_FLOAT) {
      push_d(ctx, val->double_val);
    } else if(val->type == TYPE_STRING) {
      push_s(ctx, val->string);
    } else if(val->type == TYPE_BOOL) {
      push_b(ctx, val->bool_val);
    } else {
      fprintf(stderr, "type error of loadl\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(storea) {
    Type val = ctx->var_list+pc->var_id;
    Type top = pop_sp(ctx->prev);
    if(top->type == TYPE_INT) {
      val->int_val = top->int_val;
    } else if(top->type == TYPE_FLOAT) {
      val->double_val = top->double_val;
    } else if(top->type == TYPE_STRING) {
      val->string = top->string;
    } else if(top->type == TYPE_BOOL) {
      val->bool_val = top->bool_val;
    } else {
      fprintf(stderr, "type error of storel\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(storel) {
    Type val = ctx->var_list+pc->var_id;
    Type top = pop_sp(ctx);
    if(top->type == TYPE_INT) {
      val->int_val = top->int_val;
      val->type = TYPE_INT;
    } else if(top->type == TYPE_FLOAT) {
      val->double_val = top->double_val;
      val->type = TYPE_FLOAT;
    } else if(top->type == TYPE_STRING) {
      val->string = top->string;
      val->type = TYPE_STRING;
    } else if(top->type == TYPE_BOOL) {
      val->bool_val = top->bool_val;
      val->type = TYPE_BOOL;
    } else {
      fprintf(stderr, "type error of storel\n");
      return 1;
    }
    DISPATCH_NEXT;
  }
  OP(write) {
    Type val = pop_sp(ctx);
    if(val->type == TYPE_INT) {
      printf("%d\n", val->int_val);
    } else if(val->type == TYPE_FLOAT) {
      printf("%f\n", val->double_val);
    } else if(val->type == TYPE_STRING) {
      printf("%s\n", val->string);
    } else if(val->type == TYPE_BOOL) {
      if(val->bool_val) {
        printf("true\n");
      } else {
        printf("false\n");
      }
    }
    DISPATCH_NEXT;
  }

  return 0;
}
Exemple #19
0
/* Handle tcp connection:
 *  Handle any request coming from a connected client. Once data has been received, send it to the specified handler for processing.
 */
int handle_tcp_connection ( int client_socket, char*(*call_back)(char*) ) {
    char buffer[RECV_BUF_SIZE];
    
    char *message = NULL;
    char *data;
    
    int message_size;
    int read_finished = 0;
    
    /* Loop until the newline character is read */
    while ( read_finished == 0 ) {
    
        message_size = recv ( client_socket, buffer, RECV_BUF_SIZE, 0 );
    
        /* Sanity check */
        if ( message_size < 0 ) {
            DIE ( "recv() failed." );
        }
        
        /* Client disconnected, return that status */
        if ( message_size == 0 ) {
            return 0;
        }
        
        /* Allocate memory for the message */
        if ( message == NULL ) {
            message = malloc ( message_size * sizeof ( char ) + 1 );
            strncpy ( message, buffer, message_size );
        } else {
            /* Resize as necessary */
            char *tmp;
            tmp = realloc ( message, strlen ( message ) + message_size * sizeof ( char ) + 1 );
            
            /* Sanity check */
            if (tmp == NULL ) {
                DIE ( "realloc()." );
            }
            
            message = tmp;
            /* Append to the message */
            strncat ( message, buffer, message_size );
        }
        
        /* Received end of line, finish processing */
        if ( strstr ( message, "\n") != NULL ) {
            read_finished = 1;
        }
    }
    
    /* Pass the message onto the call back handler for processing */
    data = call_back( message );
    
    /* Clean up */
    free ( message );
    
    /* Sned out the results of processing */
    if ( send ( client_socket, data, strlen ( data ), 0 ) != strlen ( data ) ) {
        DIE ( "send() failed." );
    }

    /* Clean up */
    free ( data );
    
    
    /* Still active */
    return 1;
    
}