Exemplo n.º 1
0
int
bah (int p, int q)
{
  int i, j;

  while (q < -20)
    q += get_stuff (-q);

  for (i = 0; i < 36; i++)
    for (j = 0; j < 36; j++)
      do_stuff (get_stuff (q * i + 2));

  bar (p, q);
}
Exemplo n.º 2
0
int
get_jobs (int x, int y, int jobs)
{
  int q;
  if (numof_markets > 0)
    {
      for (q = 0; q < numof_markets; q++)
	{
	  if ((abs (marketx[q] - x) < MARKET_RANGE
	       && abs (markety[q] - y) < MARKET_RANGE
	       && (MP_INFO(marketx[q],markety[q]).int_2 > (3 * jobs / 2))))
	    {
	      MP_INFO(marketx[q],markety[q]).int_2 -= jobs;
	      income_tax += jobs;
	      return (1);
	    }
	}
    }
  if (get_stuff (x, y, jobs, T_JOBS) != 0)
    {
      income_tax += jobs;
      return (1);
    }
  return (0);
}
Exemplo n.º 3
0
int
get_goods (int x, int y, int goods)
{
  int q;
  if (numof_markets > 0)
    {
      for (q = 0; q < numof_markets; q++)
	{
	  if (abs (marketx[q] - x) < MARKET_RANGE
	      && abs (markety[q] - y) < MARKET_RANGE
	      && (MP_INFO(marketx[q],markety[q]).int_4
		  > goods))
	    {
	      MP_INFO(marketx[q],markety[q]).int_4 -= goods;
	      goods_tax += goods;
	      goods_used += goods;
	      /* make the waste here. */
	      MP_INFO(marketx[q],markety[q]).int_7 += goods / 3;
	      return (1);
	    }
	}
    }
  if (get_stuff (x, y, goods, T_GOODS) != 0)
    {
      put_stuff (x, y, goods / 3, T_WASTE);
      goods_tax += goods;
      goods_used += goods;
      return (1);
    }
  return (0);
}
Exemplo n.º 4
0
//*****************************************************************************
//*************************   MAIN-FUNCTION   *********************************
//*****************************************************************************
int main () {


	//Connect to the database
	mysql_connect();

	//gets min_rv en RV[]
	get_stuff();

	//disconnect from the database
	mysql_disconnect();


	//check for a too low value and send mail
	for(int i = 0; i < 3600; i++){
		if((RV[i] < min_rv) && (RV[i] > 0)){
			//exec command
			//snprintf(temp, 100, "cat /usr/share/nginx/mail/humidity_low.txt | mail -s \"Test Subject\" [email protected]");
			//echo "<b>HTML Message goes here</b>" | mail -s "$(echo -e "This is the subject\nContent-Type: text/html")" [email protected]
			snprintf(temp, 200, "cat /usr/share/nginx/mail/humidity_low.txt | mail -s \"$(echo \"[TerraPi] Too low humidity detected.\nContent-Type: text/html\")\" [email protected]");
			system(temp);

			printf("Error: Too low humidity - mail has been sent.\n\n");
			break;
		}
	}

}
Exemplo n.º 5
0
Arquivo: async.c Projeto: Elohim/FGmud
void do_stuff(void *(*func)(struct request *), struct request *data){
	if(!thread_started){
		pthread_mutex_init(&mut, NULL);
		pthread_mutex_init(&mem_mut, NULL);
		pthread_mutex_init(&work_mut, NULL);
		pthread_mutex_lock(&mut);
		pthread_t t;
		pthread_create(&t, NULL, &thread_func, NULL);
		thread_started = 1;
	}
	struct stuff *work = get_stuff();
	work->func = func;
	work->data = data;
	work->next = NULL;
	pthread_mutex_lock(&work_mut);
	add_req(data);
	if(lasttodo){
		lasttodo->next = work;
		lasttodo = work;
	} else {
		todo = lasttodo = work;
	}
	pthread_mutex_unlock(&work_mut);
	pthread_mutex_unlock(&mut);
}
Exemplo n.º 6
0
int
foo (int s, int p)
{
  int c, r = 0;

  for (c = 0 ; c < count; c++)
    {
      r += get_stuff (s);
      /* The following is just something big that can go away.  */
      if (p != 0)
	{
	  int a[64][64];
	  int i, j, k;

	  for (i = 0; i < 64; i++)
	    for (j = 0; j < 64; j++)
	      a[i][j] = get_element (p + c, i, j);

	  for (k = 0; k < 4; k++)
	    {
	      r = r / 2;

	      for (i = 1; i < 63; i++)
		for (j = 62; j > 0; j--)
		  a[i][j] += adjust (a[i-1][j], a[i][j-1],
				     a[i+1][j], a[i][j+1]);

	      for (i = 4; i < 64; i += 4)
		for (j = 4; j < 64; j += 4)
		  r += a[i][j] / 4;
	    }
	}
    }
  return r;
}
Exemplo n.º 7
0
static void foo(struct A p, char *q)
{
  if (p.i)
    p.u.p = get_stuff ();
  else
    p.u.q = q;

  use_stuff (p.u.q);
}
Exemplo n.º 8
0
int				termcap_init(void)
{
	char				*name_term;

	manage_signal();
	if ((get_stuff()->fd = open(ttyname(0), O_WRONLY | O_NOCTTY)) == -1)
		return (-1);
	if ((name_term = getenv("TERM")) == NULL)
		return (-1);
	if (tgetent(NULL, name_term) == -1)
		return (-1);
	if (tcgetattr(get_stuff()->fd, get_term()) == -1)
		return (-1);
	get_term()->c_lflag &= ~(ICANON | ECHO);
	get_term()->c_cc[VMIN] = 1;
	get_term()->c_cc[VTIME] = 0;
	if (tcsetattr(get_stuff()->fd, TCSADRAIN, get_term()) == -1)
		return (-1);
	tputs(tgetstr("ti", NULL), 1, ft_putchr);
	hide_cursor();
	enable_keyboard();
	get_s_win();
	return (0);
}
Exemplo n.º 9
0
float foo(int *err)
{
    int err = 0;
    float result = <some default value>;

    // Acquire resources
    Stuff *stuff = get_stuff(err);
    if (*err) {
        return result;
    }

    MoreStuff *more_stuff = get_more_stuff(err);
    if (*err) {
        goto free_stuff;
    }

    // Do work

    // ...

    // On error need to ensure all resources are released
    if (*err) {
        goto finalize;
    }

    // ...

    // We don't set until completely finished so the function either
    // succeeds or does nothing at all.

    // Commit result
    result = <final result>;

    // Release resources
finalize:
    free(more_stuff);
    more_stuff = NULL;

    // Partial tear-down
free_stuff:
    free(stuff);
    stuff = NULL;

    return result;
}
Exemplo n.º 10
0
int
get_food (int x, int y, int food)
{
  int q;
  if (numof_markets > 0)
    {
      for (q = 0; q < numof_markets; q++)
	{
	  if ((abs (marketx[q] - x) < MARKET_RANGE)
	      && (abs (markety[q] - y) < MARKET_RANGE)
	      && (MP_INFO(marketx[q],markety[q]).int_1
		  > food))
	    {
	      MP_INFO(marketx[q],markety[q]).int_1 -= food;
	      return (1);
	    }
	}
    }
  if (get_stuff (x, y, food, T_FOOD) != 0)
    return (1);
  return (0);
}
Exemplo n.º 11
0
int
get_coal (int x, int y, int coal)
{
  int q;
  if (numof_markets > 0)
    {
      for (q = 0; q < numof_markets; q++)
	{
	  if ((abs (marketx[q] - x) < MARKET_RANGE)
	      && (abs (markety[q] - y) < MARKET_RANGE)
	      && (MP_INFO(marketx[q],markety[q]).int_3
		  > coal))
	    {
	      MP_INFO(marketx[q],markety[q]).int_3 -= coal;
	      return (1);
	    }
	}
    }
  if (get_stuff (x, y, coal, T_COAL) != 0)
    return (1);
  return (0);
}
Exemplo n.º 12
0
int
get_ore (int x, int y, int ore)
{
  int q;
  if (numof_markets > 0)
    {
      for (q = 0; q < numof_markets; q++)
	{
	  if ((abs (marketx[q] - x) < MARKET_RANGE)
	      && (abs (markety[q] - y) < MARKET_RANGE)
	      && (MP_INFO(marketx[q],markety[q]).int_5
		  > ore))
	    {
	      MP_INFO(marketx[q],markety[q]).int_5 -= ore;
	      return (1);
	    }
	}
    }
  if (get_stuff (x, y, ore, T_ORE) != 0)
    return (1);
  return (0);
}
Exemplo n.º 13
0
int
get_steel (int x, int y, int steel)
{
  int q;
  if (numof_markets > 0)
    {
      for (q = 0; q < numof_markets; q++)
	{
	  if ((abs (marketx[q] - x) < MARKET_RANGE)
	      && (abs (markety[q] - y) < MARKET_RANGE)
	      && (MP_INFO(marketx[q],markety[q]).int_6
		  > steel))
	    {
	      MP_INFO(marketx[q],markety[q]).int_6 -= steel;
	      return (1);
	    }
	}
    }
  if (get_stuff (x, y, steel, T_STEEL) != 0)
    return (1);
  return (0);
}
Exemplo n.º 14
0
int
get_waste (int x, int y, int waste)
{
  int q;
  if (numof_markets > 0)
    {
      for (q = 0; q < numof_markets; q++)
	{
	  if ((abs (marketx[q] - x) < MARKET_RANGE)
	      && (abs (markety[q] - y) < MARKET_RANGE)
	      && (MP_INFO(marketx[q],markety[q]).int_7
		  > waste))
	    {
	      MP_INFO(marketx[q],markety[q]).int_7 -= waste;
	      return (1);
	    }
	}
    }
  if (get_stuff (x, y, waste, T_WASTE) != 0)
    return (1);
  return (0);
}
Exemplo n.º 15
0
void loop(){
    float foo[3];
    api.getMyZRState(me);
    foo[0] = me[0];
    foo[1] = me[1];
    foo[2] = me[2];
    
   
    target_enemy();
    api.setAttitudeTarget(enemy_direction);
    
   
    if (red_or_blue){ 
        if (stage == 0){
            get_stuff(mirror_2, 8);
        }
        
        if (stage == 1){
            get_stuff(score_4, 6); //top score block
        }
        
        if (stage == 2){
            get_stuff(mirror_1, 7); // right mirror
        }
        
        if (stage == 3){
            get_stuff(score_2, 4); //left block
        }
        
        if (stage == 4){
            get_stuff(score_3, 5);//right block
        }
        
        
        if (stage == 5){
            get_stuff(energy_2, 1);//right energy
        }
        
    }
    else {
        if (stage == 0){
            get_stuff(mirror_1, 7);
        }
        
        if (stage == 1){
            get_stuff(score_4, 6); //top score block
        }
        
        if (stage == 2){
            get_stuff(mirror_2, 8); //left block
        }
        
        
         if (stage == 3){
            get_stuff(score_3, 5);//right block
        }
        if (stage == 4) {
            get_stuff(score_2, 4);//left block
        }
    
        if (stage == 5){
            get_stuff(energy_1, 0); //left energy
        }
    }
    mirror_use();
    pic();
}
Exemplo n.º 16
0
/************************************************************************
 *                                                                       *
 *  get_name                                                              *
 *									*/
