OSSP CVS Repository

ossp - Difference in ossp-pkg/rc/rc_script.c versions 1.18 and 1.19
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/rc/rc_script.c 1.18 -> 1.19

--- rc_script.c  2003/05/20 15:06:42     1.18
+++ rc_script.c  2003/05/21 12:49:21     1.19
@@ -28,6 +28,9 @@
 */
 
 #include <string.h>
+#include <stdlib.h>
+#include <unistd.h>     /* For mkstemp(3)             */
+#include <fcntl.h>      /* For open(2)                */
 #include <ctype.h>      /* For isspace(3)             */
 #include <pwd.h>        /* For getlogin(2)            */
 
@@ -38,6 +41,21 @@
 
 
 /************************************************
+* scriptCopy(rc_script_t *)                     *
+* Copy constructor                              *
+************************************************/
+rc_script_t *scriptCopy(rc_script_t *pOrig)
+{
+    rc_script_t *pNew = NULL;
+
+    pNew = (rc_script_t *)malloc(sizeof(rc_script_t));
+    *pNew = malloc((strlen(scriptTostring(pOrig)) + 1) * sizeof(char));
+    strcpy(*pNew, scriptTostring(pOrig));
+
+    return(pNew);
+}
+
+/************************************************
 * scriptNew(void)                               *
 * Construct a script                            *
 ************************************************/
@@ -284,6 +302,26 @@
         return(RC_THROW(RC_OK));
     }
     else
+        return(RC_THROW(RC_ERR_USE));
+}
+
+/************************************************
+* scriptWrite(rc_script_t *, const char *)      *
+* Print a script to a file                      *
+************************************************/
+rc_return_t scriptWrite(rc_script_t *pScript, const char *szPath)
+{
+    int nFdtmp = open(szPath, O_WRONLY | O_CREAT, 0600);
+    FILE *pStream = fdopen(nFdtmp, "w");
+
+    /* Don't remove this! It encapsulates the script object, */
+    /*                    which might not be a simple string */
+    if (pScript && pStream) {
+        fprintf(pStream, "%s", *pScript);
+        fclose(pStream);
+        return(RC_THROW(RC_OK));
+    }
+    else
         return(RC_THROW(RC_ERR_USE));
 }
 

CVSTrac 2.0.1