OSSP CVS Repository

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

ossp-pkg/rc/rc_script.c 1.15 -> 1.16

--- rc_script.c  2003/05/15 22:22:30     1.15
+++ rc_script.c  2003/05/16 12:37:10     1.16
@@ -29,6 +29,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>      /* For isspace(3)             */
 
 #include "rc.h"         /* Public Rc interface        */
 #include "rc_pcre.h"    /* For section parsing        */
@@ -111,6 +112,7 @@
     char *piEnd        = NULL;
     long  nPri         = 0;
     long  nUid         = 0;
+    int nTmp           = 0;
     int nOffset        = 0;
     int nFound         = 0;
     int nVecsize       = 0;
@@ -172,8 +174,6 @@
         piLabstart = piBlocend + *(pnVec + 2);
         nLabsize   = *(pnVec + 3) - *(pnVec + 2);
 
-/*fprintf(stderr, "Substring we want ist %s!\n", kszSecname);
-fprintf(stderr, "Compared with ist %s!\n", piLabstart);*/
         /* Test the substring. If it matches our label, make a new section */
         if (!strncmp(piLabstart, kszSecname, nLabsize)) {
             /* Handle the section body */
@@ -182,21 +182,32 @@
             pSec = sectionNew();
             sectionSetndata(pSec, piStart, piEnd - piStart);
 
+            /* FIXME: Implement --ParseSectionParam for extra gravy */
             /* Handle the section priority */
             piStart = piBlocend + *(pnVec + 4);
             piEnd   = piBlocend + *(pnVec + 5);
-            /* FIXME: Implement --ParseSectionParam for extra gravy */
             piSubtemp = strnstr(piStart, RC_DEF_PRG, piEnd - piStart);
             if (piSubtemp) { /* Priority pattern found */
-/* FIXME: Remove the 1 in the following line! */
-                nPri = strtol(piSubtemp + strlen(RC_DEF_PRG), (char **)NULL, 10);
+                for (nTmp = (int)piSubtemp + strlen(RC_DEF_PRG);\
+                    isspace(*(char *)nTmp); nTmp += sizeof (char)); /* Strip */
+                nPri = strtol((char *)nTmp, (char **)NULL, 10);
                 sectionSetpri(pSec, nPri);
             }
             else /* Fallback to default value */
                 sectionSetpri(pSec, RC_DEF_PRI);
 
             /* Handle the section userid   */
-            return(pSec);   /* Section found, so return the text */
+            piSubtemp = strnstr(piStart, RC_DEF_UIG, piEnd - piStart);
+            if (piSubtemp) { /* Priority pattern found */
+                for (nTmp = (int)piSubtemp + strlen(RC_DEF_UIG);\
+                    isspace(*(char *)nTmp); nTmp += sizeof (char)); /* Strip */
+                nUid = strtol((char *)nTmp, (char **)NULL, 10);
+                sectionSetuid(pSec, nUid);
+            }
+            else /* Fallback to default value */
+                sectionSetuid(pSec, RC_DEF_UID);
+
+            return(pSec); /* Section found, so return the text */
         }
 
         /* Looks like we didn't find the section yet, so keep trying */

CVSTrac 2.0.1