Lines Matching refs:fp
84 static int dki_readfile (FILE *fp, dki_t *dkp)
94 assert (fp != NULL);
96 while ( (c = getc (fp)) == ';' ) /* line start with comment ? */
99 if ( (c = getc (fp)) == '%' ) /* special comment? */
101 while ( (c = getc (fp)) == ' ' || c == '\t' )
103 ungetc (c, fp);
105 if ( fscanf (fp, "%25[a-zA-Z]=%14s", tag, val) == 2 )
117 ungetc (c, fp);
118 while ( (c = getc (fp)) != EOF && c != '\n' ) /* eat up rest of the line */
121 ungetc (c, fp); /* push back last char */
123 if ( fscanf (fp, "%4095s", buf) != 1 ) /* read label */
131 while ( (c = getc (fp)) != EOF && isspace (c) ) /* skip spaces */
134 fscanf (fp, "%*d");
136 ungetc (c, fp); /* oops, no ttl */
139 if ( (c = fscanf (fp, " IN DNSKEY %d %d %d", &flags, &type, &algo)) != 3 &&
140 (c = fscanf (fp, "KEY %d %d %d", &flags, &type, &algo)) != 3 )
148 if ( fgets (buf, sizeof buf, fp) == NULL || buf[0] == '\0' )
163 FILE *fp;
168 if ( (fp = fopen (path, "w")) == NULL )
171 if ( dki_prt_dnskey_raw (dkp, fp) == 0 )
173 fclose (fp);
245 FILE *fp;
270 if ( (fp = popen (cmdline, "r")) == NULL || fgets (fname, sizeof fname, fp) == NULL )
272 pclose (fp);
292 FILE *fp;
333 if ( (fp = fopen (path, "r")) == NULL )
341 if ( (err = dki_readfile (fp, dkp)) != 0 )
346 fclose (fp);
351 if ( fstat (fileno(fp), &st) )
384 fclose (fp);
679 int dki_prt_dnskey (const dki_t *dkp, FILE *fp)
681 return dki_prt_dnskeyttl (dkp, fp, 0);
687 int dki_prt_dnskeyttl (const dki_t *dkp, FILE *fp, int ttl)
694 fprintf (fp, "%s ", dkp->name);
696 fprintf (fp, "%d ", ttl);
697 fprintf (fp, "IN DNSKEY ");
698 fprintf (fp, "%d 3 %d (", dkp->flags, dkp->algo);
699 fprintf (fp, "\n\t\t\t");
702 fprintf (fp, "\n\t\t\t");
704 putc (*p, fp);
705 fprintf (fp, "\n\t\t");
707 fprintf (fp, ") ; key id = %u (original key id = %u)", (dkp->tag + 128) % 65535, dkp->tag);
709 fprintf (fp, ") ; key id = %u", dkp->tag);
710 fprintf (fp, "\n");
718 int dki_prt_dnskey_raw (const dki_t *dkp, FILE *fp)
726 fprintf (fp, ";%%\tgenerationtime=%s\n", time2isostr (dkp->gentime, 's'));
728 fprintf (fp, ";%%\tlifetime=%dd\n", days);
730 fprintf (fp, ";%%\texpirationtime=%s\n", time2isostr (dkp->exptime, 's'));
732 fprintf (fp, "%s ", dkp->name);
735 fprintf (fp, "%d ", ttl);
737 fprintf (fp, "IN DNSKEY ");
738 fprintf (fp, "%d 3 %d ", dkp->flags, dkp->algo);
739 fprintf (fp, "%s\n", dkp->pubkey);
747 int dki_prt_comment (const dki_t *dkp, FILE *fp)
753 len += fprintf (fp, "; %s ", dkp->name);
754 len += fprintf (fp, "tag=%u ", dkp->tag);
755 len += fprintf (fp, "algo=%s ", dki_algo2str(dkp->algo));
756 len += fprintf (fp, "generated %s\n", time2str (dkp->time, 's'));
764 int dki_prt_trustedkey (const dki_t *dkp, FILE *fp)
772 len += fprintf (fp, "\"%s\" ", dkp->name);
774 len += fprintf (fp, "%*s", spaces > 0 ? spaces : 0 , " ");
775 len += fprintf (fp, "%d 3 %d ", dkp->flags, dkp->algo);
777 len += fprintf (fp, "\n\t\t\t%7s", " ");
778 len += fprintf (fp, "\"");
781 len += fprintf (fp, "\n\t\t\t\t");
783 putc (*p, fp), len += 1;
786 len += fprintf (fp, "\" ; # key id = %u (original key id = %u)\n\n", (dkp->tag + 128) % 65535, dkp->tag);
788 len += fprintf (fp, "\" ; # key id = %u\n\n", dkp->tag);