Rechercher une page de manuel
getgrent_r
Langue: ja
Version: 2003-11-15 (openSuse - 09/10/07)
Section: 3 (Bibliothèques de fonctions)
̾Á°
getgrent_r, fgetgrent_r - ¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë¥¨¥ó¥È¥ê¤ò¥ê¥¨¥ó¥È¥é¥ó¥È (reentrant) ¤Ë¼è¤ê½Ð¤¹½ñ¼°
#define _GNU_SOURCE
#include <grp.h> int getgrent_r(struct group *gbuf, char *buf,
size_t buflen, struct group **gbufp); int fgetgrent_r(FILE *fp, struct group *gbuf, char *buf,
size_t buflen, struct group **gbufp);
ÀâÌÀ
´Ø¿ô getgrent_r() ¤È fgetgrent_r() ¤Ï getgrent(3) ¤È fgetgrent(3) ¤Î¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤǤ¢¤ë¡£ Á°¼Ô¤Ï¡¢ setgrent(3) ¤Ë¤è¤Ã¤Æ½é´ü²½¤µ¤ì¤¿¥¹¥È¥ê¡¼¥à¤«¤é¡¢¼¡¤Î¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤òÆɤ߹þ¤à¡£ ¸å¼Ô¤Ï¡¢°ú¤¿ô fp ¤È¤·¤ÆÍ¿¤¨¤é¤ì¤¿¥¹¥È¥ê¡¼¥à¤«¤é¡¢¼¡¤Î¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤òÆɤ߹þ¤à¡£group ¹½Â¤ÂÎ¤Ï <grp.h> ¤Ë¤ª¤¤¤Æ°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
-
struct group { char *gr_name; /* ¥°¥ë¡¼¥×̾ */ char *gr_passwd; /* ¥°¥ë¡¼¥×¥Ñ¥¹¥ï¡¼¥É */ gid_t gr_gid; /* ¥°¥ë¡¼¥× ID */ char **gr_mem; /* ¥°¥ë¡¼¥×¥á¥ó¥Ð */ };
¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤Ê¤¤´Ø¿ô¤ÏÀÅŪ¤Ê³ÊǼÎΰè¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£ ¤³¤ÎÀÅŪ¤Ê³ÊǼÎΰè¤Ë¤Ï¡¢¹¹¤Ë¥°¥ë¡¼¥×̾¡¦¥Ñ¥¹¥ï¡¼¥É¡¦ ¥á¥ó¥Ð¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬´Þ¤Þ¤ì¤ë¡£ ¤³¤³¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¥ê¥¨¥ó¥È¥é¥ó¥È¤Ê´Ø¿ô¤Ï¡¢ ¸Æ¤Ó½Ð¤·Â¦¤«¤éÄ󶡤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¤Ë¥°¥ë¡¼¥×̾¤Ê¤ÉÁ´¤Æ¤òÊÖ¤¹¡£ ºÇ½é¤Î°ú¤¿ô¤È¤·¤Æ struct group ¤òÊÝ»ý¤Ç¤¤ë¥Ð¥Ã¥Õ¥¡ gbuf ¤¬¤¢¤ë¡£ ¼¡¤Ë¤½¤Î¾¤Îʸ»úÎó¤òÊÝ»ý¤Ç¤¤ë¥µ¥¤¥º buflen ¤Î¥Ð¥Ã¥Õ¥¡ buf ¤¬¤¢¤ë¡£ ¤³¤ì¤é¤Î´Ø¿ô¤Î·ë²Ì (¥¹¥È¥ê¡¼¥à¤«¤éÆɤ߹þ¤Þ¤ì¤¿ struct group) ¤Ï¡¢ Ä󶡤µ¤ì¤¿¥Ð¥Ã¥Õ¥¡ *gbuf ¤Ë³ÊǼ¤µ¤ì¡¢¤³¤Î struct group ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ï *gbufp ¤ËÊÖ¤µ¤ì¤ë¡£
ÊÖ¤êÃÍ
À®¸ù¤·¤¿¾ì¹ç¡¢¤³¤ì¤é¤Î´Ø¿ô¤Ï 0 ¤òÊÖ¤·¡¢ *gbufp ¤Ï struct group ¤Ø¤Î¥Ý¥¤¥ó¥¿¤È¤Ê¤ë¡£ ¥¨¥é¡¼¤Î¾ì¹ç¡¢¤³¤ì¤é¤Î´Ø¿ô¤Ï¥¨¥é¡¼ÃͤòÊÖ¤·¡¢ *gbufp ¤Ï NULL ¤Ë¤Ê¤ë¡£¥¨¥é¡¼
- ENOENT
- ¼¡¤Î¥¨¥ó¥È¥ê¤¬¤Ê¤¤¡£
- ERANGE
- ½½Ê¬¤Ê¥Ð¥Ã¥Õ¥¡¶õ´Ö¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤¡£ ¤â¤Ã¤ÈÂ礤ʥХåե¡¤ÇºÆÅټ¹Ԥ¹¤ë¤³¤È¡£
½àµò
¤³¤ì¤é¤Î´Ø¿ô¤Ï GNU ³ÈÄ¥¤Ç¤¢¤ê¡¢POSIX ÈǤδؿô getpwnam_r(3) ¤Î·Á¼°¤Ë»÷¤»¤Æ¤¢¤ë¡£ ¾¤Î¥·¥¹¥Æ¥à¤Ç¤Ï°Ê²¼¤Î¥×¥í¥È¥¿¥¤¥×¤¬»È¤ï¤ì¤Æ¤¤¤ë¡£struct group * getgrent_r(struct group *grp, char *buf, int buflen);
¤è¤êÎɤ¤¤â¤Î¤Ç¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
int getgrent_r(struct group *grp, char *buf, int buflen, FILE **gr_fp);
Ãí°Õ
´Ø¿ô getgrent_r() ¤ÏËÜÅö¤Î¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤Ï¤Ê¤¤¡£ ¤Ê¤¼¤Ê¤é¡¢¥¹¥È¥ê¡¼¥à¤ÎÆɤ߹þ¤ß°ÌÃÖ¤ò ¾¤ÎÁ´¤Æ¤Î¥¹¥ì¥Ã¥É¤È¶¦Í¤·¤Æ¤¤¤ë¤¿¤á¤Ç¤¢¤ë¡£Îã
#define _GNU_SOURCE #include <grp.h> #include <stdio.h> #define BUFLEN 4096 int main(void) { struct group grp, *grpp; char buf[BUFLEN]; int i; setgrent(); while (1) { i = getgrent_r(&grp, buf, BUFLEN, &grpp); if (i) break; printf("%s (%d):", grpp->gr_name, grpp->gr_gid); for (i = 0; ; i++) { if (grpp->gr_mem[i] == NULL) break; printf(" %s", grpp->gr_mem[i]); } printf("\n"); } endgrent(); exit(EXIT_SUCCESS); }
´ØÏ¢¹àÌÜ
fgetgrent(3), getgrent(3), getgrgid(3), getgrnam(3), putgrent(3), group(5), feature_test_macros(7)Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre