/*
* This OS/2 port was hacked by Harald Kipp from the
*
* Network News Transfer Protocol server
*
* Phil Lapsley
* University of California, Berkeley
* Stan Barber
* Baylor College of Medicine
*
* Bug reports related to THIS modified version should be sent to
*
* harald@os2point.ping.de
* harald@sesam.com
* Fido: 2:2448/434
*
*/
#define OS2
#define INCL_DOSFILEMGR
#include <os2.h>
#include <types.h>
#include <netinet\in.h>
#include <sys\socket.h>
#include <netlib.h>
#undef min
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <lprintf.h>
#include <dbgheap.h>
#include "config.h"
#include "globals.h"
#include "nntp.h"
#include "changi.h"
/************************************************************************/
/* */
/************************************************************************/
static int longcmp(long *x, long *y)
{
if(*x > *y)
return(1);
else if(*x < *y)
return(-1);
return(0);
}
/************************************************************************/
/* */
/************************************************************************/
int scan_dir(char *path, long low_msg, long high_msg, long art_array[])
{
long artnum;
HDIR hdir = HDIR_CREATE;
int sOff = sizeof(FILEFINDBUF) - CCHMAXPATHCOMP + 1;
PFILEFINDBUF paffb = malloc(12288);
PFILEFINDBUF pffb;
int cffb = 255;
int rc;
int i;
int num_arts = 0;
char *tmplt = malloc(CCHMAXPATH);
strcpy(tmplt, path);
strcat(tmplt, "\\*");
if((rc = DosFindFirst2(tmplt, &hdir, 0, paffb, 12288, &cffb, 1, 0L)) == 0) {
while (!rc && cffb) {
pffb = paffb;
for(i = 0; i < cffb; i++) {
artnum = atol(pffb->achName);
if (artnum && artnum >= low_msg && artnum <= high_msg) {
if(num_arts < MAX_ARTICLES)
art_array[num_arts++] = artnum;
else {
lprintf("Can't handle more than %u articles in one group", MAX_ARTICLES);
break;
}
}
pffb = (PFILEFINDBUF)((char *)pffb + sOff + pffb->cchName);
}
if(num_arts >= MAX_ARTICLES)
break;
cffb = 255;
rc = DosFindNext(hdir, paffb, 12288, &cffb);
}
DosFindClose(hdir);
qsort(art_array, num_arts, sizeof(long), longcmp);
}
free(paffb);
free(tmplt);
return (num_arts);
}