Subversion Repositories filter_foundry

Rev

Rev 390 | Rev 394 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 390 Rev 393
Line 153... Line 153...
153
        photoshop->unknown3 = premiere->unknown3;
153
        photoshop->unknown3 = premiere->unknown3;
154
        for (i=0;i<4;++i)
154
        for (i=0;i<4;++i)
155
                photoshop->map_used[i] = premiere->map_used[i];
155
                photoshop->map_used[i] = premiere->map_used[i];
156
        for (i=0;i<8;++i)
156
        for (i=0;i<8;++i)
157
                photoshop->ctl_used[i] = premiere->ctl_used[i];
157
                photoshop->ctl_used[i] = premiere->ctl_used[i];
158
        sprintf((char*)photoshop->category, "Filter Factory"); // Premiere plugins do not have a category attribute
158
        sprintf(photoshop->szCategory, "Filter Factory"); // Premiere plugins do not have a category attribute
159
        photoshop->iProtected = 0; // Premiere plugins do not have a protect flag
159
        photoshop->iProtected = 0; // Premiere plugins do not have a protect flag
160
        memcpy((void*)photoshop->title, (void*)premiere->title, sizeof(photoshop->title));
160
        memcpy((void*)photoshop->szTitle, (void*)premiere->szTitle, sizeof(photoshop->szTitle));
161
        memcpy((void*)photoshop->copyright, (void*)premiere->copyright, sizeof(photoshop->copyright));
161
        memcpy((void*)photoshop->szCopyright, (void*)premiere->szCopyright, sizeof(photoshop->szCopyright));
162
        memcpy((void*)photoshop->author, (void*)premiere->author, sizeof(photoshop->author));
162
        memcpy((void*)photoshop->szAuthor, (void*)premiere->szAuthor, sizeof(photoshop->szAuthor));
163
        for (i=0;i<4;++i)
163
        for (i=0;i<4;++i)
164
                memcpy((void*)photoshop->map[i], (void*)premiere->map[i], sizeof(photoshop->map[i]));
164
                memcpy((void*)photoshop->szMap[i], (void*)premiere->szMap[i], sizeof(photoshop->szMap[i]));
165
        for (i=0;i<8;++i)
165
        for (i=0;i<8;++i)
166
                memcpy((void*)photoshop->ctl[i], (void*)premiere->ctl[i], sizeof(photoshop->ctl[i]));
166
                memcpy((void*)photoshop->szCtl[i], (void*)premiere->szCtl[i], sizeof(photoshop->szCtl[i]));
167
 
167
 
168
        if (premiere->singleExpression) {
168
        if (premiere->singleExpression) {
169
                memcpy((void*)photoshop->formula[0], (void*)premiere->formula[3], sizeof(photoshop->formula[3]));
169
                memcpy((void*)photoshop->szFormula[0], (void*)premiere->szFormula[3], sizeof(photoshop->szFormula[3]));
170
                memcpy((void*)photoshop->formula[1], (void*)premiere->formula[3], sizeof(photoshop->formula[3]));
170
                memcpy((void*)photoshop->szFormula[1], (void*)premiere->szFormula[3], sizeof(photoshop->szFormula[3]));
171
                memcpy((void*)photoshop->formula[2], (void*)premiere->formula[3], sizeof(photoshop->formula[3]));
171
                memcpy((void*)photoshop->szFormula[2], (void*)premiere->szFormula[3], sizeof(photoshop->szFormula[3]));
172
                memcpy((void*)photoshop->formula[3], (void*)premiere->formula[3], sizeof(photoshop->formula[3]));
172
                memcpy((void*)photoshop->szFormula[3], (void*)premiere->szFormula[3], sizeof(photoshop->szFormula[3]));
173
        } else {
173
        } else {
174
                memcpy((void*)photoshop->formula[0], (void*)premiere->formula[2], sizeof(photoshop->formula[2]));
174
                memcpy((void*)photoshop->szFormula[0], (void*)premiere->szFormula[2], sizeof(photoshop->szFormula[2]));
175
                memcpy((void*)photoshop->formula[1], (void*)premiere->formula[1], sizeof(photoshop->formula[1]));
175
                memcpy((void*)photoshop->szFormula[1], (void*)premiere->szFormula[1], sizeof(photoshop->szFormula[1]));
176
                memcpy((void*)photoshop->formula[2], (void*)premiere->formula[0], sizeof(photoshop->formula[0]));
176
                memcpy((void*)photoshop->szFormula[2], (void*)premiere->szFormula[0], sizeof(photoshop->szFormula[0]));
177
                memcpy((void*)photoshop->formula[3], (void*)premiere->formula[3], sizeof(photoshop->formula[3]));
177
                memcpy((void*)photoshop->szFormula[3], (void*)premiere->szFormula[3], sizeof(photoshop->szFormula[3]));
178
        }
178
        }
