Ignore:
Timestamp:
May 7, 2010, 6:49:10 PM (15 years ago)
Author:
herwigb
Message:

Split parameter string into separate parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0/src/splpd.c

    r28 r30  
    489489        char        arg[256];
    490490        char        *j_parms;
     491        int         allocSize = 0;
    491492        char        j_id[3];
    492493        char        parameters[256];
     
    506507        char        spool_dir[256];
    507508        ULONG       ulBootDrive;
     509        char        *p1 = NULL;
     510        char        *p2 = NULL;
     511        char        *p3 = NULL;
     512        char        *p4 = NULL;
     513        char        *p5 = NULL;
     514        char        *p6 = NULL;
     515        char        *p7 = NULL;
     516        char        *p8 = NULL;
     517        char        *p9 = NULL;
    508518
    509519        rc = PrfQueryProfileString (HINI_SYSTEMPROFILE,
     
    568578//      decryptPassword(password_enc,password_dec);
    569579
    570         j_parms = malloc((strlen(parameters) - strlen("%file%") + strlen(filename)) * sizeof(char));
    571 
    572         searchReplace("%file%", filename, parameters, j_parms);
     580//  allocate needed space for the returning string +1 (for string terminator)
     581        allocSize = strlen(parameters) - strlen("%file%") + strlen(filename);
     582
     583        j_parms = malloc((allocSize +1) * sizeof(char));
     584
     585//  searchReplace(search, replace, string, replaced, allocSize);
     586        searchReplace("%file%", filename, parameters, j_parms, allocSize);
     587
     588//  split into single paramters
     589        p1 = strtok (j_parms, " ");
     590        p2 = strtok (NULL, " ");
     591        p3 = strtok (NULL, " ");
     592        p4 = strtok (NULL, " ");
     593        p5 = strtok (NULL, " ");
     594        p6 = strtok (NULL, " ");
     595        p7 = strtok (NULL, " ");
     596        p8 = strtok (NULL, " ");
     597        p9 = strtok (NULL, " ");
    573598
    574599        if (strlen(workingdir) > 0)
     
    576601                chdir(workingdir);     
    577602        };
    578         rc = spawnlp(P_WAIT,binfile,binfile,j_parms,NULL);
     603
     604        rc = spawnlp(P_WAIT,binfile,binfile,p1,p2,p3,p4,p5,p6,p7,p8,p9,NULL);
    579605
    580606        while (rc != 0)
    581607        {
    582                 sprintf(errorstr,"Error during spooling to %s %s",binfile,j_parms);
     608                sprintf(errorstr,"Error during spooling to %s %s %s %s %s %s %s %s %s %s ",binfile,p1,p2,p3,p4,p5,p6,p7,p8,p9,NULL);
     609
    583610                resp = WinMessageBox (HWND_DESKTOP,
    584611                                                        HWND_DESKTOP,
     
    588615                if (resp != MBID_CANCEL )
    589616                {
    590                         rc = spawnlp(P_WAIT,binfile,binfile,j_parms,NULL);
     617                        rc = spawnlp(P_WAIT,binfile,binfile,p1,p2,p3,p4,p5,p6,p7,p8,p9,NULL);
    591618                }
    592619                else rc = 0;
     
    594621
    595622        free(j_parms);
     623       
    596624        strcpy(filename,&szTemp[pos]);
    597625        DosDelete(filename);
Note: See TracChangeset for help on using the changeset viewer.