Changeset 20 for branches/1.0/src/uni.c
- Timestamp:
- Apr 18, 2010, 8:03:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/src/uni.c
r19 r20 61 61 62 62 /* replace one string by another */ 63 /*64 int main()65 {66 char string[100] = "ich bin ein file: %file%";67 char search[] = "%file%";68 char replace[] = "datei___datei";69 char *replaced;70 71 // allocate needed space for the returning string72 replaced = malloc((strlen(string) - strlen(search) + strlen(replace)) * sizeof(char));73 74 printf("vorher: %s\n", string);75 searchReplace(search, replace, string, replaced);76 printf("nachher: %s\n", replaced);77 78 free(replaced);79 return 0;80 }81 */82 83 63 BOOL searchReplace(const UCHAR *search, const UCHAR *replace, const UCHAR *string, UCHAR *replaced) 84 64 { 85 // creat init some variables 86 87 88 89 // do we find the searched string at all 90 91 92 93 94 95 96 97 // copy first part 98 99 100 101 // add the replaced string 102 103 104 // add the last part 105 106 107 108 65 /* create init some variables */ 66 UCHAR *searchStart; 67 int len = 0; 68 69 /* do we find the searched string at all */ 70 searchStart = strstr(string, search); 71 if (searchStart == NULL) 72 { 73 strncpy(replaced, string, strlen(replaced)); 74 return FALSE; 75 } 76 77 /* copy first part */ 78 len = searchStart - string; 79 strncpy(replaced, string, len); 80 81 /* add the replaced string */ 82 strcat(replaced, replace); 83 84 /* add the last part */ 85 len += strlen(search); 86 strcat(replaced, string+len); 87 88 return TRUE; 109 89 } 110 90 … … 270 250 WinSetDlgItemText(hDlg,ID_PARAMETERS,token); 271 251 break; 252 case 2: 253 if (token[ strlen(token) - 1 ] == ';') 254 token[ strlen(token)-1 ] = '\0'; 255 WinSetDlgItemText(hDlg,ID_DIRECTORY,token); 256 break; 272 257 } 273 258 i++; … … 292 277 strncat(szDesc, szTemp, STR_LEN_PORTDESC - 1); 293 278 } 294 strncat(szDesc, " ", STR_LEN_PORTDESC - 1);295 strncat(szDesc, szShareName, STR_LEN_PORTDESC - 1); 279 /* strncat(szDesc, " ", STR_LEN_PORTDESC - 1); 280 strncat(szDesc, szShareName, STR_LEN_PORTDESC - 1); */ 296 281 297 282 /* Parameters */ 298 283 WinQueryDlgItemText (hDlg, ID_PARAMETERS, sizeof(szTemp), szTemp ); 299 284 strcat(pLprData->szSaveLprSetting,szTemp); 300 strncpy(szShareName, szTemp, STR_LEN_PORTDESC - 1); 285 strcat(pLprData->szSaveLprSetting,"#"); 286 301 287 if (strlen(szTemp) > 0) { 302 strncat(sz ShareName, " ", STR_LEN_PORTDESC - 1);303 strncat(sz ShareName, szTemp, STR_LEN_PORTDESC - 1);288 strncat(szDesc, " ", STR_LEN_PORTDESC - 1); 289 strncat(szDesc, szTemp, STR_LEN_PORTDESC - 1); 304 290 } 291 /* strncat(szDesc, " ", STR_LEN_PORTDESC - 1); 292 strncat(szDesc, szShareName, STR_LEN_PORTDESC - 1); */ 305 293 306 /* Printername | Queue */ 307 /* WinQueryDlgItemText (hDlg, ID_UNIQUEUE, sizeof(szTemp), szTemp ); 308 strcat(pLprData->szSaveLprSetting,"#"); 294 /* Working directory */ 295 WinQueryDlgItemText (hDlg, ID_DIRECTORY, sizeof(szTemp), szTemp ); 309 296 strcat(pLprData->szSaveLprSetting,szTemp); 310 if (strlen(szTemp) > 0) { 297 /* strcat(pLprData->szSaveLprSetting,"#"); */ 298 299 /* if (strlen(szTemp) > 0) { 311 300 strncat(szShareName, "\\", STR_LEN_PORTDESC - 1); 312 301 strncat(szShareName, szTemp, STR_LEN_PORTDESC - 1); … … 1012 1001 UCHAR j_id[3]; 1013 1002 UCHAR parameters[256]; 1003 UCHAR workingdir[256] ; 1014 1004 UCHAR j_title[256]; 1015 1005 UCHAR j_copies[3]; … … 1065 1055 case 1:strcpy(parameters,&szTemp[pos]); 1066 1056 break; 1067 /* case 2:strcpy(workgroup,&szTemp[pos]);1057 case 2:strcpy(workingdir,&szTemp[pos]); 1068 1058 break; 1069 case 3:strcpy(username,&szTemp[pos]);1059 /* case 3:strcpy(username,&szTemp[pos]); 1070 1060 break; 1071 1061 case 4:strcpy(j_copies,&szTemp[pos]); … … 1103 1093 while (rc != 0) 1104 1094 { 1105 sprintf(errorstr,"Error during spooling to smb://%s:****@%s/%s/%s",username,workgroup,ip_add,queue_name);1095 sprintf(errorstr,"Error during spooling %s to %s %s",queue_name,binfile,j_parms); 1106 1096 resp = WinMessageBox (HWND_DESKTOP, 1107 1097 HWND_DESKTOP,
Note:
See TracChangeset
for help on using the changeset viewer.