179
}
179
}
180
 
180
 
181
char* _ffx_read_str(char** q) {
181
char* _ffx_read_str(char** q) {
182
        uint32_t len;
182
        uint32_t len;
Line 215... Line 215...
215
                                free(val);
215
                                free(val);
216
                                if (format_version > 0) {
216
                                if (format_version > 0) {
217
                                        simplewarning(_strdup("Attention! You are loading a \"Filters Unlimited\" file. Please note that Filter Foundry only implements the basic Filter Factory functions. Therefore, most \"Filters Unlimited\" filters won't work with Filter Foundry."));
217
                                        simplewarning(_strdup("Attention! You are loading a \"Filters Unlimited\" file. Please note that Filter Foundry only implements the basic Filter Factory functions. Therefore, most \"Filters Unlimited\" filters won't work with Filter Foundry."));
218
 
218
 
219
                                        val = _ffx_read_str(&q);
219
                                        val = _ffx_read_str(&q);
220
                                        myc2pstrcpy(gdata->parm.title, val);
220
                                        strcpy(gdata->parm.szTitle, val);
221
                                        free(val);
221
                                        free(val);
222
 
222
 
223
                                        val = _ffx_read_str(&q);
223
                                        val = _ffx_read_str(&q);
224
                                        myc2pstrcpy(gdata->parm.category, val);
224
                                        strcpy(gdata->parm.szCategory, val);
225
                                        free(val);
225
                                        free(val);
226
 
226
 
227
                                        val = _ffx_read_str(&q);
227
                                        val = _ffx_read_str(&q);
228
                                        myc2pstrcpy(gdata->parm.author, val);
228
                                        strcpy(gdata->parm.szAuthor, val);
229
                                        free(val);
229
                                        free(val);
230
 
230
 
231
                                        val = _ffx_read_str(&q);
231
                                        val = _ffx_read_str(&q);
232
                                        myc2pstrcpy(gdata->parm.copyright, val);
232
                                        strcpy(gdata->parm.szCopyright, val);
233
                                        free(val);
233
                                        free(val);
234
 
234
 
235
                                        // Channels I, R, G, B, A
235
                                        // Channels I, R, G, B, A
236
                                        for (i = 0; i < 4; i++) {
236
                                        for (i = 0; i < 4; i++) {
237
                                                val = _ffx_read_str(&q);
237
                                                val = _ffx_read_str(&q);
Line 252... Line 252...
252
                                                        else {
252
                                                        else {
253
                                                                free(val);
253
                                                                free(val);
254
                                                                val = val2;
254
                                                                val = val2;
255
                                                        }
255
                                                        }
256
                                                }
256
                                                }
257
                                                if (strlen(val) >= sizeof(gdata->parm.formula[i])) {
257
                                                if (strlen(val) >= sizeof(gdata->parm.szFormula[i])) {
258
                                                        if (i == 0) {
258
                                                        if (i == 0) {
259
                                                                simplealert(_strdup("Attention! The formula for channel I/R was too long (longer than 1023 characters) and was truncated."));
259
                                                                simplealert(_strdup("Attention! The formula for channel I/R was too long (longer than 1023 characters) and was truncated."));
260
                                                        }
260
                                                        }
261
                                                        else if (i == 1) {
261
                                                        else if (i == 1) {
262
                                                                simplealert(_strdup("Attention! The formula for channel G was too long (longer than 1023 characters) and was truncated."));
262
                                                                simplealert(_strdup("Attention! The formula for channel G was too long (longer than 1023 characters) and was truncated."));
Line 267... Line 267...
267
                                                        else if (i == 3) {
267
                                                        else if (i == 3) {
268
                                                                simplealert(_strdup("Attention! The formula for channel A was too long (longer than 1023 characters) and was truncated."));
268
                                                                simplealert(_strdup("Attention! The formula for channel A was too long (longer than 1023 characters) and was truncated."));
269
                                                        }
269
                                                        }
270
                                                        // C++ wrong warning: Buffer overflow (C6386)
270
                                                        // C++ wrong warning: Buffer overflow (C6386)
271
                                                        #pragma warning(suppress : 6386)
271
                                                        #pragma warning(suppress : 6386)
272
                                                        val[sizeof(gdata->parm.formula[i]) - 1] = '\0';
272
                                                        val[sizeof(gdata->parm.szFormula[i]) - 1] = '\0';
273
                                                }
273
                                                }
274
                                                expr[i] = my_strdup(val);
274
                                                expr[i] = my_strdup(val);
275
                                                strcpy((char*)gdata->parm.formula[i], val); // Attention! This is not a Pascal string!
275
                                                strcpy(gdata->parm.szFormula[i], val);
276
                                                free(val);
276
                                                free(val);
277
                                        }
277
                                        }
278
 
278
 
279
                                        // Sliders
279
                                        // Sliders
280
                                        for (i = 0; i < 8; i++) {
280
                                        for (i = 0; i < 8; i++) {
Line 284... Line 284...
284
                                                if (format_version >= 12) {
284
                                                if (format_version >= 12) {
285
                                                        // Format FFX1.2 has prefixes {S} = Slider, {C} = Checkbox, none = Slider
285
                                                        // Format FFX1.2 has prefixes {S} = Slider, {C} = Checkbox, none = Slider
286
                                                        if ((sliderName[0] == '{') && (sliderName[1] == 'S') && (sliderName[2] == '}')) sliderName += 3;
286
                                                        if ((sliderName[0] == '{') && (sliderName[1] == 'S') && (sliderName[2] == '}')) sliderName += 3;
287
                                                        else if ((sliderName[0] == '{') && (sliderName[1] == 'C') && (sliderName[2] == '}')) sliderName += 3;
287
                                                        else if ((sliderName[0] == '{') && (sliderName[1] == 'C') && (sliderName[2] == '}')) sliderName += 3;
288
                                                }
288
                                                }
289
                                                myc2pstrcpy(gdata->parm.ctl[i], sliderName);
289
                                                strcpy(gdata->parm.szCtl[i], sliderName);
290
                                                free(val);
290
                                                free(val);
291
                                                gdata->parm.ctl_used[i] = (bool32_t)*((byte*)q);
291
                                                gdata->parm.ctl_used[i] = (bool32_t)*((byte*)q);
292
                                                q += sizeof(byte);
292
                                                q += sizeof(byte);
293
                                                gdata->parm.val[i] = *((uint32_t*)q);
293
                                                gdata->parm.val[i] = *((uint32_t*)q);
294
                                                slider[i] = *((uint32_t*)q);
294
                                                slider[i] = *((uint32_t*)q);
295
                                                q += sizeof(uint32_t);
295
                                                q += sizeof(uint32_t);
296
                                        }
296
                                        }
297
 
297
 
298
                                        // Maps (are not part of the format!)
298
                                        // Maps (are not part of the format!)
299
                                        strcpy((char*)gdata->parm.map[0], "\006Map 0:");
299
                                        strcpy(gdata->parm.szMap[0], "Map 0:");
300
                                        strcpy((char*)gdata->parm.map[1], "\006Map 1:");
300
                                        strcpy(gdata->parm.szMap[1], "Map 1:");
301
                                        strcpy((char*)gdata->parm.map[2], "\006Map 2:");
301
                                        strcpy(gdata->parm.szMap[2], "Map 2:");
302
                                        strcpy((char*)gdata->parm.map[3], "\006Map 3:");
302
                                        strcpy(gdata->parm.szMap[3], "Map 3:");
303
 
303
 
304
                                        res = true;
304
                                        res = true;
305
                                }
305
                                }
306
                        }
306
                        }
