free (p->line);
- if (NULL != p->eptr) {
- db->ops->free (p->eptr);
- }
+ if (NULL != p->eptr)
+ db->ops->cio_free(p->eptr);
free (p);
}
struct commonio_entry *p;
for (p = db->head; NULL != p; p = p->next) {
- if (name_is_nis (p->eptr ? db->ops->getname (p->eptr)
+ if (name_is_nis (p->eptr ? db->ops->cio_getname(p->eptr)
: p->line)) {
/*@-mustfreeonly@*/
newp->next = p;
if (NULL == buf)
goto cleanup_errno;
- while (db->ops->fgets (buf, buflen, db->fp) == buf) {
+ while (db->ops->cio_fgets(buf, buflen, db->fp) == buf) {
struct commonio_entry *p;
while ( (strrchr (buf, '\n') == NULL)
goto cleanup_errno;
len = strlen (buf);
- if (db->ops->fgets (buf + len,
- (int) (buflen - len),
- db->fp) == NULL) {
+ if (db->ops->cio_fgets(buf + len, buflen - len, db->fp) == NULL)
goto cleanup_buf;
- }
}
stpsep(buf, "\n");
if (name_is_nis (line)) {
eptr = NULL;
} else {
- eptr = db->ops->parse (line);
+ eptr = db->ops->cio_parse(line);
if (NULL != eptr) {
- eptr = db->ops->dup (eptr);
+ eptr = db->ops->cio_dup(eptr);
if (NULL == eptr) {
goto cleanup_line;
}
goto cleanup_errno;
}
- if ((NULL != db->ops->open_hook) && (db->ops->open_hook () == 0)) {
+ if ((NULL != db->ops->cio_open_hook) && (db->ops->cio_open_hook() == 0)) {
goto cleanup_errno;
}
return 1;
cleanup_entry:
- if (NULL != eptr) {
- db->ops->free (eptr);
- }
+ if (NULL != eptr)
+ db->ops->cio_free(eptr);
cleanup_line:
free (line);
cleanup_buf:
if (NULL == pw_ptr->eptr) {
continue;
}
- name = passwd->ops->getname (pw_ptr->eptr);
+ name = passwd->ops->cio_getname(pw_ptr->eptr);
for (spw_ptr = shadow->head;
NULL != spw_ptr;
spw_ptr = spw_ptr->next) {
if (NULL == spw_ptr->eptr) {
continue;
}
- if (streq(name, shadow->ops->getname(spw_ptr->eptr)))
+ if (streq(name, shadow->ops->cio_getname(spw_ptr->eptr)))
break;
}
if (NULL == spw_ptr) {
if (p->changed) {
eptr = p->eptr;
assert (NULL != eptr);
- if (db->ops->put (eptr, db->fp) != 0) {
+ if (db->ops->cio_put(eptr, db->fp) != 0) {
return -1;
}
} else if (NULL != p->line) {
- if (db->ops->fputs (p->line, db->fp) == EOF) {
+ if (db->ops->cio_fputs(p->line, db->fp) == EOF)
return -1;
- }
+
if (putc ('\n', db->fp) == EOF) {
return -1;
}
goto success;
}
- if ((NULL != db->ops->close_hook) && (db->ops->close_hook () == 0)) {
+ if ((NULL != db->ops->cio_close_hook) && (db->ops->cio_close_hook() == 0)) {
goto fail;
}
for (p = pos; NULL != p; p = p->next) {
ep = p->eptr;
if ( (NULL != ep)
- && streq(db->ops->getname(ep), name)) {
+ && streq(db->ops->cio_getname(ep), name)) {
break;
}
}
errno = EINVAL;
return 0;
}
- nentry = db->ops->dup (eptr);
+ nentry = db->ops->cio_dup(eptr);
if (NULL == nentry) {
errno = ENOMEM;
return 0;
}
- p = find_entry_by_name (db, db->ops->getname (eptr));
+ p = find_entry_by_name(db, db->ops->cio_getname(eptr));
if (NULL != p) {
- if (next_entry_by_name (db, p->next, db->ops->getname (eptr)) != NULL) {
- fprintf (shadow_logfd, _("Multiple entries named '%s' in %s. Please fix this with pwck or grpck.\n"), db->ops->getname (eptr), db->filename);
- db->ops->free (nentry);
+ if (next_entry_by_name(db, p->next, db->ops->cio_getname(eptr)) != NULL) {
+ fprintf(shadow_logfd, _("Multiple entries named '%s' in %s. Please fix this with pwck or grpck.\n"), db->ops->cio_getname(eptr), db->filename);
+ db->ops->cio_free(nentry);
return 0;
}
- db->ops->free (p->eptr);
+ db->ops->cio_free(p->eptr);
p->eptr = nentry;
p->changed = true;
db->cursor = p;
/* not found, new entry */
p = MALLOC(1, struct commonio_entry);
if (NULL == p) {
- db->ops->free (nentry);
+ db->ops->cio_free(nentry);
errno = ENOMEM;
return 0;
}
errno = EINVAL;
return 0;
}
- nentry = db->ops->dup (eptr);
+ nentry = db->ops->cio_dup(eptr);
if (NULL == nentry) {
errno = ENOMEM;
return 0;
/* new entry */
p = MALLOC(1, struct commonio_entry);
if (NULL == p) {
- db->ops->free (nentry);
+ db->ops->cio_free(nentry);
errno = ENOMEM;
return 0;
}
free (p->line);
- if (NULL != p->eptr) {
- db->ops->free (p->eptr);
- }
+ if (NULL != p->eptr)
+ db->ops->cio_free(p->eptr);
free(p);
* Make a copy of the object (for example, struct passwd)
* and all strings pointed by it, in malloced memory.
*/
- /*@null@*/ /*@only@*/void *(*dup) (const void *);
+ /*@null@*/ /*@only@*/void *(*cio_dup)(const void *);
/*
* free() the object including any strings pointed by it.
*/
- void (*free)(/*@only@*/void *);
+ void (*cio_free)(/*@only@*/void *);
/*
* Return the name of the object (for example, pw_name
* for struct passwd).
*/
- const char *(*getname) (const void *);
+ const char *(*cio_getname)(const void *);
/*
* Parse a string, return object (in static area -
* should be copied using the dup operation above).
*/
- void *(*parse) (const char *);
+ void *(*cio_parse)(const char *);
/*
* Write the object to the file (this calls putpwent()
* for struct passwd, for example).
*/
- int (*put) (const void *, FILE *);
+ int (*cio_put)(const void *, FILE *);
/*
* fgets and fputs (can be replaced by versions that
* understand line continuation conventions).
*/
ATTR_ACCESS(write_only, 1, 2)
- /*@null@*/char *(*fgets)(/*@returned@*/char *restrict s, int n,
+ /*@null@*/char *(*cio_fgets)(/*@returned@*/char *restrict s, int n,
FILE *restrict stream);
- int (*fputs) (const char *, FILE *);
+ int (*cio_fputs)(const char *, FILE *);
/*
* open_hook and close_hook.
* is open or before it is closed.
* They return 0 on failure and 1 on success.
*/
- /*@null@*/int (*open_hook) (void);
- /*@null@*/int (*close_hook) (void);
+ /*@null@*/int (*cio_open_hook)(void);
+ /*@null@*/int (*cio_close_hook)(void);
};
/*