TIP: Click on subject to list as thread! ANSI
echo: locsysop
to: Bob Lawrence
from: Paul Edwards
date: 1996-11-20 11:40:12
subject: tic

PE> Use trav() and I've already done the conversion. If there's
PE> some reason you can't use trav(), the Unix (actually, POSIX)
PE> equivalent is opendir() and readdir(). These are available for
PE> DOS, in "SNIPPETS"

BL> Oh. Borland has thi\ose. These aren't ANSI (ascii) but they work in 
BL> DOS, UNIX and Windows. Bloody ANSI is useless. Does trav() use them, 
BL> or what? I'd just as soon stick to a set of words that will mean 
BL> something to someone and trav() does score high in the Mysterious 
BL> Stakes...

trav is short for traverse, to traverse a directory.  trav() doesn't use
opendir() and readdir(), but it should be updated one day to do so.  As an
#ifdef POSIX.  Oh, I recently modified trav (since ozpd) to fix some Amiga
restrictions.  I'll post it here.  BFN.  Paul.

/*********************************************************************/
/*                                                                   */
/*  This Program Written By Paul Edwards.                            */
/*  Released to the public domain.                                   */
/*                                                                   */
/*********************************************************************/
/*********************************************************************/
/*                                                                   */
/*  trav - traverse a directory                                      */
/*                                                                   */
/*  This function is designed to be highly machine-specific.  It     */
/*  is to get all the machine-specific directory processing into a   */
/*  single function.                                                 */
/*                                                                   */
/*  The first parameter is a filename.  This can be a simple         */
/*  filename such as "temp.c", or one that contains wildcards such   */
/*  as "temp.*" or "temp.c(*)".                        
             */
/*                                                                   */
/*  The second parameter is a pointer to a control block.  This      */
/*  control block's structure is machine-specific, and contains      */
/*  information that trav will use such as whether or not to         */
/*  search subdirectories as well.                                   */
/*                                                                   */
/*  The third parameter is a pointer to a function which will get    */
/*  called for every file found.                                     */
/*                                                                   */
/*  The fourth parameter is a pointer to a control block which will  */
/*  get passed to the function you specified as parameter 3.         */
/*                                                                   */
/*  The function that trav calls takes two parameters:               */
/*  The first is a filename that trav has found.                     */
/*  The second is the fourth parameter you passed to trav.           */
/*                                                                   */
/*  example of use:                                                  */
/*                                                                   */
/*  int myfunc(char *fnm, void *ucb)                                 */
/*  {                                                                */
/*    printf("fnm is %s\n",fnm);                                     */
/*    return (1);                                                    */
/*  }                                                                */
/*                                                                   */
/*  main()                                                           */
/*  {                                                                */
/*    trav("dd:input(*)",NULL,myfunc,NULL);                          */
/*    return (0);                                                    */
/*  }                                                                */
/*                                                                   */
/*********************************************************************/

#include 
#include 
#include 
#include 
#include 

#ifdef MVS
  #include "brkpds.h"
  #include "mkpdsn.h"
  #include "patmat.h"
  #include "stritr.h"
  #include "striupr.h"
#endif
#ifdef MSDOS
  #include 
#ifdef __TURBOC__
  #include 
#else
  #include 
#endif  
#endif
#ifdef UNIX
  #include 
  #include 
  #include 
  #include "patmat.h"
  static int (*gfunc)(char *fnm, void *ucb);
  static char *gfile;
  static void *gcb;
  static int   grec;
  static char *gpat;
  static char gstem[FILENAME_MAX+200];
#endif
#ifdef VAXVMS
#include 
#include "patmat.h"
#endif
#ifdef AMIGA
  #include 
#endif
#ifdef OS2
#include 
#endif
#ifdef VM
#endif

/* suppress warning about unused parameter */

#ifndef unused
#define unused(x) ((void)(x))
#endif

int trav(char *filename, void *tcb,
    int (*ufunc)(char *fnm, void *ucb), void *cb)
{
#ifdef MVS
  FILE *pds;
  char *first = NULL;
  char *sec = NULL;
  char buf[256];
  char mem[9];
  char ttr[3];
  int mcnt, scnt, x;

  /* tcb of 1 means that the user wants the TTR */
  if ((tcb != NULL) && (*(int *)tcb == 1)) cb = ttr;
  if (!brkpds(filename,&first,&sec))
      return(ufunc(filename,cb));
#ifdef C370
  pds = fopen(first,"rb,recfm=u");
#else
  pds = fopen(first,"rb");
#endif
  if (pds == NULL) return (0);
  striupr(sec);
  mem[8] = '\0';
  while (fread(buf,256,1,pds) == 1)
  {
    mcnt = *(short *)buf;
    for (x=2;x * Origin: X (3:711/934.9)

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.