Category : C Source Code
Archive   : DMAKE38B.ZIP
Filename : FIND.C

 
Output of file : FIND.C contained in archive : DMAKE38B.ZIP
/*
Directory Access Library

FIND.C taken from DIRLIB.C by M. J. Weinstein
Released to public domain 1-Jan-89

The author may be contacted at:
[email protected] -or- POB 84524, L.A., CA 90073

Modified by [email protected] to work with dmake.
(nuked the DOS version 2 code, since dmake needs version
3.0 or greater to function).
*/


/*
* revision history:
*
* VER MM/DD/YY COMMENTS
* ---- -------- --------
* 0.99 02/24/86 Beta release to INTERNET
*/

#include
#include
#include
#include
#include
#include
#include "dirlib.h"

#ifndef MK_FP
#define MK_FP(seg,ofs) ((void far *) \
(((unsigned long)(seg) << 16) | (unsigned)(ofs)))
#endif
#ifndef FP_SEG
#define FP_SEG(fp) ((unsigned)((unsigned long)(fp) >> 16))
#endif
#ifndef FP_OFF
#define FP_OFF(fp) ((unsigned)(fp))
#endif

int _err;
static DTA far *_getsetdta ANSI((DTA far *));

/*
* get/set dta address
*/

static DTA far *
_getsetdta(newdta)
DTA far *newdta;
{
DTA far *olddta;
union REGS r;
struct SREGS s;

/* get old dta */
r.h.ah = 0x2f;
intdos(&r, &r);
segread(&s);
olddta = (DTA far *) MK_FP(s.es, r.x.bx);

/* conditionally set new dta */
if (newdta) {
r.h.ah = 0x1a;
s.ds = FP_SEG(newdta);
r.x.dx = FP_OFF(newdta);
intdosx(&r, &r, &s);
}

return olddta;
}

/*
* dos findfirst
*/

DTA *
findfirst(name, dta)
char *name;
DTA *dta;
{
union REGS r;
struct SREGS s;
DTA far *dtasave;
char far *nmp = (char far *)name;

dtasave = _getsetdta((DTA far *)dta);

/* do directory lookup */
segread(&s);
r.h.ah = 0x4e;
r.x.cx = 0x10;
r.x.dx = FP_OFF(nmp);
s.ds = FP_SEG(nmp);
intdosx(&r, &r, &s);
/* restore dta */
_getsetdta(dtasave);
_err = r.x.ax;
if (r.x.cflag)
return (DTA *) 0;

return dta;
}

/*
* dos findnext
*/

DTA *
findnext(dta)
DTA *dta;
{
union REGS r;
DTA far *dtasave;

dtasave = _getsetdta((DTA far *)dta);

/* do directory lookup */
r.h.ah = 0x4f;
intdos(&r, &r);
/* restore old dta */
_getsetdta(dtasave);
_err = r.x.ax;
if (r.x.cflag)
return (DTA *) 0;

return dta;
}


  3 Responses to “Category : C Source Code
Archive   : DMAKE38B.ZIP
Filename : FIND.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/