Ignore:
Timestamp:
Nov 1, 2016, 7:26:35 PM (9 years ago)
Author:
bird
Message:

lib/nt: Got fts-nt halfways working, quite a few NT interface changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/fts-nt.h

    r2983 r2985  
     1/* $Id: $ */
     2/** @file
     3 * Header for the NT port of BSD fts.h.
     4 *
     5 * @copyright   Copyright (c) 1989, 1993 The Regents of the University of California.  All rights reserved.
     6 * @copyright   NT modifications Copyright (C) 2016 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
     7 * @licenses    BSD3
     8 */
     9
    110/*
    211 * Copyright (c) 1989, 1993
     
    2938 *      @(#)fts.h       8.3 (Berkeley) 8/14/94
    3039 * $FreeBSD$
     40 *
    3141 */
    3242
    33 #ifndef _FTS_H_
    34 #define _FTS_H_
     43#ifndef INCLUDED_FTS_NT_H
     44#define INCLUDED_FTS_NT_H
    3545
    36 #include <sys/_types.h>
     46#include <sys/types.h>
     47#include <stdint.h>
     48#include "ntstat.h" /* ensure correct stat structure */
     49
     50typedef uint64_t fts_dev_t;
     51typedef uint64_t fts_ino_t;
     52typedef uint32_t fts_nlink_t;
     53#ifdef _WINNT_
     54typedef HANDLE fts_fd_t;
     55#else
     56typedef void * fts_fd_t;
     57#endif
     58#define FTSCALL __cdecl
    3759
    3860typedef struct {
     
    4062        struct _ftsent *fts_child;      /* linked list of children */
    4163        struct _ftsent **fts_array;     /* sort array */
    42         __dev_t fts_dev;                /* starting device # */
     64        fts_dev_t fts_dev;              /* starting device # */
    4365        char *fts_path;                 /* path for this descent */
    44         int fts_rfd;                    /* fd for root */
    45         __size_t fts_pathlen;           /* sizeof(path) */
    46         __size_t fts_nitems;            /* elements in the sort array */
    47         int (*fts_compar)               /* compare function */
     66        size_t fts_pathlen;             /* sizeof(path) */
     67        size_t fts_nitems;              /* elements in the sort array */
     68        int (FTSCALL *fts_compar)       /* compare function */
    4869            (const struct _ftsent * const *, const struct _ftsent * const *);
    4970
     
    5576#define FTS_SEEDOT      0x020           /* return dot and dot-dot */
    5677#define FTS_XDEV        0x040           /* don't cross devices */
     78#if 0 /* No whiteout on NT. */
    5779#define FTS_WHITEOUT    0x080           /* return whiteout information */
     80#endif
    5881#define FTS_OPTIONMASK  0x0ff           /* valid user option mask */
    5982
     
    6891        struct _ftsent *fts_parent;     /* parent directory */
    6992        struct _ftsent *fts_link;       /* next file in directory */
    70         long long fts_number;           /* local numeric value */
     93        int64_t fts_number;             /* local numeric value */
    7194#define fts_bignum      fts_number      /* XXX non-std, should go away */
    7295        void *fts_pointer;              /* local address value */
     
    7497        char *fts_path;                 /* root path */
    7598        int fts_errno;                  /* errno for this node */
    76         int fts_symfd;                  /* fd for symlink */
    77         __size_t fts_pathlen;           /* strlen(fts_path) */
    78         __size_t fts_namelen;           /* strlen(fts_name) */
     99        fts_fd_t fts_symfd;             /* NT: Normally -1; -2 we followed this symlinked dir */
     100        fts_fd_t fts_dirfd;             /* NT: Handle to the directory */
     101        size_t fts_pathlen;             /* strlen(fts_path) */
     102        size_t fts_namelen;             /* strlen(fts_name) */
    79103
    80         __ino_t fts_ino;                /* inode */
    81         __dev_t fts_dev;                /* device */
    82         __nlink_t fts_nlink;            /* link count */
     104        fts_ino_t fts_ino;              /* inode */
     105        fts_dev_t fts_dev;              /* device */
     106        fts_nlink_t fts_nlink;          /* link count */
    83107
    84108#define FTS_ROOTPARENTLEVEL     -1
     
    99123#define FTS_SL          12              /* symbolic link */
    100124#define FTS_SLNONE      13              /* symbolic link without target */
    101 #define FTS_W           14              /* whiteout object */
     125//#define       FTS_W           14              /* whiteout object */
    102126        int fts_info;                   /* user status for FTSENT structure */
    103127
     
    116140        char *fts_name;                 /* file name */
    117141        FTS *fts_fts;                   /* back pointer to main FTS */
     142        BirdStat_T fts_stat;            /* NT: We always got stat info. */
    118143} FTSENT;
    119144
    120 #include <sys/cdefs.h>
    121145
    122 __BEGIN_DECLS
    123 FTSENT  *fts_children(FTS *, int);
    124 int      fts_close(FTS *);
    125 void    *fts_get_clientptr(FTS *);
     146#ifdef __cplusplus
     147extern "C" {
     148#endif
     149FTSENT  *FTSCALL fts_children(FTS *, int);
     150int      FTSCALL fts_close(FTS *);
     151void    *FTSCALL fts_get_clientptr(FTS *);
    126152#define  fts_get_clientptr(fts) ((fts)->fts_clientptr)
    127 FTS     *fts_get_stream(FTSENT *);
     153FTS     *FTSCALL fts_get_stream(FTSENT *);
    128154#define  fts_get_stream(ftsent) ((ftsent)->fts_fts)
    129 FTS     *fts_open(char * const *, int,
    130             int (*)(const FTSENT * const *, const FTSENT * const *));
    131 FTSENT  *fts_read(FTS *);
    132 int      fts_set(FTS *, FTSENT *, int);
    133 void     fts_set_clientptr(FTS *, void *);
    134 __END_DECLS
     155FTS     *FTSCALL fts_open(char * const *, int,
     156            int (FTSCALL*)(const FTSENT * const *, const FTSENT * const *));
     157FTSENT  *FTSCALL fts_read(FTS *);
     158int      FTSCALL fts_set(FTS *, FTSENT *, int);
     159void     FTSCALL fts_set_clientptr(FTS *, void *);
     160#ifdef __cplusplus
     161}
     162#endif
    135163
    136 #endif /* !_FTS_H_ */
     164#endif /* !INCLUDED_FTS_NT_H */
     165
Note: See TracChangeset for help on using the changeset viewer.