Subversion Repositories filter_foundry

Rev

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

Rev 454 Rev 456
Line 78... Line 78...
78
                                }
78
                                }
79
                        }else if(linecnt<=8){
79
                        }else if(linecnt<=8){
80
                                int v;
80
                                int v;
81
                                v = atoi(linebuf);
81
                                v = atoi(linebuf);
82
                                if (v < 0) v = 0;
82
                                if (v < 0) v = 0;
83
                                if (v > 255) v = 255;
83
                                else if (v > 255) v = 255;
84
                                slider[linecnt-1] = v;
84
                                slider[linecnt-1] = (uint8_t)v;
85
                        }else{
85
                        }else{
86
                                if(lineptr){
86
                                if(lineptr){
87
                                        /* it's not an empty line; append it to current expr string */
87
                                        /* it's not an empty line; append it to current expr string */
88
                                        if( q+lineptr > curexpr+MAXEXPR ){
88
                                        if( q+lineptr > curexpr+MAXEXPR ){
89
                                                *reason = _strdup("Found an expression longer than 1024 characters.");
89
                                                *reason = _strdup("Found an expression longer than 1024 characters.");
Line 299... Line 299...
299
                                                gdata->parm.ctl_used[i] = (bool32_t)*((byte*)q);
299
                                                gdata->parm.ctl_used[i] = (bool32_t)*((byte*)q);
300
                                                q += sizeof(byte);
300
                                                q += sizeof(byte);
301
                                                gdata->parm.val[i] = *((uint32_t*)q);
301
                                                gdata->parm.val[i] = *((uint32_t*)q);
302
                                                v = *((uint32_t*)q);
302
                                                v = *((uint32_t*)q);
303
                                                if (v < 0) v = 0;
303
                                                if (v < 0) v = 0;
304
                                                if (v > 255) v = 255;
304
                                                else if (v > 255) v = 255;
305
                                                slider[i] = v;
305
                                                slider[i] = (uint8_t)v;
306
                                                q += sizeof(uint32_t);
306
                                                q += sizeof(uint32_t);
307
                                        }
307
                                        }
308
 
308
 
309
                                        // Maps (are not part of the format!)
309
                                        // Maps (are not part of the format!)
310
                                        strcpy(gdata->parm.szMap[0], "Map 0:");
310
                                        strcpy(gdata->parm.szMap[0], "Map 0:");
Line 358... Line 358...
358
        if (res) gdata->obfusc = false;
358
        if (res) gdata->obfusc = false;
359
        return res;
359
        return res;
360
}
360
}
361
 
361
 
362
Boolean readPARM(PARM_T* pparm, Ptr p){
362
Boolean readPARM(PARM_T* pparm, Ptr p){
363
        int i;
-
 
364
        Boolean towin, tomac, fromwin, frommac;
363
        Boolean towin, tomac, fromwin, frommac;
365
        unsigned int signature = *((unsigned int*)p);
364
        unsigned int signature = *((unsigned int*)p);
366
        unsigned int standalone = *((unsigned int*)p+1);
365
        unsigned int standalone = *((unsigned int*)p+1);
367
 
366
 
368
        // Find out our OS ("reader") the OS of the plugin ("source")
367
        // Find out our OS ("reader") the OS of the plugin ("source")
Line 402... Line 401...
402
                memcpy(pparm, p, sizeof(PARM_T));
401
                memcpy(pparm, p, sizeof(PARM_T));
403
        }
402
        }
404
 
403
 
405
        // Do we need to do string conversion?
404
        // Do we need to do string conversion?
406
        if (frommac) {
405
        if (frommac) {
-
 
406
                int i;
-
 
407
 
407
                /* Mac PARM resource stores Pascal strings - convert to C strings, since this is what we work internally with (regardles of OS) */
408
                /* Mac PARM resource stores Pascal strings - convert to C strings, since this is what we work internally with (regardles of OS) */
408
                myp2cstr((unsigned char*)pparm->szCategory);
409
                myp2cstr((unsigned char*)pparm->szCategory);
409
                myp2cstr((unsigned char*)pparm->szTitle);
410
                myp2cstr((unsigned char*)pparm->szTitle);
410
                myp2cstr((unsigned char*)pparm->szCopyright);
411
                myp2cstr((unsigned char*)pparm->szCopyright);
411
                myp2cstr((unsigned char*)pparm->szAuthor);
412
                myp2cstr((unsigned char*)pparm->szAuthor);
Line 419... Line 420...
419
        if (fromwin && tomac) {
420
        if (fromwin && tomac) {
420
                size_t i;
421
                size_t i;
421
 
422
 
422
                // Convert copyright CRLF to CR (actually, just removing LF)
423
                // Convert copyright CRLF to CR (actually, just removing LF)
423
                char copyrightCRLF[256] = { 0 };
424
                char copyrightCRLF[256] = { 0 };
424
                char* p = &copyrightCRLF[0];
425
                char* pCopyright = &copyrightCRLF[0];
425
                for (i = 0; i < strlen(pparm->szCopyright); i++) {
426
                for (i = 0; i < strlen(pparm->szCopyright); i++) {
426
                        if (pparm->szCopyright[i] != LF) {
427
                        if (pparm->szCopyright[i] != LF) {
427
                                *p++ = pparm->szCopyright[i];
428
                                *pCopyright++ = pparm->szCopyright[i];
428
                        }
429
                        }
429
                }
430
                }
430
                *p++ = '\0';
431
                *pCopyright++ = '\0';
431
                strcpy(pparm->szCopyright, copyrightCRLF);
432
                strcpy(pparm->szCopyright, copyrightCRLF);
432
 
433
 
433
                // these are the only numeric fields we *have* to swap
434
                // these are the only numeric fields we *have* to swap
434
                // all the rest are bool_t flags which (if we're careful) will work in either ordering
435
                // all the rest are bool_t flags which (if we're careful) will work in either ordering
435
                for (i = 0; i < 8; ++i)
436
                for (i = 0; i < 8; ++i)
Line 447... Line 448...
447
        if (frommac && towin) {
448
        if (frommac && towin) {
448
                size_t i;
449
                size_t i;
449
 
450
 
450
                // Convert CR in the copyright field to CRLF.
451
                // Convert CR in the copyright field to CRLF.
451
                char copyrightCRLF[256] = { 0 };
452
                char copyrightCRLF[256] = { 0 };
452
                char* p = &copyrightCRLF[0];
453
                char* pCopyright = &copyrightCRLF[0];
453
                for (i = 0; i < strlen(pparm->szCopyright); i++) {
454
                for (i = 0; i < strlen(pparm->szCopyright); i++) {
454
                        *p++ = pparm->szCopyright[i];
455
                        *pCopyright++ = pparm->szCopyright[i];
455
                        if (pparm->szCopyright[i] == CR) {
456
                        if (pparm->szCopyright[i] == CR) {
456
                                *p++ = LF;
457
                                *pCopyright++ = LF;
457
                        }
458
                        }
458
                }
459
                }
459
                *p++ = '\0';
460
                *pCopyright++ = '\0';
460
                strcpy(pparm->szCopyright, copyrightCRLF);
461
                strcpy(pparm->szCopyright, copyrightCRLF);
461
 
462
 
462
                // these are the only numeric fields we *have* to swap
463
                // these are the only numeric fields we *have* to swap
463
                // all the rest are bool_t flags which (if we're careful) will work in either ordering
464
                // all the rest are bool_t flags which (if we're careful) will work in either ordering
464
                for (i = 0; i < 8; ++i)
465
                for (i = 0; i < 8; ++i)
465
                        pparm->val[i] = EndianS32_LtoN(pparm->val[i]);
466
                        pparm->val[i] = EndianS32_LtoN(pparm->val[i]);
466
        }
467
        }
467
 
468
 
468
        // Now set the values in pparm into the working variables expr[] and slider[], so that they are visible in the GUI
469
        // Now set the values in pparm into the working variables expr[] and slider[], so that they are visible in the GUI
469
 
470
        {
-
 
471
                int i;
470
        for(i = 0; i < 4; ++i){
472
                for (i = 0; i < 4; ++i) {
471
                if(expr[i]) free(expr[i]);
473
                        if (expr[i]) free(expr[i]);
472
                expr[i] = my_strdup(pparm->szFormula[i]);
474
                        expr[i] = my_strdup(pparm->szFormula[i]);
473
        }
475
                }
474
 
476
 
Line 480... Line 482...
480
                        // Should not happen since we did the stuff above
482
                                // Should not happen since we did the stuff above
481
                        slider[i] = (uint8_t)EndianS32_LtoN(slider[i]);
483
                                slider[i] = (uint8_t)EndianS32_LtoN(slider[i]);
482
                }
484
                        }
483
                */
485
                        */
484
        }
486
                }
-
 
487
        }
485
 
488
 
486
        return true;
489
        return true;
487
}
490
}
488
 
491
 
489
Handle readfileintohandle(FILEREF r){
492
Handle readfileintohandle(FILEREF r){
Line 760... Line 763...
760
                                                        strcpy(tmp,"0");
763
                                                        strcpy(tmp,"0");
761
                                                }
764
                                                }
762
                                        }
765
                                        }
763
                                        v = atoi(tmp);
766
                                        v = atoi(tmp);
764
                                        if (v < 0) v = 0;
767
                                        if (v < 0) v = 0;
765
                                        if (v > 255) v = 255;
768
                                        else if (v > 255) v = 255;
766
                                        gdata->parm.val[i] = slider[i] = v;
769
                                        gdata->parm.val[i] = slider[i] = (uint8_t)v;
767
                                }
770
                                }
768
 
771
 
769
                                // Map names
772
                                // Map names
770
                                for (i = 0; i < 4; i++) {
773
                                for (i = 0; i < 4; i++) {
771
                                        char keyname[7];
774
                                        char keyname[7];