- filename = get_conf_name(DLINE_TYPE);
-
- if((in = fopen(filename, "r")) == 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, source_p->name, filename);
- return 0;
- }
-
- oldumask = umask(0);
- if((out = fopen(temppath, "w")) == 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, source_p->name, temppath);
- fclose(in);
- umask(oldumask);
- return 0;
- }
-
- umask(oldumask);
-
- while (fgets(buf, sizeof(buf), in))
- {
- rb_strlcpy(buff, buf, sizeof(buff));
-
- if((p = strchr(buff, '\n')) != NULL)
- *p = '\0';
-
- if((*buff == '\0') || (*buff == '#'))
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- continue;
- }
-
- if((found_cidr = getfield(buff)) == NULL)
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- continue;
- }
-
- if(irccmp(found_cidr, cidr) == 0)
- {
- pairme++;
- }
- else
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- continue;
- }
- }
-
- fclose(in);
- if (fclose(out))
- error_on_write = YES;
-
- if(error_on_write)
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Couldn't write D-line file, aborted",
- me.name, source_p->name);
- return 0;
- }
- else if(!pairme)
- {
- sendto_one(source_p, ":%s NOTICE %s :No D-Line for %s",
- me.name, source_p->name, cidr);
-
- if(temppath != NULL)
- (void) unlink(temppath);