double
Win_movie::get_name(char *s1, char *s2, int where)
{
    Movie_frame *insert_point, *list_point, *newframe ;
    int zip ;
    double the_vs = 0.0;

#ifdef DMALLOC
    cerr << "v1.1 ";
    malloc_verify();
#endif

    if ((strcmp(s1,"delete")==0) && (strcmp(s2,"delete")==0)){
	if ((where<number_of_frames)&&(number_of_frames>0)){
	    insert_point = movie_head ;
	    for (zip = 0 ; zip < where ; zip++ ){
		insert_point = insert_point->nextframe ;
	    }
	    insert_point->prevframe->nextframe = insert_point->nextframe ; 
	    insert_point->nextframe->prevframe = insert_point->prevframe ; 
	    if (where==0){
		movie_head = insert_point->nextframe ;
	    }
	    delete insert_point ;
	    if (number_of_frames==1){       /* if there was only one, */
		movie_head = NULL ;          /* there are none now. */
	    }
	}
    }else{
	char *filename = new char[strlen(s1) + strlen(s2) + 2];
	strcpy(filename, s1);
	strcat(filename, "/");
	strcat(filename, s2);
    
	if (movie_head == NULL){
	    movie_head = new Movie_frame(filename);
	    delete [] filename;
	    if ((the_vs = get_stuff (movie_head)) == -1.0){
		delete movie_head ;
		movie_head = NULL;
		return (-1.0);
	    }else{
		movie_head->nextframe = movie_head ;
		movie_head->prevframe = movie_head ;
	    }
	}else{
	    insert_point = movie_head ;
	    for (zip = 0 ; zip < where ; zip++ ){
		insert_point = insert_point->nextframe ;
	    }
	    newframe = new Movie_frame(filename);
	    delete [] filename;
	    if ((the_vs = get_stuff (newframe)) == -1.0){  
		delete newframe ;
		newframe = NULL; 
		return (-1.0);
	    }else{ 
		newframe->nextframe = insert_point ;
		newframe->prevframe = insert_point->prevframe;
		insert_point->prevframe->nextframe = newframe ;
		insert_point->prevframe = newframe ;
	    }
	    
	    if (where==0){
		movie_head = newframe;
	    }
	}
    }

#ifdef DMALLOC
    cerr << "v1.2 ";
    malloc_verify();
#endif

    number_of_frames = 0 ;
    list_point = movie_head ;
    if (movie_head != NULL){
	do{
	    list_point = list_point->nextframe ;
	    number_of_frames++ ;
	} while (list_point != movie_head);
    }
    
    frame_number = high_frame = number_of_frames - 1 ;

    // If we have more than 1 frame, show frame slider and start/stop buttons

    int slider_show = number_of_frames > 1 ? TRUE : FALSE;
    xv_set(frame_slider,
	   PANEL_MAX_VALUE, number_of_frames,
	   PANEL_VALUE, number_of_frames,
	   XV_SHOW, slider_show,
	   NULL);
    xv_set(start_stop_item, XV_SHOW, slider_show, NULL);

    if (number_of_frames){
	xv_set(high_frame_item,
	       PANEL_VALUE, number_of_frames,
	       PANEL_MAX_VALUE, number_of_frames,
	       NULL);
	xv_set(low_frame_item, PANEL_MAX_VALUE, number_of_frames, NULL);
	int t = (int)xv_get(low_frame_item, PANEL_VALUE);
	if (t <= 0){
	    xv_set(low_frame_item, PANEL_VALUE, 1, NULL);
	}else if (t > number_of_frames){
	    xv_set(low_frame_item, PANEL_VALUE, number_of_frames, NULL);
	}
    }else{
	xv_set(high_frame_item, PANEL_VALUE, 1, NULL);
	xv_set(low_frame_item, PANEL_VALUE, 1, NULL);
    }

#ifdef DMALLOC
    cerr << "v1.3 ";
    malloc_verify();
#endif
    
    return the_vs;
}