Back to index

citadel  8.12
Classes | Defines | Typedefs | Functions
rss_atom_parser.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  __rss_xml_handler
struct  rss_item
struct  rss_room_counter
struct  __networker_save_message
struct  rss_aggregator

Defines

#define RSS_UNSET   (1<<0)
#define RSS_RSS   (1<<1)
#define RSS_ATOM   (1<<2)
#define RSS_REQUIRE_BUF   (1<<3)

Typedefs

typedef struct rss_aggregator
typedef struct rss_item
typedef struct rss_room_counter
typedef void(* rss_handler_func )(StrBuf *CData, rss_item *ri, rss_aggregator *Cfg, const char **Attr)
typedef struct __rss_xml_handler rss_xml_handler
typedef struct
__networker_save_message 
networker_save_message

Functions

void flush_rss_item (rss_item *ri)
eNextState RSSAggregator_ParseReply (AsyncIO *IO)
eNextState RSS_FetchNetworkUsetableEntry (AsyncIO *IO)

Class Documentation

struct __rss_xml_handler

Definition at line 37 of file rss_atom_parser.h.

Collaboration diagram for __rss_xml_handler:
Class Members
int Flags
rss_handler_func Handler
struct rss_item

Definition at line 42 of file rss_atom_parser.h.

Class Members
StrBuf * author_email
StrBuf * author_or_creator
StrBuf * author_url
StrBuf * channel_title
StrBuf * description
int done_parsing
StrBuf * guid
int item_tag_nesting
StrBuf * link
StrBuf * linkTitle
time_t pubdate
StrBuf * reLink
StrBuf * reLinkTitle
StrBuf * title
struct rss_room_counter

Definition at line 60 of file rss_atom_parser.h.

Class Members
int count
long QRnumber
struct __networker_save_message

Definition at line 65 of file rss_atom_parser.h.

Class Members
StrBuf * Message
StrBuf * MsgGUID
struct rss_aggregator

Definition at line 72 of file rss_atom_parser.h.

Collaboration diagram for rss_aggregator:
Class Members
StrBuf * CData
AsyncIO IO
rss_item * Item
int ItemType
StrBuf * Key
time_t last_error_when
HashList * Messages
time_t next_poll
HashList * OtherQRnumbers
HashPos * Pos
long QRnumber
int roomlist_parts
StrBuf * rooms
networker_save_message * ThisMsg
StrBuf * Url
XML_Parser xp

Define Documentation

#define RSS_ATOM   (1<<2)

Definition at line 24 of file rss_atom_parser.h.

#define RSS_REQUIRE_BUF   (1<<3)

Definition at line 25 of file rss_atom_parser.h.

#define RSS_RSS   (1<<1)

Definition at line 23 of file rss_atom_parser.h.

#define RSS_UNSET   (1<<0)

Definition at line 22 of file rss_atom_parser.h.


Typedef Documentation

typedef struct rss_aggregator

Definition at line 27 of file rss_atom_parser.h.

typedef void(* rss_handler_func)(StrBuf *CData, rss_item *ri, rss_aggregator *Cfg, const char **Attr)

Definition at line 31 of file rss_atom_parser.h.

typedef struct rss_item

Definition at line 28 of file rss_atom_parser.h.

typedef struct rss_room_counter

Definition at line 29 of file rss_atom_parser.h.


Function Documentation

void flush_rss_item ( rss_item ri)

Definition at line 127 of file rss_atom_parser.c.

{
       /* Initialize the feed item data structure */
       FreeStrBuf(&ri->guid);
       FreeStrBuf(&ri->title);
       FreeStrBuf(&ri->link);
       FreeStrBuf(&ri->author_or_creator);
       FreeStrBuf(&ri->author_email);
       FreeStrBuf(&ri->author_url);
       FreeStrBuf(&ri->description);

       FreeStrBuf(&ri->linkTitle);
       FreeStrBuf(&ri->reLink);
       FreeStrBuf(&ri->reLinkTitle);
       FreeStrBuf(&ri->channel_title);
}

Here is the caller graph for this function:

TODO

Definition at line 258 of file serv_rssclient.c.

