Exemplo n.º 1
0
/* net_connect_wait_cb:
 *  See `net_connect_wait_*'.  This version calls the given 
 *  callback while waiting, and aborts if the callback returns 
 *  nonzero.
 */
int net_connect_wait_cb (NET_CONN *conn, const char *addr, int (*cb)(void))
{
	int x = 0, y;
	if (net_connect (conn, addr)) return -1;
	do {
		if (cb) x = cb();
		y = net_poll_connect (conn);
		safe_sleep (1);
	} while ((x == 0) && (y == 0));
	if (y < 0) return -1;
	if (y > 0) return 0;
	return 1;
}
Exemplo n.º 2
0
/* net_connect_wait_time:
 *  See `net_connect_wait_*'.  The event in this case is that 
 *  `time' seconds have passed.
 */
int net_connect_wait_time (NET_CONN *conn, const char *addr, int time)
{
	int y;
	if (net_connect (conn, addr)) return -1;
	do {
		time--;
		y = net_poll_connect (conn);
		safe_sleep (1);
	} while ((time >= 0) && (y == 0));
	if (y < 0) return -1;
	if (y > 0) return 0;
	return 1;
}
Exemplo n.º 3
0
void *background_work(void *data)
{
    pthread_attr_t t_attr;

    struct get_coords_data *cd;
    struct background_work_data *bgwd = (struct background_work_data*)data;

    while(work)
    {
        safe_sleep(bgwd->step, NULL);

        cd = malloc(sizeof(struct get_coords_data));
        if(cd == NULL)
            error_exit("Allocating memory:");
        cd->list = bgwd->list;

        start_detached_thread(&cd->mutex, &t_attr, &cd->thread, collect_coordinates, cd);
    }

    return NULL;
}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
    int i,serverid=0;
    FILE *fp=NULL,*fpscript=fopen(INND_SCRIPT,"w");
    char buf[256],serverstr[30]="";
    chdir(BBSHOME "/innd");
    attach_SHM();
    resolve_boards();
    memset(istran,0,sizeof(int)*MAX_BOARD);
    load_server();
    load_newsfeeds();

    for(i=0;i<feedcount;i++)
	{
	  if(strcasecmp(serverstr,feedline[i].server))
	   {
	     if(get_server(feedline[i].server)==-1) continue;
	     if(fp) {
			fclose(fp);	
                        dobbsnnrp(serverstr,serverid,fpscript);
		    }
	     strcpy(serverstr,feedline[i].server);
	     serverid=get_server(feedline[i].server);
	     sprintf(buf,INNDHOME"/active/%s.auto.active",serverstr);
	     fp=fopen(buf,"w");
	   }
          if(fp)
             fprintf(fp,"%-35s 0000000000 0000000000 y\r\n",feedline[i].group);
	}
    if(fp) 
    {
      dobbsnnrp(serverstr,serverid,fpscript);
      fclose(fp);
    }
    if(fpscript)
     {
	fclose(fpscript);
	chmod(INND_SCRIPT,0744);
     }

    // 重設轉信與不轉信板標記
    int total = num_boards();
    for(i=0;i<total;i++)
     {
       if(bcache[i].brdname[0]=='\0' ||
	   (bcache[i].brdattr & BRD_GROUPBOARD) ) continue;
       if((bcache[i].brdattr & BRD_NOTRAN )&& istran[i])
         {
	   while(SHM->Bbusystate) {safe_sleep(1);}
  	   SHM->Bbusystate = 1;
           bcache[i].brdattr = bcache[i].brdattr & ~BRD_NOTRAN;
           strncpy(bcache[i].title + 5, "●", 2);
	   SHM->Bbusystate = 0;

           substitute_record(BBSHOME"/.BRD", &bcache[i],sizeof(boardheader_t),i+1);
	 }
       else if(!(bcache[i].brdattr & BRD_NOTRAN) && !istran[i]) 
         {
	   while(SHM->Bbusystate) {safe_sleep(1);}
           SHM->Bbusystate = 1;
           bcache[i].brdattr = bcache[i].brdattr | BRD_NOTRAN;
           strncpy(bcache[i].title + 5, "◎", 2);
           SHM->Bbusystate = 0;
           substitute_record(BBSHOME"/.BRD", &bcache[i],sizeof(boardheader_t),i+1);
	 }

     }
    return 0;
}