307
                        PIDISPOSEHANDLE(h);
307
                        PIDISPOSEHANDLE(h);
Line 357... Line 357...
357
                                                // Case #3: Windows is reading an old FilterFactory Mac file
357
                                                // Case #3: Windows is reading an old FilterFactory Mac file
358
                                                // Note: You must read the ".rsrc" resource fork, not the standalone binary!
358
                                                // Note: You must read the ".rsrc" resource fork, not the standalone binary!
359
                                                else if( ((EndianS32_LtoN(q[0]) == PARM_SIZE) ||
359
                                                else if( ((EndianS32_LtoN(q[0]) == PARM_SIZE) ||
360
                                                     (EndianS32_LtoN(q[0]) == PARM_SIZE_PREMIERE) ||
360
                                                     (EndianS32_LtoN(q[0]) == PARM_SIZE_PREMIERE) ||
361
                                                     (EndianS32_LtoN(q[0]) == PARM_SIG_MAC)) && EndianS32_LtoN(q[1]) == 1
361
                                                     (EndianS32_LtoN(q[0]) == PARM_SIG_MAC)) && EndianS32_LtoN(q[1]) == 1
362
                                                        && (res = readPARM((char*)q, &gdata->parm, reason, 0 /*Strings are already PStrings*/)) )
362
                                                        && (res = readPARM((char*)q, &gdata->parm, reason, 0/*fromwin=0 means that strings are PStrings instead of CStrings*/)) )
