Changeset 17


Ignore:
Timestamp:
Apr 16, 2010, 4:29:34 PM (15 years ago)
Author:
herwigb
Message:

Some more changes

File:
1 edited

Legend:

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

    r16 r17  
    5959#include    <process.h>
    6060#include    "UNI.h"
     61
     62/*  replace one string by another */
     63char * stringReplace(char *search, char *replace, char *string) {
     64        char *tempString, *searchStart;
     65        int len=0;
     66        // preuefe ob Such-String vorhanden ist
     67        searchStart = strstr(string, search);
     68        if(searchStart == NULL) {
     69                return string;
     70        }
     71        // Speicher reservieren
     72        tempString = (char*) malloc((strlen(string) + strlen(replace) - strlen(search))* sizeof(char));
     73        // temporaere Kopie anlegen
     74        strcpy(tempString, string);
     75        // ersten Abschnitt in String setzen
     76        len = searchStart - string;
     77        strncpy(string, tempString, len);
     78        // zweiten Abschnitt anhaengen
     79        strcat(string, replace);
     80        // dritten Abschnitt anhaengen
     81        len += strlen(search);
     82        strcat(string,  (char *)tempString+len);
     83        return string;
     84}
     85
    6186
    6287/* Password encryption/decryption routines from ndpsmb.c */
     
    10371062// Usage: smbspool [DEVICE_URI] job-id user title copies options [file]
    10381063
     1064
    10391065        sprintf(j_parms,parameters);
    1040         rc = spawnlp(P_WAIT,binfile,binfile,j_parms,filename,NULL);
     1066        stringReplace("%file%",filename,j_parms);
     1067       
     1068        rc = spawnlp(P_WAIT,binfile,binfile,j_parms,NULL);
    10411069
    10421070        while (rc != 0)
     
    10501078                if (resp != MBID_CANCEL )
    10511079                {
    1052                         rc = spawnlp(P_WAIT,binfile,binfile,j_parms,filename,NULL);
     1080                        rc = spawnlp(P_WAIT,binfile,binfile,j_parms,NULL);
    10531081                }
    10541082                else rc = 0;
Note: See TracChangeset for help on using the changeset viewer.