void query_del_by_conn( irc_t *irc, struct im_connection *ic ) { query_t *q, *n, *def; int count = 0; q = irc->queries; def = query_default( irc ); while( q ) { if( q->ic == ic ) { n = q->next; query_del( irc, q ); q = n; count ++; } else { q = q->next; } } if( count > 0 ) imcb_log( ic, "Flushed %d unanswered question(s) for this connection.", count ); q = query_default( irc ); if( q && q != def ) query_display( irc, q ); }
/* So it turns out some requests have no account context at all, because * libpurple hates us. This means that query_del_by_conn() won't remove those * on logout, and will segfault if the user replies. That's why this exists. */ static void prplcb_close_request(PurpleRequestType type, void *data) { struct prplcb_request_action_data *pqad; struct request_input_data *ri; struct purple_data *pd; if (!data) { return; } switch (type) { case PURPLE_REQUEST_ACTION: pqad = data; /* if this is null, it's because query_del was run already */ if (pqad->bee_data) { query_del(local_bee->ui_data, pqad->bee_data); } g_free(pqad); break; case PURPLE_REQUEST_INPUT: ri = data; pd = ri->ic->proto_data; imcb_remove_buddy(ri->ic, ri->buddy, NULL); g_free(ri->buddy); g_hash_table_remove(pd->input_requests, GUINT_TO_POINTER(ri->id)); break; default: g_free(data); break; } }
void query_answer( irc_t *irc, query_t *q, int ans ) { int disp = 0; if( !q ) { q = query_default( irc ); disp = 1; } if( ans ) { if( q->ic ) imcb_log( q->ic, "Accepted: %s", q->question ); else irc_usermsg( irc, "Accepted: %s", q->question ); q->yes( q->data ); } else { if( q->ic ) imcb_log( q->ic, "Rejected: %s", q->question ); else irc_usermsg( irc, "Rejected: %s", q->question ); q->no( q->data ); } q->data = NULL; query_del( irc, q ); if( disp && ( q = query_default( irc ) ) ) query_display( irc, q ); }
TF EXPFUNC p_db_freeq(ENGid eid) { QUERY* pq; g_lsRC = lsGetParm(eid, 1, cADDR, &pq); if (g_lsRC != OK) goto LS_ERROR; query_del(pq); return TRUE; LS_ERROR: return(lserror()); }
void query_delall() { QUERY* pq; int i=0; //char mess[20]; //DUMPLOG("query_delall begin"); //messout("query_delall begin"); pq = QList; while (pq != NULL) { // printf("deleting all query %p\n", pq); query_del(pq); pq = QList; i++; } //sprintf(mess, "Deleted %d queries", i); //messout(mess); //DUMPLOG("query_delall end"); }
void irc_free(irc_t * irc) { GSList *l; irc->status |= USTATUS_SHUTDOWN; log_message(LOGLVL_INFO, "Destroying connection with fd %d", irc->fd); if (irc->status & USTATUS_IDENTIFIED && set_getbool(&irc->b->set, "save_on_quit")) { if (storage_save(irc, NULL, TRUE) != STORAGE_OK) { log_message(LOGLVL_WARNING, "Error while saving settings for user %s", irc->user->nick); } } for (l = irc_plugins; l; l = l->next) { irc_plugin_t *p = l->data; if (p->irc_free) { p->irc_free(irc); } } irc_connection_list = g_slist_remove(irc_connection_list, irc); while (irc->queries != NULL) { query_del(irc, irc->queries); } /* This is a little bit messy: bee_free() frees all b->users which calls us back to free the corresponding irc->users. So do this before we clear the remaining ones ourselves. */ bee_free(irc->b); while (irc->users) { irc_user_free(irc, (irc_user_t *) irc->users->data); } while (irc->channels) { irc_channel_free(irc->channels->data); } if (irc->ping_source_id > 0) { b_event_remove(irc->ping_source_id); } if (irc->r_watch_source_id > 0) { b_event_remove(irc->r_watch_source_id); } if (irc->w_watch_source_id > 0) { b_event_remove(irc->w_watch_source_id); } closesocket(irc->fd); irc->fd = -1; g_hash_table_foreach_remove(irc->nick_user_hash, irc_free_hashkey, NULL); g_hash_table_destroy(irc->nick_user_hash); g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL); g_hash_table_destroy(irc->watches); if (irc->iconv != (GIConv) - 1) { g_iconv_close(irc->iconv); } if (irc->oconv != (GIConv) - 1) { g_iconv_close(irc->oconv); } g_free(irc->sendbuffer); g_free(irc->readbuffer); g_free(irc->password); g_free(irc); if (global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON || (global.conf->runmode == RUNMODE_DAEMON && global.listen_socket == -1 && irc_connection_list == NULL)) { b_main_quit(); } }
TF EXPFUNC p_db_fetch(ENGid eid) { QUERY* pq; HSTMT hstmt; TERM tcols; TERM t; COL* pCol; #ifdef _DEBUG TERM xt1, xt2; char xbuf1[512], xbuf2[512]; #endif if (pVAR != lsGetParmType(eid, 2)) { lsErrRaise(eid, "db_fetch instantiation error: arg 2 must be var"); return FALSE; } g_lsRC = lsGetParm(eid, 1, cADDR, &pq); if (g_lsRC != OK) goto LS_ERROR; hstmt = pq->hstmt; /* set up error handler */ g_hSTMT = hstmt; g_eid = eid; if ( SQL_NO_DATA_FOUND == (g_RC = SQLFetch(hstmt)) ) { DUMPLOG("no data found"); query_del(pq); return FALSE; } ERROR_CHK("SQLFetch"); DUMPLOG("found data"); g_lsRC = lsMakeList(eid, &tcols); if (g_lsRC != OK) goto LS_ERROR; for (pCol = pq->clist; pCol != NULL; pCol = pCol->next) { switch(pCol->pdtype) { case pdATOM: g_lsRC = lsMakeAtom(eid, &t, pCol->s); if (g_lsRC != OK) goto LS_ERROR; break; case pdSTR: g_lsRC = lsMakeStr(eid, &t, pCol->s); if (g_lsRC != OK) goto LS_ERROR; break; case pdINT: g_lsRC = lsMakeInt(eid, &t, pCol->i); if (g_lsRC != OK) goto LS_ERROR; break; case pdFLOAT: g_lsRC = lsMakeFloat(eid, &t, pCol->f); if (g_lsRC != OK) goto LS_ERROR; break; case pdDOUBLE: g_lsRC = lsMakeFloat(eid, &t, pCol->g); if (g_lsRC != OK) goto LS_ERROR; break; case pdDATE: g_lsRC = lsMakeFA(eid, &t, "date", 3); if (g_lsRC != OK) goto LS_ERROR; lsUnifyArg(eid, &t, 1, cSHORT, &(pCol->d->year)); lsUnifyArg(eid, &t, 2, cSHORT, &(pCol->d->month)); lsUnifyArg(eid, &t, 3, cSHORT, &(pCol->d->day)); break; case pdTIME: g_lsRC = lsMakeFA(eid, &t, "time", 3); if (g_lsRC != OK) goto LS_ERROR; lsUnifyArg(eid, &t, 1, cSHORT, &(pCol->t->hour)); lsUnifyArg(eid, &t, 2, cSHORT, &(pCol->t->minute)); lsUnifyArg(eid, &t, 3, cSHORT, &(pCol->t->second)); break; default: messout("Unsupported Prolog type for ODBC fetch"); } g_lsRC = lsPushList(eid, &tcols, t); if (g_lsRC != OK) return(lserror()); } /* #ifdef _DEBUG lsGetParm(eid, 2, cTERM, &xt1); lsTermToStrQ(eid, xt1, xbuf1, 500); lsTermToStrQ(eid, xt2, xbuf2, 500); #endif */ lsUnifyParm(eid, 2, cTERM, &tcols); return TRUE; LS_ERROR: return(lserror()); ODBC_ERROR: return FALSE; }