363
                                                {
363
                                                {
364
                                                        // Note: slider[i] = EndianS32_LtoN(slider[i]); will be done in readPARM()
364
                                                        // Note: slider[i] = EndianS32_LtoN(slider[i]); will be done in readPARM()
365
                                                        // All the rest are flags which (if we're careful) will work in either ordering
365
                                                        // All the rest are flags which (if we're careful) will work in either ordering
366
 
366
 
367
                                                        // Convert CR in the copyright field to CRLF.
367
                                                        // Convert CR in the copyright field to CRLF.
368
                                                        int i, j;
-
 
369
                                                        for (i = 1; i < gdata->parm.copyright[0]; i++) {
368
                                                        char copyrightCRLF[256];
370
                                                                if (gdata->parm.copyright[i] == CR) {
369
                                                        char* p = &copyrightCRLF[0];
371
                                                                        for (j = gdata->parm.copyright[0]; j>i; j--) {
370
                                                        for (size_t i = 0; i < strlen(gdata->parm.szCopyright); i++) {
372
                                                                                gdata->parm.copyright[j+1] = gdata->parm.copyright[j];
371
                                                                *p++ = gdata->parm.szCopyright[i];
373
                                                                        }
-
 
374
                                                                        gdata->parm.copyright[0]++;
372
                                                                if (gdata->parm.szCopyright[i] == CR) {
375
                                                                        gdata->parm.copyright[i+1] = LF;
373
                                                                        *p++ = LF;
376
                                                                }
374
                                                                }
377
                                                        }
375
                                                        }
-
 
376
                                                        *p++ = '\0';
-
 
377
                                                        strcpy(gdata->parm.szCopyright, copyrightCRLF);
378
                                                }
378
                                                }
379
                                                #endif
379
                                                #endif
380
 
380
 
381
                                                if (res) break;
381
                                                if (res) break;
382
                                        }
382
                                        }
Line 401... Line 401...
401
        } else {
401
        } else {
402
                // Assume it is Photoshop. Signature either PARM_SIZE (0x2068) or 0x1C68
402
                // Assume it is Photoshop. Signature either PARM_SIZE (0x2068) or 0x1C68
403
                memcpy(pparm,p,sizeof(PARM_T));
403
                memcpy(pparm,p,sizeof(PARM_T));
404
        }
