2019-08-03 16:23:04 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* libs/libc/grp/lib_grp.h
|
|
|
|
*
|
2021-03-02 09:55:05 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2019-08-03 16:23:04 +02:00
|
|
|
*
|
2021-03-02 09:55:05 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2019-08-03 16:23:04 +02:00
|
|
|
*
|
2021-03-02 09:55:05 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2019-08-03 16:23:04 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __LIBS_LIBC_GRP_LIB_GRP_H
|
|
|
|
#define __LIBS_LIBC_GRP_LIB_GRP_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <grp.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define ROOT_GID 0
|
|
|
|
#define ROOT_NAME "root"
|
|
|
|
#define ROOT_PASSWD "x"
|
|
|
|
|
2019-08-04 21:32:36 +02:00
|
|
|
/* Reserver space for a NULL terminated list for group member names */
|
|
|
|
|
|
|
|
#define MEMBER_SIZE ((CONFIG_LIBC_GROUP_NUSERS + 1) * sizeof(FAR char *))
|
|
|
|
|
|
|
|
/* Reserve space for the maximum line in the group file PLUS space for an
|
|
|
|
* array of Member names.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define GRPBUF_RESERVE_SIZE (CONFIG_LIBC_GROUP_LINESIZE + MEMBER_SIZE)
|
|
|
|
|
2019-08-03 16:23:04 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2019-08-04 21:32:36 +02:00
|
|
|
#ifdef CONFIG_LIBC_GROUP_FILE
|
|
|
|
/* Data for non-reentrant group functions */
|
|
|
|
|
|
|
|
EXTERN struct group g_group;
|
|
|
|
EXTERN char g_group_buffer[GRPBUF_RESERVE_SIZE];
|
|
|
|
#endif
|
|
|
|
|
2019-08-03 16:23:04 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct group *getgrbuf(gid_t gid, FAR const char *name,
|
|
|
|
FAR const char *passwd);
|
|
|
|
int getgrbuf_r(gid_t gid, FAR const char *name, FAR const char *passwd,
|
|
|
|
FAR struct group *grp, FAR char *buf, size_t buflen,
|
|
|
|
FAR struct group **result);
|
|
|
|
|
2019-08-04 21:32:36 +02:00
|
|
|
#ifdef CONFIG_LIBC_GROUP_FILE
|
|
|
|
int grp_findby_name(FAR const char *gname, FAR struct group *entry,
|
|
|
|
FAR char *buffer, size_t buflen);
|
|
|
|
int grp_findby_gid(gid_t gid, FAR struct group *entry, FAR char *buffer,
|
|
|
|
size_t buflen);
|
|
|
|
#endif
|
|
|
|
|
2019-08-03 16:23:04 +02:00
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __LIBS_LIBC_GRP_LIB_GRP_H */
|