 o-lh0-    Lr$  
compiler.h/u/*
**      $VER: compiler.h 37.31 (18.3.98)
**
**      Compiler independent register (and SAS/C extensions) handling
**
**      (C) Copyright 1997-98 Andreas R. Kleinert
**      All Rights Reserved.
*/

#ifndef COMPILER_H
#define COMPILER_H

 /* ============================================================
    There have been problems how to define the seglist pointer
    under AROS, AmigaOS or elsewhere in a unique (and still
    working!) way. It seems to make sense to use a new, global
    type definition for it. This is done here. */

#ifndef _AROS
# ifdef VBCC
#  define SEGLISTPTR APTR
# else /* !VBCC */
#  include <dos/dos.h>
#  define SEGLISTPTR BPTR
# endif /* VBCC */
#else /* !_AROS */
  typedef struct SegList * SEGLISTPTR;
#endif /* _AROS */

 /* ============================================================ */

/* Basically, Amiga C compilers must try to reach the goal to be
   as SAS/C compatible as possible. But on the other hand,
   when porting AmigaOS to other platforms, one perhaps
   can't expect GCC becoming fully SAS/C compatible...

   There are two ways to make your sources portable:

    - using non ANSI SAS/C statements and making these
      "available" to the other compilers (re- or undefining)
    - using replacements for SAS/C statements and smartly
      redefining these for any compiler

   The last mentioned is the most elegant, but may require to
   rewrite your source codes, so this compiler include file
   basically does offer both.

   For some compilers, this may have been done fromout project or
   makefiles for the first method (e.g. StormC) to ensure compileablity.

   Basically, you should include this header file BEFORE any other stuff.
*/

/* ********************************************************************* */
/* Method 1: redefining SAS/C keywords                                   */
/*                                                                       */
/* Sorry, this method does not work with register definitions for the current
gcc version (V2.7.2.1), as it expects register attributes after the parameter
description. (This is announced to be fixed with gcc V2.8.0).
Moreover the __asm keyword has another meaning with GCC.
Therefore ASM must be used. */

#ifdef __MAXON__  // ignore this switches of SAS/Storm
#define __aligned
#define __asm
#define __regargs
#define __saveds
#define __stdargs
#endif

#ifdef __GNUC__  // ignore this switches of SAS/Storm
#define __d0
#define __d1
#define __d2
#define __d3
#define __d4
#define __d5
#define __d6
#define __d7
#define __a0
#define __a1
#define __a2
#define __a3
#define __a4
#define __a5
#define __a6
#define __a7
#endif

#ifdef VBCC
#define __d0 __reg("d0")
#define __d1 __reg("d1")
#define __d2 __reg("d2")
#define __d3 __reg("d3")
#define __d4 __reg("d4")
#define __d5 __reg("d5")
#define __d6 __reg("d6")
#define __d7 __reg("d7")
#define __a0 __reg("a0")
#define __a1 __reg("a1")
#define __a2 __reg("a2")
#define __a3 __reg("a3")
#define __a4 __reg("a4")
#define __a5 __reg("a5")
#define __a6 __reg("a6")
#define __a7 __reg("a7")
#endif

 /* for SAS/C we don't need this, for StormC this is done in the
    makefile or projectfile */

/*                                                                       */
/* ********************************************************************* */


/* ********************************************************************* */
/* Method 2: defining our own keywords                                   */
/*                                                                       */
#ifdef __SASC

#  define REG(r)     register __ ## r
#  define GNUCREG(r)
#  define SAVEDS     __saveds
#  define ASM        __asm
#  define REGARGS    __regargs
#  define STDARGS    __stdargs
#  define ALIGNED    __aligned

#else
# ifdef __MAXON__

#  define REG(r)    register __ ## r
#  define GNUCREG(r)
#  define SAVEDS
#  define ASM
#  define REGARGS
#  define STDARGS
#  define ALIGNED

# else
#  ifdef __STORM__

#   define REG(r)  register __ ## r
#   define GNUCREG(r)
#   define SAVEDS  __saveds
#   define ASM
#   define REGARGS
#   define STDARGS
#   define ALIGNED