404
        }
405
 
405
 
406
        if(fromwin){
406
        if(!fromwin){
407
                /* Windows PARM resource stores C strings - convert to Pascal strings  */
407
                /* Mac PARM resource stores Pascal strings - convert to C strings  */
408
                myc2pstr((char*)pparm->category);
408
                myp2cstr((unsigned char*)pparm->szCategory);
409
                myc2pstr((char*)pparm->title);
409
                myp2cstr((unsigned char*)pparm->szTitle);
410
                myc2pstr((char*)pparm->copyright);
410
                myp2cstr((unsigned char*)pparm->szCopyright);
411
                myc2pstr((char*)pparm->author);
411
                myp2cstr((unsigned char*)pparm->szAuthor);
412
                for(i = 0; i < 4; ++i)
412
                for(i = 0; i < 4; ++i)
413
                        myc2pstr((char*)pparm->map[i]);
413
                        myp2cstr((unsigned char*)pparm->szMap[i]);
414
                for(i = 0; i < 8; ++i)
414
                for(i = 0; i < 8; ++i)
415
                        myc2pstr((char*)pparm->ctl[i]);
415
                        myp2cstr((unsigned char*)pparm->szCtl[i]);
416
        }
416
        }
417
 
417
 
418
        for(i = 0; i < 4; ++i){
418
        for(i = 0; i < 4; ++i){
419
                if(expr[i]) free(expr[i]);
419
                if(expr[i]) free(expr[i]);
420
                expr[i] = my_strdup((char*)pparm->formula[i]);
420
                expr[i] = my_strdup(pparm->szFormula[i]);
421
        }
421
        }
422
 
422
 
423
        for (i = 0; i < 8; ++i) {
423
        for (i = 0; i < 8; ++i) {
424
                if (pparm->val[i] > 0xFF) {
424
                if (pparm->val[i] > 0xFF) {
425
                        // Wrong endianess (e.g. reading a Mac rsrc on Windows)
425
                        // Wrong endianess (e.g. reading a Mac rsrc on Windows)
Line 491... Line 491...
491
                }
491
                }
492
                x++;
492
                x++;
493
        }
493
        }
494
}
494
}
495
 
495
 
496
// isFormula=false => outputFile is Pascal string. TXT linebreaks become spaces.
496
// isFormula=false => outputFile is C string. TXT linebreaks become spaces.
497
// isFormula=true  => outputFile is C string. TXT line breaks become CRLF line breaks
497
// isFormula=true  => outputFile is C string. TXT line breaks become CRLF line breaks
498
Boolean _picoReadProperty(char* inputFile, int maxInput, const char* property, char* outputFile, size_t maxOutput, Boolean isFormula) {
498
Boolean _picoReadProperty(char* inputFile, int maxInput, const char* property, char* outputFile, size_t maxOutput, Boolean isFormula) {
499
        int i;
499
        int i;
500
        char* outputwork;
500
        char* outputwork;
501
        char* sline;
501
        char* sline;
Line 573... Line 573...
573
                x = strstr(inputwork, "\nA=\n");
573
                x = strstr(inputwork, "\nA=\n");
574
                if (x) memcpy(x, "\nA:\n", strlen("\nA:\n"));
574
                if (x) memcpy(x, "\nA:\n", strlen("\nA:\n"));
575
        }
575
        }
576
        // Replace all \r and \n with \0, so that we can parse easier
576
        // Replace all \r and \n with \0, so that we can parse easier
577
        for (i = 0; i < maxInput; i++) {
577
        for (i = 0; i < maxInput; i++) {
578
                if (inputworkinitial[i] == 0) break;
-
 
579
                if (inputworkinitial[i] == CR) inputworkinitial[i] = 0;
578
                if (inputworkinitial[i] == CR) inputworkinitial[i] = 0;
580
                if (inputworkinitial[i] == LF) inputworkinitial[i] = 0;
579
                else if (inputworkinitial[i] == LF) inputworkinitial[i] = 0;
581
        }
580
        }
