/* shadow.h: Password file parsing. */

#ifndef _SHADOW_H
#define _SHADOW_H

#include <stdio.h>

struct spwd
{
    char* sp_namp;
    char* sp_pwdp;
    long sp_lstchg;
    long sp_min;
    long sp_max;
    long sp_warn;
    long sp_inact;
    long sp_expire;
    unsigned long sp_flag;
};

#ifdef __cplusplus
extern "C"
{
#endif

    /* Read the next entry from the shadow file. */
    struct spwd* getspent();

    /* Find the entry with a matching username in the shadow file. */
    struct spwd* getspnam(const char* name);

    /* Read the next entry from the shadow file (reentrant version). */
    int getspent_r(struct spwd* spbuf, char* buf, size_t buflen, struct spwd** spbufp);

    /* Read the next entry from a shadow file (reentrant version). */
    int fgetspent_r(FILE* stream, struct spwd* spbuf, char* buf, size_t buflen, struct spwd** spbufp);

    /* Rewind the shadow file. */
    void setspent(void);

    /* End shadow file parsing. */
    void endspent(void);

#ifdef __cplusplus
}
#endif

#endif