MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gr_init

Function gr_init

tools/libutil/gr_util.c:60–92  ·  view source on GitHub ↗

* Initialize statics */

Source from the content-addressed store, hash-verified

58 * Initialize statics
59 */
60int
61gr_init(const char *dir, const char *group)
62{
63
64 if (dir == NULL) {
65 strcpy(group_dir, _PATH_ETC);
66 } else {
67 if (strlen(dir) >= sizeof(group_dir)) {
68 errno = ENAMETOOLONG;
69 return (-1);
70 }
71 strcpy(group_dir, dir);
72 }
73
74 if (group == NULL) {
75 if (dir == NULL) {
76 strcpy(group_file, _PATH_GROUP);
77 } else if (snprintf(group_file, sizeof(group_file), "%s/group",
78 group_dir) > (int)sizeof(group_file)) {
79 errno = ENAMETOOLONG;
80 return (-1);
81 }
82 } else {
83 if (strlen(group) >= sizeof(group_file)) {
84 errno = ENAMETOOLONG;
85 return (-1);
86 }
87 strcpy(group_file, group);
88 }
89
90 initialized = 1;
91 return (0);
92}
93
94/*
95 * Lock the group file

Callers

nothing calls this directly

Calls 1

snprintfFunction · 0.85

Tested by

no test coverage detected