582
 
581
 
583
        // Find line that contains out key
582
        // Find line that contains out key
584
        inputwork = inputworkinitial;
583
        inputwork = inputworkinitial;
585
        do {
584
        do {
586
                if (inputwork > inputworkinitial + maxInput) {
585
                if (inputwork > inputworkinitial + maxInput) {
587
                        // Key not found. Set output to empty string
586
                        // Key not found. Set output to empty string
588
                        outputwork[0] = 0;
587
                        outputwork[0] = 0;
589
                        free(inputworkinitial);
588
                        free(inputworkinitial);
590
                        if (!isFormula) myc2pstr(outputFile);
-
 
591
                        return false;
589
                        return false;
592
                }
590
                }
593
                sline = inputwork;
591
                sline = inputwork;
594
                inputwork += strlen(sline) + 1;
592
                inputwork += strlen(sline) + 1;
595
                if (inputwork - 1 > inputworkinitial + maxInput) {
593
                if (inputwork - 1 > inputworkinitial + maxInput) {
596
                        // Key not found. Set output to empty string
594
                        // Key not found. Set output to empty string
597
                        // TODO: will that be ever called?
595
                        // TODO: will that be ever called?
598
                        outputwork[0] = 0;
596
                        outputwork[0] = 0;
599
                        free(inputworkinitial);
597
                        free(inputworkinitial);
600
                        if (!isFormula) myc2pstr(outputFile);
-
 
601
                        return false;
598
                        return false;
602
                }
599
                }
603
        } while (!_picoLineContainsKey(sline, &svalue, property));
600
        } while (!_picoLineContainsKey(sline, &svalue, property));
604
 
601
 
605
        // Read line(s) until we find a line with another key, or the line end
602
        // Read line(s) until we find a line with another key, or the line end
