void loadbotservdb() { char nick[NICKLEN+1]; char ident[NICKLEN+1]; char host[HOSTLEN+1]; char chan[CHANLEN+1]; MYSQL_RES *result; MYSQL_ROW row; if (!reconnect_to_db()) { fprintf(stderr,"Cannot connect to db\n"); operlog("Cannot connect to db"); return; } mysql_query(&mysql,"SELECT * FROM child_botserv_bots"); if ((result = mysql_use_result(&mysql)) == NULL) { fprintf(stderr,"CRITICAL: Cannot load botserv bots table: mysql_use_result returned NULL\n"); return; } while ((row = mysql_fetch_row(result))) { strncpy(nick,row[0],NICKLEN); strncpy(ident,row[1],NICKLEN); strncpy(host,row[2],HOSTLEN); if (find_bot(nick)) continue; addBot(nick,ident,host); if (vv) printf("Bot %s added (%s@%s)\n",nick,ident,host); } mysql_query(&mysql,"SELECT * FROM child_botserv_chans"); if ((result = mysql_use_result(&mysql)) == NULL) { fprintf(stderr,"CRITICAL: Cannot load botserv chans table: mysql_use_result returned NULL\n"); return; } while ((row = mysql_fetch_row(result))) { strncpy(chan,row[0],CHANLEN); strncpy(nick,row[1],NICKLEN); if (find_chanbot(chan)) continue; if (!find_bot(nick)) continue; if (!find_channel(chan)) continue; addChanbot(chan,nick); if (vv) printf("Chanbot %s added with bot %s\n",chan,nick); } mysql_close(&mysql); }
/* Make first/last for oreg. */ static int make_firstlast( MergeInfo *inf, Overlapping *ovlap, Rect *oreg ) { REGION *rir = inf->rir; REGION *sir = inf->sir; Rect rr, sr; int x; int missing; /* We're going to build first/last ... lock it from other generate * threads. In fact it's harmless if we do get two writers, but we may * avoid duplicating work. */ g_mutex_lock( ovlap->fl_lock ); /* Do we already have first/last for this area? Bail out if we do. */ missing = 0; for( x = oreg->left; x < IM_RECT_RIGHT( oreg ); x++ ) { const int j = x - ovlap->overlap.left; const int first = ovlap->first[j]; if( first < 0 ) { missing = 1; break; } } if( !missing ) { /* No work to do! */ g_mutex_unlock( ovlap->fl_lock ); return( 0 ); } /* Entire height of overlap in ref for oreg ... we know oreg is inside * overlap. */ rr.left = oreg->left; rr.top = ovlap->overlap.top; rr.width = oreg->width; rr.height = ovlap->overlap.height; rr.left -= ovlap->rarea.left; rr.top -= ovlap->rarea.top; /* Same in sec. */ sr.left = oreg->left; sr.top = ovlap->overlap.top; sr.width = oreg->width; sr.height = ovlap->overlap.height; sr.left -= ovlap->sarea.left; sr.top -= ovlap->sarea.top; /* Make pixels. */ if( im_prepare( rir, &rr ) || im_prepare( sir, &sr ) ) { g_mutex_unlock( ovlap->fl_lock ); return( -1 ); } /* Make first/last cache. */ for( x = 0; x < oreg->width; x++ ) { const int j = (x + oreg->left) - ovlap->overlap.left; int *first = &ovlap->first[j]; int *last = &ovlap->last[j]; /* Done this line already? */ if( *first < 0 ) { /* Search for top/bottom of overlap on this scan-line. */ if( find_top( sir, first, x + sr.left, sr.top, sr.height ) || find_bot( rir, last, x + rr.left, rr.top, rr.height ) ) { g_mutex_unlock( ovlap->fl_lock ); return( -1 ); } /* Translate to output space. */ *first += ovlap->sarea.top; *last += ovlap->rarea.top; /* Clip to maximum blend width, if necessary. */ if( ovlap->mwidth >= 0 && *last - *first > ovlap->mwidth ) { int shrinkby = (*last - *first) - ovlap->mwidth; *first += shrinkby / 2; *last -= shrinkby / 2; } } } g_mutex_unlock( ovlap->fl_lock ); return( 0 ); }