#  else
#   ifdef __GNUC__

#    define REG(r)
#    define GNUCREG(r)  __asm( #r )
#    define SAVEDS  __saveds
#    define ASM
#    define REGARGS __regargs
#    define STDARGS __stdargs
#    define ALIGNED __aligned

#   else
#    ifdef VBCC
/* VBCC ignore this switch */
#     define __aligned
#     define __asm
#     define __regargs
#     define __saveds
#     define __stdargs
#     define __register
#     define GNUCREG(r)
#     define REG(r)
#     define SAVEDS
#     define ASM
#     define REGARGS
#     define STDARGS
#     define ALIGNED

#    else
#     ifdef _DCC
#      define __aligned
#      define __stdargs
#      define GNUCREG(r)
#      define ASM

#     else  /* any other compiler, to be added here */

#      define REG(r)
#      define GNUCREG(r)
#      define SAVEDS
#      define ASM
#      define REGARGS
#      define STDARGS
#      define ALIGNED

#     endif /*   _DCC      */
#    endif /*   VBCC      */
#   endif /*  __GNUC__   */
#  endif /*  __STORM__  */
# endif /*  __MAXON__  */
#endif /*  __SASC     */
/*                                                                       */
/* ********************************************************************* */

#endif /* COMPILER_H */
-lh0-    Tw&B config.hC
#ifndef CONFIG_H
#define CONFIG_H

/*
** Poniezj sa definicje funkcji/struktur do operacji na plikach
** konfiguracyjnych, pliki te moga sluzyc do zapamietywania jakis
** zmiennych itp. wartosci, pliki wygladaja tak:
**
** SNazwa1 = wartosc1  // oznacza, ze pole Nazwa1 ma argument jako string
** NNazwa2 = wartosc2  // Nazwa2 wa argument jako liczba (long)
**
*/

/* Simple Config (tm ;) definitions */

struct ConfigNode
{
    struct ConfigNode *cn_Next;
    struct ConfigNode *cn_Prev;
    char              *cn_Name;
    char              *cn_SValue;
    long               cn_NValue;
};

struct SimpleConfig
{
    BPTR   sc_File;
    char  *sc_FileName;

    struct List *sc_Entries;
};

/*
** stworz nowy SimpleConfig
** name - nazwa pliku
*/
extern struct SimpleConfig *cfg_create_simpleconfig(char *name);

extern struct SimpleConfig *cfg_open_simpleconfig(char *name);

/*
** dodaj nowe pole typu string
*/
extern int cfg_add_string_entry(struct SimpleConfig *cfg, char *name, char *value);

/*
** dodaj nowe pole typu number
*/
extern int cfg_add_number_entry(struct SimpleConfig *cfg, char *name, long value);

/*
** zmodyfikuj pole typu string
*/
extern int cfg_mod_number_entry(struct SimpleConfig *cfg, char *name, long value);

/*
** zmodyfikuj pole typu number
*/
extern int cfg_mod_string_entry(struct SimpleConfig *cfg, char *name, char *value);

/*
** usun pole
** name - szukaj wg. nazwy
** num  - wedlug pola ('name' musi byc wtedy NULL)
*/
extern int cfg_rem_entry(struct SimpleConfig *cfg, char *name, long num);

/*
** pobierz wartosc pole typu number
*/
extern long cfg_get_number_entry(struct SimpleConfig *cfg, char *name);

/*
** pobierz wartosc pola typu string
*/
extern char *cfg_get_string_entry(struct SimpleConfig *cfg, char *name);

/*
** zapisz SimpleConfig
*/
extern void cfg_save_simpleconfig(struct SimpleConfig *sc);

/*
** zwolnij pamiec po SimpleConfig
*/
extern void cfg_free_simpleconfig(struct SimpleConfig *sc);

