6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
11 #include <sys/fcntl.h>
20 static FILE *rmfp = NULL;
23 setrmtabent(char *type)
27 rmfp = fsetrmtabent(_PATH_RMTAB, type);
28 return (rmfp != NULL);
32 fsetrmtabent(char *fname, char *type)
34 int readonly = !strcmp(type, "r");
39 if ((fp = fopen(fname, type)) == NULL) {
40 xlog(L_ERROR, "can't open %s for %sing", fname,
41 readonly ? "read" : "writ");
50 return fgetrmtabent(rmfp, log);
54 fgetrmtabent(FILE *fp, int log)
56 static struct rmtabent re;
63 if (fgets(buf, sizeof(buf)-1, fp) == NULL)
65 if ((sp = strchr(buf, '\n')) != NULL)
67 if (!(sp = strchr(buf, ':'))) {
69 xlog(L_ERROR, "malformed entry in rmtab file");
75 strncpy(re.r_client, buf, sizeof (re.r_client) - 1);
76 re.r_client[sizeof (re.r_client) - 1] = '\0';
77 strncpy(re.r_path, sp, sizeof (re.r_path) - 1);
78 re.r_path[sizeof (re.r_path) - 1] = '\0';
83 putrmtabent(struct rmtabent *rep)
85 fputrmtabent(rmfp, rep);
89 fputrmtabent(FILE *fp, struct rmtabent *rep)
93 fprintf(fp, "%s:%s\n", rep->r_client, rep->r_path);
104 fendrmtabent(FILE *fp)
118 frewindrmtabent(FILE *fp)