Пример #1
0
void NewsArticle::assemble()
{
    Headers::Base *h;
    QCString newHead = "";

    //Message-ID
    if((h = messageID(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Control
    if((h = control(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Supersedes
    if((h = supersedes(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //From
    h = from(); // "From" is mandatory
    newHead += h->as7BitString() + "\n";

    //Subject
    h = subject(); // "Subject" is mandatory
    newHead += h->as7BitString() + "\n";

    //To
    if((h = to(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Newsgroups
    if((h = newsgroups(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Followup-To
    if((h = followUpTo(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Reply-To
    if((h = replyTo(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Mail-Copies-To
    if((h = mailCopiesTo(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Date
    h = date(); // "Date" is mandatory
    newHead += h->as7BitString() + "\n";

    //References
    if((h = references(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Lines
    h = lines(); // "Lines" is mandatory
    newHead += h->as7BitString() + "\n";

    //Organization
    if((h = organization(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //User-Agent
    if((h = userAgent(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Mime-Version
    newHead += "MIME-Version: 1.0\n";

    //Content-Type
    newHead += contentType()->as7BitString() + "\n";

    //Content-Transfer-Encoding
    newHead += contentTransferEncoding()->as7BitString() + "\n";

    //X-Headers
    int pos = h_ead.find("\nX-");
    if(pos > -1) //we already have some x-headers => "recycle" them
        newHead += h_ead.mid(pos + 1, h_ead.length() - pos);
    else if(h_eaders && !h_eaders->isEmpty())
    {
        for(h = h_eaders->first(); h; h = h_eaders->next())
        {
            if(h->isXHeader() && (strncasecmp(h->type(), "X-KNode", 7) != 0))
                newHead += h->as7BitString() + "\n";
        }
    }

    h_ead = newHead;
}
Пример #2
0
KWBoolean check_sys(NEWS_SYS *entry, char *groups, char *distrib, char *path)
{

    printmsg(5, "check_sys: node: %s", entry->sysname);
    printmsg(5, "check_sys: groups: %s", groups);
    printmsg(5, "check_sys: distrib: %s", distrib);
    printmsg(5, "check_sys: path: %s", path);

    /*--------------------------------------------------------------------*/
    /*       Through out this processing, we keep the copies of the       */
    /*       strings used for this system clean by copying them before    */
    /*       passing them to the routines which want to tokenize them.    */
    /*--------------------------------------------------------------------*/

    /*--------------------------------------------------------------------*/
    /*       Never send a post from where it came                         */
    /*--------------------------------------------------------------------*/

    if (excluded(strcpy( cache, entry->sysname ), path))
        return KWFalse;

    /*--------------------------------------------------------------------*/
    /*       Never send to a post to a system which explicitly listed     */
    /*       in the system exclusion list (normally because it's an       */
    /*       alias of the system name we know the system by.              */
    /*--------------------------------------------------------------------*/

    if (entry->exclude )
    {
        printmsg(3, "check_sys: checking exclusions");
        if (excluded(strcpy( cache, entry->exclude ), path))
            return KWFalse;
    }

    /*--------------------------------------------------------------------*/
    /*       Determine if the message has gone too hops to be forwarded   */
    /*--------------------------------------------------------------------*/

    if ( (entry->maximumHops < USHRT_MAX) &&
            (hops( path ) > entry->maximumHops ))
    {
        printmsg(3, "check_sys: Too many hops to be accepted" );
        return KWFalse;
    }

    /*--------------------------------------------------------------------*/
    /*        Determine if we accept the distribution for this system     */
    /*--------------------------------------------------------------------*/

    if (entry->distribution)
    {
        printmsg(3, "check_sys: checking distributions");
        if (!distributions(strcpy( cache, entry->distribution ), distrib))
            return KWFalse;
    }

    /*--------------------------------------------------------------------*/
    /*            Determine if the remote system wants this group         */
    /*--------------------------------------------------------------------*/

    if (entry->groups)
    {
        printmsg(3, "check_sys: checking groups");
        if (!newsgroups(strcpy( cache, entry->groups ), groups))
            return KWFalse;
    }

    /*--------------------------------------------------------------------*/
    /*       The article passed our filters, report acceptance to caller  */
    /*--------------------------------------------------------------------*/

    return KWTrue;

} /* check_sys */