#endif
$-lh0-$  $  u& FlushHeaders.c/*
** $Log$
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/rexxsyslib.h>

#include <rexx/rxslib.h>
#include <rexx/rexxio.h>
#include <rexx/errors.h>

#include <dos/dos.h>
#include <exec/memory.h>
#include <utility/tagitem.h>

#include "get_folder_path.h"

int __stack = 12000;

struct NewsNode
{
    struct NewsNode *next;
    struct NewsNode *prev;
    struct List *domains;
    char *ngname;
    char *path;
    long last;
    long maxlen;
    long maxmsg;
    char folder[40];
    char update;
};

#ifndef __GNUC__
struct Library        *RexxSysBase = NULL;
#else
struct RxsLib         *RexxSysBase = NULL;
#endif

struct List *newsgroupslist=0;
struct List   *folders;

void        *listpool=0;

char buf[1000];

char *stristr(char *buf, char *str)
{
    register int len = strlen(buf);
    register int len2 = strlen(str);
    register int a;

    for(a = 0; a <= len - len2; a++)
        if(strnicmp(&buf[a], str, len2) == 0)
            return(&buf[a]);
    return(0);
}

int LoadConfig(void)
{
    BPTR fh;
    char *tmp;

    fh=Open("YAM:Yam2NN.config", MODE_OLDFILE);

    while(FGets(fh, buf, 200))
    {
        if(strlen(buf) < 2)
            break;

        if(buf[0] == ';')
            continue;

        if(!(strnicmp(buf, "Newsgroups:", 11)))
        {
            struct NewsNode *newsnode;

            if(!newsgroupslist)
            {
                newsgroupslist = LibAllocPooled(listpool, sizeof(struct List));
                NewList(newsgroupslist);
            }

            newsnode = LibAllocPooled(listpool, sizeof(struct NewsNode));

            newsnode->domains = LibAllocPooled(listpool, sizeof(struct List));
            NewList(newsnode->domains);
            newsnode->update = FALSE;

            tmp=strtok(buf + 12, " ");
            newsnode->ngname = LibAllocPooled(listpool, strlen(tmp) + 1);
            strcpy(newsnode->ngname, tmp);

            tmp=strtok(NULL, " \n");
            if(!tmp)
                return(FALSE);

            newsnode->path = LibAllocPooled(listpool, strlen(tmp)+  1);
            strcpy(newsnode->path, tmp);

            {
                int a, b;

                a = strlen(tmp);
                if(tmp[a - 1] == '/')
                    tmp[a - 1] = 0;
                while(tmp[a] != '/' && tmp[a] != ':' && a > 0)
                    a--;

                strcpy(newsnode->folder, &tmp[a + 1]);
            }

            FGets(fh, buf, 200);
            newsnode->maxlen = atol(&buf[13]);

            FGets(fh, buf, 200);
            newsnode->maxmsg = atol(&buf[15]);

            while(1)
            {
                struct Node *node;

                if(!(FGets(fh, buf, 200)))
                    break;

                if(strnicmp(buf, "\n", 1)==0)
                    break;
            }

            AddTail(newsgroupslist, newsnode);
        }
    }
    Close(fh);
    return(TRUE);
}

// this function was written by Christian Hattemer <Chris@heaven.riednet.wh.tu-darmstadt.de>

long SendRexxCommand(char *Port, char *Cmd, struct MsgPort *ReplyPort, char *Result)
{
   ULONG Error;
   struct MsgPort *RexxPort;

   Forbid();

   if (RexxPort = FindPort(Port))
   {
      struct RexxMsg *rexxMsg, *Answer;

      if (rexxMsg = CreateRexxMsg(ReplyPort, NULL, NULL))
      {
         if (rexxMsg->rm_Args[0] = CreateArgstring(Cmd, strlen(Cmd)))
         {
            rexxMsg->rm_Action = RXCOMM | RXFF_RESULT;

            PutMsg(RexxPort, &rexxMsg->rm_Node);

            do
            {
               WaitPort(ReplyPort);
               Answer = (struct RexxMsg *)GetMsg(ReplyPort);
            } while (Answer == NULL);

            Permit();

            if ((Error = Answer->rm_Result1) == RC_OK)
            {
               if (Answer->rm_Result2)
               {
                  strcpy(Result, (STRPTR)Answer->rm_Result2);
                  DeleteArgstring((UBYTE *)Answer->rm_Result2);
               }
            }

            DeleteArgstring((UBYTE *)ARG0(Answer));
            DeleteRexxMsg(Answer);

            return Error;
         }
         else
            DeleteRexxMsg(rexxMsg);
      }
   }

   Permit();

   return RC_FATAL;
}

int FindOldHeader(char *in, char *out, char *header)
{
    int n = 0, i = 0;
    char *h;
    BOOL end=FALSE;

    h = strstr(in, header);

    if(h)
    {
        while(h[n] != ':')
            n++;

        n += 2;

        while(!end)
        {
            while(h[n] != 10)
                out[i++] = h[n++];

            if(h[n-1] != ',')
                end = TRUE;
            else
            {
                while(isspace(h[n++])) ;
                n--;
            }
        }

        out[i]=0;
        return(TRUE);
    }
    return(FALSE);
}

void GetFolderName(char *folder, char *path)
{
    char fconfig[108];
    BPTR fh;

    strcpy(fconfig, path);
    AddPart(fconfig, ".fconfig", 108);
    fh=Open(fconfig, MODE_OLDFILE);

    while(FGets(fh, fconfig, 108))
    {
        if(strnicmp("name", fconfig, 4)==0)
        {
            int a=0, b=0;

            while(fconfig[a++]!='=') ;

            a++;
            while(isspace(fconfig[a++])) ;

            a--;
            while(fconfig[a]!=10)
                folder[b++]=fconfig[a++];

            folder[b]=0;
            break;
        }
    }
    Close(fh);
}

void update_folder(void)
{
    struct MsgPort *ARexxPort;
    char tmp[100];

    ARexxPort = CreateMsgPort();
    if(!ARexxPort)
        return;

    sprintf(buf, "SETFOLDER %d", get_folder_pos(folders, DELETED));
    SendRexxCommand("YAM", buf, ARexxPort, tmp);

    SendRexxCommand("YAM", "MAILUPDATE", ARexxPort, tmp);

    sprintf(buf, "SETFOLDER %d", ((struct Folder *)folders->lh_Head)->f_num);
    SendRexxCommand("YAM", buf, ARexxPort, tmp);


    DeleteMsgPort(ARexxPort);
}

int main(int argc, char *argv[])
{
    struct FileInfoBlock *fib;
    BPTR lock, fh, oldlock;
    char *msg = 0, tmp[108], path[108];

    RexxSysBase = OpenLibrary("rexxsyslib.library", 0);
    if(!RexxSysBase)
        return(20);

    query_for_user();

    folders = init_folder_list();

    strcpy(path, current_user_path);
    strcpy(tmp, get_folder_path(folders, DELETED));

    AddPart(path, tmp, sizeof(path));

    strcpy(buf, path);
    AddPart(buf, ".fconfig", sizeof(buf));

    lock = Lock(buf, ACCESS_READ);
    if(!lock)
        exit(20);

    UnLock(lock);

    if(!(listpool = LibCreatePool(MEMF_ANY | MEMF_CLEAR, 4096, 4096)))
        exit(20);

    fib = AllocDosObject(DOS_FIB, TAG_DONE);

    if(!(LoadConfig()))
        exit(20);

    lock = Lock(path, ACCESS_READ);
    if(!lock)
        exit(20);
    oldlock = CurrentDir(lock);

    Examine(lock, fib);

    while(ExNext(lock, fib))
    {
        if(fib->fib_EntryType < -2)
        {
            if(stricmp(fib->fib_FileName, ".fconfig") && stricmp(fib->fib_FileName, ".index"))
            {
                char header[60];

                fh = Open(fib->fib_FileName, MODE_OLDFILE);
                msg = AllocVec(fib->fib_Size, MEMF_ANY | MEMF_CLEAR);
                Read(fh, msg, fib->fib_Size);

                if(FindOldHeader(msg, header, "Message-ID:"))
                {
                    if(FindOldHeader(msg, tmp, "Newsgroups:"))
                    {
                        BPTR fh2;
                        char name[108], *p, *nextname;
                        struct NewsNode *nn = (struct NewsNode *)newsgroupslist->lh_Head;

                        nextname = strtok(tmp, ",");
                        while(nextname)
                        {
                            char folder[108];

                            strcpy(name, "YAM:NNTP-Headers/");

                            while(nn->next)
                            {
                                if(stricmp(nn->ngname, nextname) == 0)
                                    break;
                                nn = nn->next;
                            }

                            GetFolderName(folder, nn->path);
                            strcat(name, folder);

                            header[0] = 'p';
                            if(strlen(header) <= 30)
                            {
                                p = strchr(header, '>');
                                if(p)
                                    *p = 0;
                            }
                            else
                                header[30] = 0;

                            AddPart(name, header, sizeof(name));
                            fh2 = Open(name, MODE_OLDFILE);
                            if(fh2)
                            {
                                Close(fh2);
                                DeleteFile(name);
                            }
                            nextname = strtok(NULL, ",");
                            if(!nextname)
                                break;
                        }
                    }
                }
                FreeVec(msg);
                Close(fh);
                DeleteFile(fib->fib_FileName);
            }
        }
    }

    FreeDosObject(DOS_FIB, fib);
    CurrentDir(oldlock);
    UnLock(lock);
    LibDeletePool(listpool);
    update_folder();
    free_folders_list(folders);
    CloseLibrary(RexxSysBase);
    exit(0);
}
'-lh0-    Z_'B get_folder_path.c0/*
**   YAM2NN - Usenet access for YAM p7 and newer
**   Copyright (C) 1999 Karol Bryd <kbryd@femina.com.pl>
**
**   This program is free software; you can redistribute it and/or
**   modify it under the terms of the GNU General Public License
**   as published by the Free Software Foundation; either version 2
**   of the License, or (at your option) any later version.
**
**   This program is distributed in the hope that it will be useful,
**   but WITHOUT ANY WARRANTY; without even the implied warranty of
**   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**   GNU General Public License for more details.
**
**   You should have received a copy of the GNU General Public License
**   along with this program; if not, write to the Free Software
**   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

/*
** $Log$
*/

