mirror of https://github.com/lianthony/NT4.0
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
860 B
51 lines
860 B
/*** dlist.c - code to handling creation of DH style doclists
|
|
*
|
|
*/
|
|
#include <stdio.h>
|
|
#include "dh.h"
|
|
|
|
/* Extern Functions */
|
|
extern int printf();
|
|
extern int free();
|
|
|
|
static Fhandle lastfh = ERROR;
|
|
static Docid lastid = ERROR;
|
|
static Docid firstid = ERROR;
|
|
|
|
|
|
void adddl(fh, did)
|
|
Fhandle fh;
|
|
Docid did;
|
|
{
|
|
char *fname;
|
|
|
|
if ( lastfh == fh ) {
|
|
if ( did == lastid + 1 ) {
|
|
if ( firstid == lastid )
|
|
printf("-");
|
|
lastid += 1;
|
|
} else {
|
|
if ( firstid != lastid )
|
|
printf("%d,%d", lastid, did);
|
|
else
|
|
printf(",%d", did);
|
|
firstid = lastid = did;
|
|
}
|
|
} else {
|
|
if ( lastfh != ERROR )
|
|
printf("%d\n", lastid);
|
|
fname = getname(fh);
|
|
printf("%s:%d", fname, did);
|
|
free(fname);
|
|
lastfh = fh;
|
|
firstid = lastid = did;
|
|
}
|
|
}
|
|
|
|
void putdl()
|
|
{
|
|
if ( (lastid != ERROR) && (lastid != firstid) )
|
|
printf("%d\n", lastid);
|
|
else
|
|
printf("\n");
|
|
}
|