TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Jani Patanen
date: 1996-10-19 12:09:10
subject: Pointer to a pointer to a pointer a

Hello All!

It's been a while since I've been handling pointers to a pointer. Not to
say about pointer in third degree. So I'm having some problems here.
I'm trying to port scandir to OS/2. (if you have on, I'd love to get it).
I'm using EMX 0.9b.

When I try to compile, I get following errors:
scandir.c: In function `scandir':
scandir.c:45: request for member `d_name' in something not a structure or union
scandir.c:46: request for member `d_namlen' in something not a structure or union
scandir.c:47: request for member `d_size' in something not a structure or union
scandir.c:47: warning: conversion lacks type at end of format
scandir.c:47: warning: too many arguments for format
scandir.c:48: request for member `d_time' in something not a structure or union
scandir.c:49: request for member `d_date' in something not a structure or union
scandir.c:50: request for member `d_attr' in something not a structure or union


Here's the src:

#include 
#include 
#include 
#include 
#include 
#include 
#define INCL_DOSFILEMGR



int
scandir(const char *dirname, struct dirent ***namelist,
        int (*select)(struct dirent *),
        int (*compar)(const void *, const void *))

{
HDIR FindHandle;
FILEFINDBUF3 FindBuffer;
ULONG FindCount;
APIRET rc;
int items=0;
FindHandle=0x0001;
FindCount=1;

rc=DosFindFirst(dirname,              /* file Pattern */
                &FindHandle,          /* Directory Search handle */
                0,                    /* File attribute, anyone will do*/
                (PVOID) &FindBuffer,  /* Result buffer */
                sizeof(FindBuffer),   /* Result buffer len */
                &FindCount,           /* # of entries found */
                FIL_STANDARD);        /* Return level 1 file info */
/* Don't ask me about all this. Directly copied from borland  online
 * help */

if (rc !=0) return -1;
namelist=(PVOID) NULL;

while (rc==0){
    items++; /* Number of files found */
    namelist = (struct dirent ***) realloc (namelist,items*sizeof(namelist));
    /* allocated more memory for new item */
    if (NULL==namelist) return -1;
    sprintf((namelist+(items-1))->d_name,"%s",FindBuffer.achName);
   
sprintf((namelist+items-1)->d_namlen,"%lu",strlen(FindBuffer.achName));
    sprintf((namelist+items-1)->d_size,"%l",FindBuffer.cbFile);
    *(namelist+items-1)->d_time=0; /* not interested making conversion */
    *(namelist+items-1)->d_date=0; /* I doubt it's needed */
    *(namelist+items-1)->d_attr=0;

    FindCount=1;
    rc = DosFindNext(FindHandle,            /* Directory handle */
                    (PVOID) &FindBuffer,    /* Result Buffer */
                    sizeof(FindBuffer),     /* Res buffer len */
                    &FindCount);            /* Number of entries to find */
                }

return items;
}


-Jani


--- 
* Origin: And even more trash coming from : (2:220/273.1)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1
@PATH: 220/273 22/10 229/0 270/101 712/515 711/808 934

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™.