#include "Yam2NN.h"
#include "get_folder_path.h"

char current_user_path[108];
static char tmp[1024];

// gets path for current user's directory

// this needs to be rewritten
int query_for_user(void)
{
    BPTR fh;
    char *ln;

    sprintf(tmp, "/* */\n"
                "OPTIONS RESULTS\n"
                "ADDRESS YAM\n"
                "USERINFO STEM user.\n"
                "call open(fd, 'T:userinfo.tmp', 'w')\n"
                "call writeln(fd, user.maildir)\n"
                "call close(fd)\n");

    fh = Open("T:qfu.rexx", MODE_NEWFILE);
    if(!fh)
        return(-1);
    Write(fh, tmp, strlen(tmp));
    Close(fh);

    Execute("rx T:qfu.rexx", NULL, NULL);

    fh = Open("T:userinfo.tmp", MODE_OLDFILE);
    if(!fh)
        return(-1);

    Read(fh, current_user_path, sizeof(current_user_path));
    Close(fh);

    ln = strchr(current_user_path, 10);
    if(ln)
        *ln = 0;

    return(0);
}

/*
char *stristr(char *buf, char *str)
{
    register int len = strlen(buf);
    register int len2 = strlen(str);
    register int a;

    for(a = 0; a <= len - len2; a++)
        if(strnicmp(&buf[a], str, len2) == 0)
            return(&buf[a]);
    return(0);
}
*/

