/*static char *SCCSID = "@(#)fnext.c    6.1 90/11/17";*/
/* fnext.c       -- DosFindNext
 *
 *  pre- and post- processor for aligned data API.
 */

/***  Change History:                                             ***/
/***    noto 11/18/93  Define which segment for Page Tuning DLL   ***/
/***                                                              ***/


/* STOP_LISTING */

#define INCL_DOS
#define INCL_32
#define INCL_NOPMAPI
#define INCL_ERRORS
#include <os2.h>
#define assert(f)

#include "align32.h"
#include "ffn.h"





/***    Define which segment for Page Tuning DLL   ***/

APIRET  APIENTRY DOS32FINDNEXT( HDIR , PVOID , ULONG , PULONG);

#pragma code_seg("CODE32_TUNE4", "CODE")
#pragma code_seg()

#pragma alloc_text(CODE32_TUNE4, DOS32FINDNEXT)







/* START_LISTING */

/*** Dos32FindNext
 *
 *  pre- and post- processor for aligned data API.
 *
 *  ENTRY:
 *
 *  EXIT:
 *
 *  ARGUMENTS:
 *
 *  RETURNS:
 *
 *  CALLS:
 *
 *  WARNINGS:
 *
 *  NOTE:
 *
 *  PSEUO-CODE:
 *      BEFORE
 *
 *      AFTER
 */

APIRET  APIENTRY DOS32FINDNEXT( HDIR    hdir,
                                PVOID   pfindbuf,
                                ULONG   cbBuf,
                                PULONG  pcFileNames) {
    APIRET  rc;
    FFNDATA ffndata;

    ffndata.cbBuffer = cbBuf;
    ffndata.ffnFlags = 0x0000;

    if (cbBuf > 0xFFFF)
        cbBuf = 0xFFFF;
    rc = Dos32PFindNext( hdir, pfindbuf, cbBuf, pcFileNames,
                                        &ffndata, pfindbuf, pcFileNames );

    if (rc) {
        if (rc == ERROR_EAS_DIDNT_FIT) {
            // the EAs didn't fit, so level 2 info was returned instead.
            ffndata.ulInfoLevel = 2;
            ffndata.ffnFlags = FFN_EAS_DIDNT_FIT;
        }
        else {
            return rc;
        }
    }

    FFNAlign( &ffndata, pfindbuf );

    return rc;
}
