OSSP CVS Repository

ossp - Check-in [3343]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3343
Date: 2003-May-16 14:37:10 (local)
2003-May-16 12:37:10 (UTC)
User:ms
Branch:
Comment: Bugfix and cleanup priority scheduling, and add similar userid parameter handling.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc_const.h      1.13 -> 1.14     2 inserted, 0 deleted
ossp-pkg/rc/rc_script.c      1.15 -> 1.16     17 inserted, 6 deleted

ossp-pkg/rc/rc_const.h 1.13 -> 1.14

--- rc_const.h   2002/08/02 20:09:59     1.13
+++ rc_const.h   2003/05/16 12:37:10     1.14
@@ -125,6 +125,8 @@
 #define RC_DEF_OFF    "0"                       /* Digital switch */
 #define RC_DEF_DEF    "^%(\\w+)[ \t]*(.*?)\\n(.*?)^$" /* Section definition */
 #define RC_DEF_NCF    "config"                  /* Config section name */
+#define RC_DEF_UIG    "-u"                      /* Section user string */
+#define RC_DEF_UID    -1                        /* Section user value  */
 #define RC_DEF_PRG    "-p"                      /* Section priority string */
 #define RC_DEF_PRI    200                       /* Section priority value */
 


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