// scans YAM's folders and gets type of folder from .fconfig files

void scan_folders(struct List *folders)
{
    struct Folder *folder;
    BPTR fh;

    folder = (struct Folder *)folders->lh_Head;

    while(folder->f_next)
    {
        strcpy(tmp, current_user_path);
        AddPart(tmp, folder->f_path, sizeof(tmp));
        AddPart(tmp, ".fconfig", sizeof(tmp));

        fh = Open(tmp, MODE_OLDFILE);
        if(fh)
        {
            char *fconfig, *equal;

            fconfig = AllocVec(1000, MEMF_ANY);
            Read(fh, fconfig, 1000);

            Close(fh);

            equal = stristr(fconfig, "Type");

            equal = strchr(equal, '=');
            if(equal)
            {
                equal++;
                equal = stpblk(equal);

                folder->f_type = atol(equal);
            }
        }
        folder = folder->f_next;
    }
}

// creates list of folders - only in YAM p7+

int build_folders_list(struct List *folders)
{
    BPTR folders_fh;
    int num = 0;

    strcpy(tmp, current_user_path);
    AddPart(tmp, ".folders", sizeof(tmp));
    folders_fh = Open(tmp, MODE_OLDFILE);
    if(!folders_fh)
        return(-2);  // perhaps no YAM P7

    FGets(folders_fh, tmp, sizeof(tmp));

    while(FGets(folders_fh, tmp, sizeof(tmp)))
    {
        if(strnicmp(tmp, "@FOLDER", 7) == 0)
        {
            struct Folder *folder;

            FGets(folders_fh, tmp, sizeof(tmp));

            folder = AllocVec(sizeof(struct Folder), MEMF_ANY | MEMF_CLEAR);
            folder->f_num = num++;
            folder->f_path = AllocVec(strlen(tmp) + 1, MEMF_ANY | MEMF_CLEAR);
            strcpy(folder->f_path, strtok(tmp, "\n"));
            AddTail(folders, folder);
        }
    }
    scan_folders(folders);
    Close(folders_fh);
    return(0);
}