606
        do {
603
        do {
607
                while ((svalue[0] == ' ') || (svalue[0] == TAB)) svalue++; // Trim left
604
                while ((svalue[0] == ' ') || (svalue[0] == TAB)) svalue++; // Trim left
608
                while ((svalue[strlen(svalue) - 1] == ' ') || (svalue[strlen(svalue) - 1] == TAB)) svalue[strlen(svalue) - 1] = 0; // Trim right
605
                while ((svalue[strlen(svalue) - 1] == ' ') || (svalue[strlen(svalue) - 1] == TAB)) svalue[strlen(svalue) - 1] = 0; // Trim right
609
 
606
 
610
                if (strlen(svalue) > 0) {
607
                if (strlen(svalue) > 0) {
611
                        if (outputwork + strlen(svalue) + (isFormula ? 3 : 2) > outputFile + maxOutput) {
608
                        if (outputwork + strlen(svalue) + (isFormula ? 3/*CRLF+NUL*/ : 2/*space+NUL*/) > outputFile + maxOutput) {
612
                                int remaining = maxOutput - (outputwork - outputFile) - 1;
609
                                int remaining = maxOutput - (outputwork - outputFile) - 1;
613
                                //printf("BUFFER FULL (remaining = %d)\n", remaining);
610
                                //printf("BUFFER FULL (remaining = %d)\n", remaining);
614
                                memcpy(outputwork, svalue, remaining);
611
                                memcpy(outputwork, svalue, remaining);
615
                                outputwork += remaining;
612
                                outputwork += remaining;
616
                                outputwork[0] = 0;
613
                                outputwork[0] = 0;
617
                                free(inputworkinitial);
614
                                free(inputworkinitial);
618
                                if (!isFormula) myc2pstr(outputFile);
-
 
619
                                return true;
615
                                return true;
620
                        }
616
                        }
621
                        else {
617
                        else {
622
                                memcpy(outputwork, svalue, strlen(svalue));
618
                                memcpy(outputwork, svalue, strlen(svalue));
623
                                outputwork += strlen(svalue);
619
                                outputwork += strlen(svalue);
Line 647... Line 643...
647
        if (outputwork > outputFile) {
643
        if (outputwork > outputFile) {
648
                outputwork -= 1;
644
                outputwork -= 1;
649
                outputwork[0] = 0;
645
                outputwork[0] = 0;
650
        }
646
        }
651
        free(inputworkinitial);
647
        free(inputworkinitial);
652
        if (!isFormula) myc2pstr(outputFile);
-
 
653
        return true;
648
        return true;
654
}
649
}
655
 
650
 
656
Boolean readfile_picotxt(StandardFileReply* sfr, char** reason) {
651
Boolean readfile_picotxt(StandardFileReply* sfr, char** reason) {
657
        extern int ctls[], maps[];
652
        extern int ctls[], maps[];
Line 670... Line 665...
670
                        char out[256];
665
                        char out[256];
671
                        if (_picoReadProperty(q, count, "Title", out, sizeof(out), false)) {
666
                        if (_picoReadProperty(q, count, "Title", out, sizeof(out), false)) {
672
                                int i;
667
                                int i;
673
 
668
 
674
                                // Plugin infos
669
                                // Plugin infos
675
                                _picoReadProperty(q, count, "Title", (char*)gdata->parm.title, sizeof(gdata->parm.title)-1, false);
670
                                _picoReadProperty(q, count, "Title", gdata->parm.szTitle, sizeof(gdata->parm.szTitle), false);
676
                                _picoReadProperty(q, count, "Category", (char*)gdata->parm.category, sizeof(gdata->parm.category)-1, false);
671
                                _picoReadProperty(q, count, "Category", gdata->parm.szCategory, sizeof(gdata->parm.szCategory), false);
677
                                _picoReadProperty(q, count, "Author", (char*)gdata->parm.author, sizeof(gdata->parm.author)-1, false);
672
                                _picoReadProperty(q, count, "Author", gdata->parm.szAuthor, sizeof(gdata->parm.szAuthor), false);
678
                                _picoReadProperty(q, count, "Copyright", (char*)gdata->parm.copyright, sizeof(gdata->parm.copyright)-1, false);
673
                                _picoReadProperty(q, count, "Copyright", gdata->parm.szCopyright, sizeof(gdata->parm.szCopyright), false);
679
                                //_picoReadProperty(q, count, "Filename", (char*)gdata->parm.xxx, sizeof(gdata->parm.xxx), false);
674
                                //_picoReadProperty(q, count, "Filename", gdata->parm.xxx, sizeof(gdata->parm.xxx), false);
680
 
675
 
681
                                // Expressions
676
                                // Expressions
682
                                if (!_picoReadProperty(q, count, "R", (char*)gdata->parm.formula[0], sizeof(gdata->parm.formula[0]), true))
677
                                if (!_picoReadProperty(q, count, "R", gdata->parm.szFormula[0], sizeof(gdata->parm.szFormula[0]), true))
683
                                        strcpy((char*)gdata->parm.formula[0], "r");
678
                                        strcpy(gdata->parm.szFormula[0], "r");
684
                                if (!_picoReadProperty(q, count, "G", (char*)gdata->parm.formula[1], sizeof(gdata->parm.formula[1]), true))
679
                                if (!_picoReadProperty(q, count, "G", gdata->parm.szFormula[1], sizeof(gdata->parm.szFormula[1]), true))
685
                                        strcpy((char*)gdata->parm.formula[1], "g");
680
                                        strcpy(gdata->parm.szFormula[1], "g");
686
                                if (!_picoReadProperty(q, count, "B", (char*)gdata->parm.formula[2], sizeof(gdata->parm.formula[2]), true))
681
                                if (!_picoReadProperty(q, count, "B", gdata->parm.szFormula[2], sizeof(gdata->parm.szFormula[2]), true))
687
                                        strcpy((char*)gdata->parm.formula[2], "b");
682
                                        strcpy(gdata->parm.szFormula[2], "b");
688
                                if (!_picoReadProperty(q, count, "A", (char*)gdata->parm.formula[3], sizeof(gdata->parm.formula[3]), true))
683
                                if (!_picoReadProperty(q, count, "A", gdata->parm.szFormula[3], sizeof(gdata->parm.szFormula[3]), true))
689
                                        strcpy((char*)gdata->parm.formula[3], "a");
684
                                        strcpy(gdata->parm.szFormula[3], "a");
690
                                for (i = 0; i < 4; i++) {
685
                                for (i = 0; i < 4; i++) {
691
                                        if (expr[i]) free(expr[i]);
686
                                        if (expr[i]) free(expr[i]);
692
                                        expr[i] = my_strdup((char*)gdata->parm.formula[i]);
687
                                        expr[i] = my_strdup(gdata->parm.szFormula[i]);
693
                                }
688
                                }
694
 
689
 
695
                                // Slider names
690
                                // Slider names
696
                                for (i = 0; i < 8; i++) {
691
                                for (i = 0; i < 8; i++) {
697
                                        char keyname[7];
692
                                        char keyname[7];
698
                                        sprintf(keyname, "ctl[%d]", i);
693
                                        sprintf(keyname, "ctl[%d]", i);
699
                                        _picoReadProperty(q, count, keyname, (char*)gdata->parm.ctl[i], sizeof(gdata->parm.ctl[i]), false);
694
                                        _picoReadProperty(q, count, keyname, gdata->parm.szCtl[i], sizeof(gdata->parm.szCtl[i]), false);
700
                                }
695
                                }
701
 
696
 
702
                                // Slider values
697
                                // Slider values
703
                                for (i = 0; i < 8; i++) {
698
                                for (i = 0; i < 8; i++) {
704
                                        char keyname[7], tmp[5];
699
                                        char keyname[7], tmp[5];
705
                                        sprintf(keyname, "val[%d]", i);
700
                                        sprintf(keyname, "val[%d]", i);
706
                                        if (!_picoReadProperty(q, count, keyname, tmp, sizeof(tmp), false)) {
701
                                        if (!_picoReadProperty(q, count, keyname, tmp, sizeof(tmp), false)) {
707
                                                sprintf(keyname, "def[%d]", i);
702
                                                sprintf(keyname, "def[%d]", i);
708
                                                if (!_picoReadProperty(q, count, keyname, tmp, sizeof(tmp), false)) {
703
                                                if (!_picoReadProperty(q, count, keyname, tmp, sizeof(tmp), false)) {
709
                                                        tmp[0] = 1;
-
 
710
                                                        tmp[1] = '0';
704
                                                        strcpy(tmp,"0");
711
                                                        tmp[2] = 0;
-
 
712
                                                }
705
                                                }
713
                                        }
706
                                        }
714
                                        myp2cstr((unsigned char*)tmp);
-
 
715
                                        gdata->parm.val[i] = slider[i] = atoi(tmp);
707
                                        gdata->parm.val[i] = slider[i] = atoi(tmp);
716
                                }
708
                                }
717
 
709
 
718
                                // Map names
710
                                // Map names
719
                                for (i = 0; i < 4; i++) {
711
                                for (i = 0; i < 4; i++) {
720
                                        char keyname[7];
712
                                        char keyname[7];
721
                                        sprintf(keyname, "map[%d]", i);
713
                                        sprintf(keyname, "map[%d]", i);
722
                                        _picoReadProperty(q, count, keyname, (char*)gdata->parm.map[i], sizeof(gdata->parm.map[i]), false);
714
                                        _picoReadProperty(q, count, keyname, gdata->parm.szMap[i], sizeof(gdata->parm.szMap[i]), false);
723
                                }
715
                                }
724
 
716
 
725
                                //These will be set when the expressions are evaluated anyway. So this part is optional:
717
                                //These will be set when the expressions are evaluated anyway. So this part is optional:
726
                                checksliders(4, ctls, maps);
718
                                checksliders(4, ctls, maps);
727
                                for (i = 0; i < 8; i++) gdata->parm.ctl_used[i] = ctls[i];
719
                                for (i = 0; i < 8; i++) gdata->parm.ctl_used[i] = ctls[i];