int updatelastpost(const char *board) { int pos; pos = getbid(board,NULL); /* board name --> board No. */ if (pos > 0) { getlastpost(board, &brdshm->bstatus[pos - 1].lastpost, &brdshm->bstatus[pos - 1].total); return 0; } else return -1; }
int updatelastpost(char *board) { struct boardmem *bptr; if (shm_bcache == NULL) shm_init(); bptr = getbcache(board); if (bptr == NULL) return -1; return getlastpost(bptr->header.filename, &bptr->lastpost, &bptr->total); }
#include "DobHtmlParser.h" DobHtmlParser::DobHtmlParser () { doc = NULL; } DobHtmlParser::DobHtmlParser (QString *document, QString *data_xpath )/*{{{*/ { doc = NULL; setDoc ( document ); setXpath ( data_xpath ); }/*}}}*/ DobHtmlParser::~DobHtmlParser ()/*{{{*/ { if ( doc ) xmlFreeDoc( doc ); if ( xpath ) xmlFree(xpath); xmlCleanupParser (); }/*}}}*/ void DobHtmlParser::setDoc ( QString *document )/*{{{*/ { if ( doc ) xmlFreeDoc ( doc ); doc = htmlReadMemory ( document->toLatin1(), document->size(), "noname.html", NULL, 0 ); }/*}}}*/ void DobHtmlParser::setXpath ( QString *data_xpath )/*{{{*/ { QByteArray a = data_xpath->toLatin1(); xpath = xmlCharStrdup ( a.data() ); }/*}}}*/ QStringList DobHtmlParser::parse ()/*{{{*/ { getlastpost (); //qDebug() << list; return list; }/*}}}*/
void resolve_boards() { int boardfd=-1; int iscreate = 0; char errbuf[STRLEN]; if (bcache == NULL) { if ((boardfd = open(BOARDS, O_RDWR | O_CREAT, 0644)) == -1) { bbslog("3system", "Can't open " BOARDS "file %s", strerror_r(errno, errbuf, STRLEN)); exit(-1); } bcache = (struct boardheader *) mmap(NULL, MAXBOARD * sizeof(struct boardheader), PROT_READ, MAP_SHARED, boardfd, 0); if (bcache == (struct boardheader *) -1) { bbslog("4system", "Can't map " BOARDS "file %s", strerror_r(errno, errbuf, STRLEN)); close(boardfd); exit(-1); } } if (brdshm == NULL) { brdshm = attach_shm("BCACHE_SHMKEY", 3693, sizeof(*brdshm), &iscreate); /* attach board share memory */ if (iscreate) { int i, maxi = -1; int fd; bbslog("3system", "reload bcache!"); fd = bcache_lock(); for (i = 0; i < MAXBOARD; i++) if (bcache[i].filename[0]) { int count; char filename[MAXPATH]; struct fileheader lastfh; getlastpost(bcache[i].filename, &brdshm->bstatus[i].lastpost, &brdshm->bstatus[i].total); /* ulock: get nowid from the last fileheader and idseq*/ setbfile(filename,bcache[i].filename,DOT_DIR); count=get_num_records(filename,sizeof(struct fileheader)); if (count > 0) { get_record(filename, &lastfh, sizeof(struct fileheader), count-1); brdshm->bstatus[i].nowid=lastfh.id+1; if (bcache[i].idseq>lastfh.id+1) brdshm->bstatus[i].nowid=bcache[i].idseq; else brdshm->bstatus[i].nowid=lastfh.id+1; } else brdshm->bstatus[i].nowid=bcache[i].idseq; /* update top title */ board_update_toptitle(i+1,false); #ifdef RECORDMAXONLINE /* load board max online record */ brdshm->bstatus[i].maxonline = bcache[i].maxonline; brdshm->bstatus[i].maxtime = bcache[i].maxtime; #endif #ifdef TITLEKEYWORD load_title_key(1, i+1, bcache[i].filename); #endif maxi = i; } if (maxi != -1) brdshm->numboards = maxi + 1; bcache_unlock(fd); } } if (bdirshm == NULL) { bdirshm = attach_shm("BDIRCACHE_SHMKEY", 3697, sizeof(*bdirshm), &iscreate); /* attach board share memory */ if (iscreate) { bbslog("3system", "reload bdircache!"); load_allboard(bdirshm->allbrd_list, &bdirshm->allbrd_list_t); load_wwwboard(bdirshm->wwwbrd_list, &bdirshm->wwwbrd_list_t); } } if (boardfd!=-1) close(boardfd); }