void free_folders_list(struct List *folders)
{
    struct Folder *folder = (struct Folder *)folders->lh_Head;
    struct Folder *next;

    while(folder->f_next)
    {
        next = folder->f_next;
        FreeVec(folder->f_path);
        FreeVec(folder);
        folder = next;
    }
}

// gets folder path

char *get_folder_path(struct List *folders, int type)
{
    struct Folder *folder = (struct Folder *)folders->lh_Head;

    while(folder->f_next)
    {
        if(folder->f_type == type)
            return(folder->f_path);
        folder = folder->f_next;
    }
    return(NULL);
}

// gets folder number

int get_folder_pos(struct List *folders, int type)
{
    struct Folder *folder = (struct Folder *)folders->lh_Head;

    while(folder->f_next)
    {
        if(folder->f_type == type)
            return(folder->f_num);
        folder = folder->f_next;
    }
    return(-1);
}

struct List *init_folder_list(void)
{
    static struct List *folders;

    folders = AllocVec(sizeof(struct List), MEMF_ANY | MEMF_CLEAR);
    if(!folders)
        return(NULL);

    NewList(folders);

    return(folders);
}

void save_folder_list(struct List *folders)
{
    struct Folder *folder;
    BPTR           fh;

    if(!folders)
        return;

    fh = Open("YAM:YAM2NN.folders", MODE_NEWFILE);
    if(!fh)
        return;

    folder = (struct Folder *)folders->lh_Head;

    while(folder->f_next)
    {
        sprintf(tmp, "%s %d %d\n", folder->f_path, folder->f_num, folder->f_type);
        Write(fh, tmp, strlen(tmp));

        folder = folder->f_next;
    }
    Close(fh);
}

struct List *open_folder_list(void)
{
    struct Folder *folder;
    struct List   *list;
    char           name[108];
    BPTR           fh;

    list = AllocVec(sizeof(struct List), MEMF_ANY | MEMF_CLEAR);
    if(!list)
        return(NULL);

    NewList(list);

    fh = Open("YAM:YAM2NN.folders", MODE_OLDFILE);
    if(!fh)
    {
        FreeVec(list);
        return(NULL);
    }

    while(FGets(fh, tmp, sizeof(tmp)))
    {
        folder = AllocVec(sizeof(struct Folder), MEMF_ANY | MEMF_CLEAR);
        if(!folder)
            break;

        sscanf(tmp, "%s %d %d", name, &folder->f_num, &folder->f_type);
        folder->f_path = AllocVec(strlen(name) + 1, MEMF_ANY | MEMF_CLEAR);
        strcpy(folder->f_path, name);

        AddTail(list, folder);
    }