{
       const char *Key;
       long len;
       struct cdbdata *cdbut;
       rss_aggregator *Ctx = (rss_aggregator *) IO->Data;

       /* Find out if we've already seen this item */
       strcpy(Ctx->ThisMsg->ut.ut_msgid,
              ChrPtr(Ctx->ThisMsg->MsgGUID)); 
       Ctx->ThisMsg->ut.ut_timestamp = time(NULL);

       cdbut = cdb_fetch(CDB_USETABLE, SKEY(Ctx->ThisMsg->MsgGUID));
#ifndef DEBUG_RSS
       if (cdbut != NULL) {
              /* Item has already been seen */
              EVRSSC_syslog(LOG_DEBUG,
                       "%s has already been seen\n",
                       ChrPtr(Ctx->ThisMsg->MsgGUID));
              cdb_free(cdbut);

              /* rewrite the record anyway, to update the timestamp */
              cdb_store(CDB_USETABLE,
                       SKEY(Ctx->ThisMsg->MsgGUID),
                       &Ctx->ThisMsg->ut, sizeof(struct UseTable) );

              if (GetNextHashPos(Ctx->Messages,
                               Ctx->Pos,
                               &len, &Key,
                               (void**) &Ctx->ThisMsg))
                     return NextDBOperation(
                            IO,
                            RSS_FetchNetworkUsetableEntry);
              else
                     return eAbort;
       }
       else
#endif
       {
              NextDBOperation(IO, RSSSaveMessage);
              return eSendMore;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 959 of file rss_atom_parser.c.

{
       StrBuf *Buf;
       rss_aggregator *RSSAggr;
       rss_item *ri;
       const char *at;
       char *ptr;
       long len;
       const char *Key;


       if (IO->HttpReq.httpcode != 200)
       {

              EVRSSATOM_syslog(LOG_ALERT, "need a 200, got a %ld !\n",
                             IO->HttpReq.httpcode);
// TODO: aide error message with rate limit
              return eAbort;
       }

       RSSAggr = IO->Data;
       ri = RSSAggr->Item;
       RSSAggr->CData = NewStrBufPlain(NULL, SIZ);
       RSSAggr->Key = NewStrBuf();
       at = NULL;
       StrBufSipLine(RSSAggr->Key, IO->HttpReq.ReplyData, &at);
       ptr = NULL;

#define encoding "encoding=\""
       ptr = strstr(ChrPtr(RSSAggr->Key), encoding);
       if (ptr != NULL)
       {
              char *pche;

              ptr += sizeof (encoding) - 1;
              pche = strchr(ptr, '"');
              if (pche != NULL)
                     StrBufCutAt(RSSAggr->Key, -1, pche);
              else
                     ptr = "UTF-8";
       }
       else
              ptr = "UTF-8";

       EVRSSATOM_syslog(LOG_DEBUG, "RSS: Now parsing [%s] \n", ChrPtr(RSSAggr->Url));

       RSSAggr->xp = XML_ParserCreateNS(ptr, ':');
       if (!RSSAggr->xp) {
              EVRSSATOMM_syslog(LOG_ALERT, "Cannot create XML parser!\n");
              return eAbort;
       }
       FlushStrBuf(RSSAggr->Key);

       RSSAggr->Messages = NewHash(1, Flathash);
       XML_SetElementHandler(RSSAggr->xp, rss_xml_start, rss_xml_end);
       XML_SetCharacterDataHandler(RSSAggr->xp, rss_xml_chardata);
       XML_SetUserData(RSSAggr->xp, RSSAggr);
       XML_SetCdataSectionHandler(RSSAggr->xp,
                               rss_xml_cdata_start,
                               rss_xml_cdata_end);


       len = StrLength(IO->HttpReq.ReplyData);
       ptr = SmashStrBuf(&IO->HttpReq.ReplyData);
       XML_Parse(RSSAggr->xp, ptr, len, 0);
       free (ptr);
       if (ri->done_parsing == 0)
              XML_Parse(RSSAggr->xp, "", 0, 1);


       EVRSSATOM_syslog(LOG_DEBUG, "RSS: XML Status [%s] \n",
                      XML_ErrorString(XML_GetErrorCode(RSSAggr->xp)));

       XML_ParserFree(RSSAggr->xp);
       flush_rss_item(ri);

       Buf = NewStrBufDup(RSSAggr->rooms);
       RSSAggr->recp.recp_room = SmashStrBuf(&Buf);
       RSSAggr->recp.num_room = RSSAggr->roomlist_parts;
       RSSAggr->recp.recptypes_magic = RECPTYPES_MAGIC;

       RSSAggr->Pos = GetNewHashPos(RSSAggr->Messages, 1);

//RSSAggr->next_poll = time(NULL) + config.c_net_freq;
       if (GetNextHashPos(RSSAggr->Messages,
                        RSSAggr->Pos,
                        &len,
                        &Key,
                        (void**) &RSSAggr->ThisMsg))
              return QueueDBOperation(IO, RSS_FetchNetworkUsetableEntry);
       else
              return eAbort;
}

Here is the call graph for this function:

Here is the caller graph for this function: