home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_300
/
376_01
/
os2tool.000
/
DIRSDOS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-03
|
2KB
|
81 lines
/* =====================================================
*
* DIRSDOS.C - Show the directory stack.
*
*
*
* Copyright(c): Martti Ylikoski. 1992
*
* Programmer: Martti Ylikoski
* Created: 3.3.1992
* Version: 1.0
*
* ====================================================== */
#include <stdio.h>
#include <string.h>
#include "list.h"
static char *deffile = "C:\\dirserv.dat" ;
int main(int argc, char * argv[])
{
HNDLIST *lhandle ;
int i, actioncode, popid ;
char * buf, fbuff[125], *tmp ;
unsigned long buflen ;
FILE *fp ;
popid = 1 ;
if ( (tmp = getenv("DIRSERV")) != NULL)
deffile = tmp ;
if (argc == 2 && (strcmpi(argv[1], "-q") == 0
|| strcmpi(argv[1], "/q") == 0))
{
unlink (deffile) ;
printf("Directory stack server removed. \n") ;
return( 0 ) ;
}
if (argc == 2)
popid = atoi(argv[1]) ;
if ((lhandle = ListInit()) == NULL)
{
printf("Error in ListInit\nExit\n") ;
return( 1 ) ;
}
if ((fp = fopen (deffile, "r")) == NULL)
{
printf("[%1] .\n") ;
return( 0 ) ;
}
while (fgets(fbuff, sizeof(fbuff), fp ) != NULL)
{
ListAdd(lhandle, fbuff, strlen(fbuff)+1) ; /* +1 because we store also \0 */
}
fclose (fp) ;
i = 1 ;
ListLast(lhandle) ;
while ( ListReturn(lhandle, &buf, &buflen) == LIST_OK)
{
printf("[%d] %s", i, buf) ;
i++ ;
if ( ListPrior(lhandle) == LIST_ERR_BEG_LIST)
break ;
}
printf("[%d] .\n", i) ;
return( 0 ) ;
}