    Close(fh);
    return(list);
}

/*
int main(void)
{
    struct List   *folders;
    struct Folder *folder;

    query_for_user();
    puts(current_user_path);

    folders = open_folder_list();
    if(!folders)
    {
        folders = init_folder_list();

        puts(get_folder_path(folders, INCOMING));
        printf("%d\n", get_folder_pos(folders, DELETED));

        save_folder_list(folders);
        free_folders_list(folders);

        folders = open_folder_list();
    }

    folder = (struct Folder *)folders->lh_Head;

    while(folder->f_next)
    {
        printf("%s %d %d\n", folder->f_path, folder->f_num, folder->f_type);
        folder = folder->f_next;
    }
    free_folders_list(folders);
}
*/
'B-lh0-    3}&B get_folder_path.h#ifndef _FOLDERS_H_
#define _FOLDERS_H_

#define REGULAR  0
#define INCOMING 1
#define OUTGOING 2
#define SENT     3
#define DELETED  4

struct Folder
{
    struct Folder *f_next;
    struct Folder *f_prev;
    char          *f_path;
    int            f_num;
    int            f_type;
};

extern int query_for_user(void);
extern void scan_folders(struct List *folders);
extern int build_folders_list(struct List *folders);
extern void free_folders_list(struct List *folders);
extern char *get_folder_path(struct List *folders, int type);
extern int get_folder_pos(struct List *folders, int type);
extern struct List *init_folder_list(void);

extern char current_user_path[];
extern struct List *open_folder_list(void);
extern void save_folder_list(struct List *folders);


#endif

 I-lh0-      J&B 
killfile.hextern void UpdateKillfile(void);
extern void CreateKillList(void);
extern void FreeKillList(void);
extern int CheckForPLONK(char *subject, char *from);

-lh0-    В&B str.cL|#include "Yam2NN.h"

#ifndef __SASC
char *Stptok(const char *s, char *tok, int toklen, const char *brk)
{
    int pos;

    if((s == NULL) || (tok == NULL) || (brk == NULL))
        return(NULL);

    if(*s == 0)
        return(NULL);
    pos = 0;
    while(1)
    {
        if(*s == 0)
            break;
        if(strchr(brk, *s))
            break;

        tok[pos++] = *s;
        if(pos >= toklen)
            break;

        s++;
    }
    tok[pos] = 0;
    return(s);
}

char *Stpblk(const char *str)
{
    while(isspace(*str) && *str)
        str++;
    return(str);
}

int Astcsma(char *s, char *p)
{
    char out[255];

    if(ParsePatternNoCase(p, out, sizeof(out)) > 0)
        if(MatchPatternNoCase(out, s))
            return(TRUE);

    return(FALSE);
}
#endif

