ossp-pkg/rc/rc_sect.c 1.8 -> 1.9
--- rc_sect.c 2003/05/20 15:06:42 1.8
+++ rc_sect.c 2003/05/21 12:49:21 1.9
@@ -29,6 +29,8 @@
#include <string.h> /* For string copy and such data ops */
#include <stdlib.h> /* For memory ops */
+#include <unistd.h> /* For mktemp(3) */
+#include <fcntl.h> /* For open(2) */
#include "rc.h" /* Public Rc interface */
@@ -230,6 +232,25 @@
return(RC_THROW(RC_OK));
}
else
+ return(RC_THROW(RC_ERR_USE));
+}
+
+/************************************************
+* sectionWrite(rc_section_t *, const char *) *
+* Print a section to a file *
+************************************************/
+rc_return_t sectionWrite(rc_section_t *pSec, const char *szPath)
+{
+ int nFdtmp = open(szPath, O_WRONLY | O_CREAT, 0600);
+ FILE *pStream = fdopen(nFdtmp, "w");
+
+ if (pSec && pStream) {
+ fprintf(pStream, "#su %s\n", sectionGetlogin(pSec));
+ fprintf(pStream, "%s", sectionGetdata(pSec));
+ fclose(pStream);
+ return(RC_THROW(RC_OK));
+ }
+ else
return(RC_THROW(RC_ERR_USE));
}
|
|