-lh0-    @&B yam2nn.hX/*
**   YAM2NN - Usenet access for YAM p7 and newer
**   Copyright (C) 1999 Karol Bryd <kbryd@femina.com.pl>
**
**   This program is free software; you can redistribute it and/or
**   modify it under the terms of the GNU General Public License
**   as published by the Free Software Foundation; either version 2
**   of the License, or (at your option) any later version.
**
**   This program is distributed in the hope that it will be useful,
**   but WITHOUT ANY WARRANTY; without even the implied warranty of
**   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**   GNU General Public License for more details.
**
**   You should have received a copy of the GNU General Public License
**   along with this program; if not, write to the Free Software
**   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "compiler.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>

#include <exec/types.h>
#include <exec/lists.h>
#include <exec/nodes.h>
#include <exec/memory.h>
#include <dos/var.h>
#include <dos/dos.h>
#include <dos/datetime.h>

#include <devices/timer.h>

#include <libraries/asl.h>
#include <libraries/mui.h>
#include <libraries/reqtools.h>
#include <utility/tagitem.h>
#include <MUI/NList_mcc.h>
#include <MUI/NListview_mcc.h>
#include <MUI/Busy_mcc.h>

#include <sys/types.h>
#include <netinet/in.h>

#include <proto/locale.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/exec.h>
#include <proto/utility.h>
#include <proto/dos.h>
#include <proto/rexxsyslib.h>
#include <proto/timer.h>

#ifdef __SASC
#include <proto/socket.h>
#include <proto/muimaster.h>
#include <proto/reqtools.h>
#endif

#include <rexx/rxslib.h>
#include <rexx/rexxio.h>
#include <rexx/errors.h>

#include "killfile.h"
#include "get_folder_path.h"
#include "config.h"

#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))

#define ID_SKIPALL 1
#define ID_PERFORM 2

#define ALWAYS 0
#define NEVER 1
#define SKIPPED 2

#define STATUS_ACTIVE 1
#define STATUS_INACTIVE 2

struct NewsMessage
{
    struct NewsMessage *next;  // pionter for next message
    struct NewsMessage *prev;
    struct List        *list;  // list of nodes with message's content
    struct Article     *art;   // pointer for structure Article (described later)

    char   *FullName;          // full name of file to which message will be written
    char   *MsgID;             // message id of message
    long   length;             // length of message

    struct timeval start;      // start time
    struct timeval end;        // end time
};


struct NewsNode
{
    struct NewsNode *next;
    struct NewsNode *prev;
    struct List     *mesg;    // list of downloaded messages
    char  *ngname;             // newsgroup name
    char  *path;               // path to a folder with messages
    char  *host;               // server name
    char  *last_id;            // MessageID of last downloaded message
    int    port;                // port number
    int    sd;                  // file descriptor
    long   last;                // last downloaded message
    long   last_pos;            // position of last dn message in the MUI list
    long   maxlen;              // maximum length of a message we can d/n
    long   maxmsg;              // maximum number of messages
    long   initfetch;           // initial fetch - how many fetch for the first time
    long   flushthreshold;
    long   preselect_type;
    char   folder[80];          // folder name
    char   update;              // do we need to update folders?
    long   status;              // status: active or inactive

// added on 17-apr-99

    long total_size;          // length of all articles to download from this ng
    long size_downloaded;     // length of all downloaded articles
    long num_articles;        // number of articles to download
    long art_downloaded;      // number of downloaded articles
};

// holds informations about one article on the server

struct Article
{
    long Num;                 // article number

    char *Subject;            // subject
    char *From;               // from
    char *Date;
    char *Msg_ID;
    char *References;
    char *Xref;

    char  FileName[20];        // file name, for example 07234.012
    char  FullName[108];       // file name with path
    char *MessageID;       // Message-ID field extracted from the message
    long  Size;                // message size
    long  Lines;               // number of lines
    char  Status;              // status, skip or get
    char  Importance;          // currently not used
    int   Score;               // score
};

extern APTR initmui(void);
extern void setmui(struct NewsNode *nn);
extern void fail(char *str, int ret);
extern int do_connect(char *host, int port);
extern int ngets(char *p, int fd);
extern int nwrite(int socket, char *s);
extern void updategadgets(int type);

extern struct timerequest *create_timer(ULONG unit);
extern void delete_timer(struct timerequest *tr);

extern struct ReqToolsBase   *ReqToolsBase;
extern struct IntuitionBase  *IntuitionBase;

#ifndef __GNUC__
extern struct Library        *RexxSysBase;
extern struct Library        *LocaleBase;
extern struct Library        *TimerBase;
#else
extern struct RxsLib         *RexxSysBase;
extern struct LocaleBase     *LocaleBase;
extern struct Device         *TimerBase;
#endif

extern struct timerequest    *tr;

extern struct Library        *SocketBase;
extern struct Library        *MUIMasterBase;
extern struct Library        *MiamiBase;

extern struct List           *newsgroupslist;
extern struct List           *folders;
extern struct MsgPort        *port, *ARexxPort;

extern APTR app;

#ifndef __SASC
extern char *Stptok(const char *s, char *tok, int toklen, const char *brk);
extern char *Stpblk(const char *str);
extern int Astcsma(char *s, char *p);

#define stpblk Stpblk
#define stptok Stptok
#define astcsma Astcsma

#endif

 