Rev 388 | Rev 390 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 388 | Rev 389 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | enum{ |
36 | enum{ |
37 | BUFSIZE = 4L<<10, |
37 | BUFSIZE = 4L<<10, |
38 | MAXLINE = 0x200, |
38 | MAXLINE = 0x200, |
39 | }; |
39 | }; |
40 | 40 | ||
41 | Boolean readparams(Handle h,Boolean alerts,char **reason){ |
41 | Boolean readparams_afs_pff(Handle h,Boolean alerts,char **reason){ |
42 | Boolean res = false; |
42 | Boolean res = false; |
43 | char linebuf[MAXLINE+1],curexpr[MAXEXPR+1],*p,*dataend,*q; |
43 | char linebuf[MAXLINE+1],curexpr[MAXEXPR+1],*p,*dataend,*q; |
44 | char c; |
44 | char c; |
45 | int linecnt, lineptr, exprcnt; |
45 | int linecnt, lineptr, exprcnt; |
46 | 46 | ||
Line 515... | Line 515... | ||
515 | char* x; |
515 | char* x; |
516 | char* k1; |
516 | char* k1; |
517 | char* k2; |
517 | char* k2; |
518 | // Metadata: |
518 | // Metadata: |
519 | x = strstr(inputwork, "CATEGORY:"); |
519 | x = strstr(inputwork, "CATEGORY:"); |
520 | if (x) strncpy(x, "Category:", strlen("Category:")); |
520 | if (x) memcpy(x, "Category:", strlen("Category:")); |
521 | x = strstr(inputwork, "TITLE:"); |
521 | x = strstr(inputwork, "TITLE:"); |
522 | if (x) strncpy(x, "Title:", strlen("Title:")); |
522 | if (x) memcpy(x, "Title:", strlen("Title:")); |
523 | x = strstr(inputwork, "COPYRIGHT:"); |
523 | x = strstr(inputwork, "COPYRIGHT:"); |
524 | if (x) strncpy(x, "Copyright:", strlen("Copyright:")); |
524 | if (x) memcpy(x, "Copyright:", strlen("Copyright:")); |
525 | x = strstr(inputwork, "AUTHOR:"); |
525 | x = strstr(inputwork, "AUTHOR:"); |
526 | if (x) strncpy(x, "Author:", strlen("Author:")); |
526 | if (x) memcpy(x, "Author:", strlen("Author:")); |
527 | // Controls: |
527 | // Controls: |
528 | for (i = 0; i < 8; i++) { |
528 | for (i = 0; i < 8; i++) { |
529 | k1 = (char*)malloc(strlen("Control X:") + 1); |
529 | k1 = (char*)malloc(strlen("Control X:") + 1); |
530 | sprintf(k1, "Control %d:", i); |
530 | sprintf(k1, "Control %d:", i); |
531 | x = strstr(inputwork, k1); |
531 | x = strstr(inputwork, k1); |
532 | if (x) { |
532 | if (x) { |
533 | k2 = (char*)malloc(strlen("ctl[X]: ") + 1); |
533 | k2 = (char*)malloc(strlen("ctl[X]: ") + 1); |
534 | sprintf(k2, "ctl[%d]: ", i); |
534 | sprintf(k2, "ctl[%d]: ", i); |
535 | strncpy(x, k2, strlen(k2)); |
535 | memcpy(x, k2, strlen(k2)); |
536 | x += strlen("ctl[X]"); |
536 | x += strlen("ctl[X]"); |
537 | _ffdcomp_removebrackets(x, inputwork + maxInput - 1); |
537 | _ffdcomp_removebrackets(x, inputwork + maxInput - 1); |
538 | free(k2); |
538 | free(k2); |
539 | } |
539 | } |
540 | free(k1); |
540 | free(k1); |
Line 545... | Line 545... | ||
545 | sprintf(k1, "Map %d:", i); |
545 | sprintf(k1, "Map %d:", i); |
546 | x = strstr(inputwork, k1); |
546 | x = strstr(inputwork, k1); |
547 | if (x) { |
547 | if (x) { |
548 | k2 = (char*)malloc(strlen("map[X]:") + 1); |
548 | k2 = (char*)malloc(strlen("map[X]:") + 1); |
549 | sprintf(k2, "map[%d]:", i); |
549 | sprintf(k2, "map[%d]:", i); |
550 | strncpy(x, k2, strlen(k2)); |
550 | memcpy(x, k2, strlen(k2)); |
551 | x += strlen("map[X]"); |
551 | x += strlen("map[X]"); |
552 | _ffdcomp_removebrackets(x, inputwork + maxInput - 1); |
552 | _ffdcomp_removebrackets(x, inputwork + maxInput - 1); |
553 | free(k2); |
553 | free(k2); |
554 | } |
554 | } |
555 | free(k1); |
555 | free(k1); |
Line 557... | Line 557... | ||
557 | // Convert all '\r' to '\n' for the next step to be easier |
557 | // Convert all '\r' to '\n' for the next step to be easier |
558 | for (i = 0; i < maxInput; i++) { |
558 | for (i = 0; i < maxInput; i++) { |
559 | if (inputworkinitial[i] == CR) inputworkinitial[i] = LF; |
559 | if (inputworkinitial[i] == CR) inputworkinitial[i] = LF; |
560 | } |
560 | } |
561 | x = strstr(inputwork, "\nR=\n"); |
561 | x = strstr(inputwork, "\nR=\n"); |
562 | if (x) strncpy(x, "\nR:\n", strlen("\nR:\n")); |
562 | if (x) memcpy(x, "\nR:\n", strlen("\nR:\n")); |
563 | x = strstr(inputwork, "\nG=\n"); |
563 | x = strstr(inputwork, "\nG=\n"); |
564 | if (x) strncpy(x, "\nG:\n", strlen("\nG:\n")); |
564 | if (x) memcpy(x, "\nG:\n", strlen("\nG:\n")); |
565 | x = strstr(inputwork, "\nB=\n"); |
565 | x = strstr(inputwork, "\nB=\n"); |
566 | if (x) strncpy(x, "\nB:\n", strlen("\nB:\n")); |
566 | if (x) memcpy(x, "\nB:\n", strlen("\nB:\n")); |
567 | x = strstr(inputwork, "\nA=\n"); |
567 | x = strstr(inputwork, "\nA=\n"); |
568 | if (x) strncpy(x, "\nA:\n", strlen("\nA:\n")); |
568 | if (x) memcpy(x, "\nA:\n", strlen("\nA:\n")); |
569 | } |
569 | } |
570 | // Replace all \r and \n with \0, so that we can parse easier |
570 | // Replace all \r and \n with \0, so that we can parse easier |
571 | for (i = 0; i < maxInput; i++) { |
571 | for (i = 0; i < maxInput; i++) { |
572 | if (inputworkinitial[i] == 0) break; |
572 | if (inputworkinitial[i] == 0) break; |
573 | if (inputworkinitial[i] == CR) inputworkinitial[i] = 0; |
573 | if (inputworkinitial[i] == CR) inputworkinitial[i] = 0; |
Line 646... | Line 646... | ||
646 | if (!isFormula) myc2pstr(outputFile); |
646 | if (!isFormula) myc2pstr(outputFile); |
647 | return true; |
647 | return true; |
648 | } |
648 | } |
649 | 649 | ||
650 | Boolean readfile_picotxt(StandardFileReply* sfr, char** reason) { |
650 | Boolean readfile_picotxt(StandardFileReply* sfr, char** reason) { |
- | 651 | extern int ctls[], maps[]; |
|
- | 652 | ||
651 | Handle h; |
653 | Handle h; |
652 | Boolean res = false; |
654 | Boolean res = false; |
653 | FILEREF refnum; |
655 | FILEREF refnum; |
654 | 656 | ||
655 | if (!fileHasExtension(sfr, ".txt")) return false; |
657 | if (!fileHasExtension(sfr, ".txt")) return false; |
Line 712... | Line 714... | ||
712 | char keyname[7]; |
714 | char keyname[7]; |
713 | sprintf(keyname, "map[%d]", i); |
715 | sprintf(keyname, "map[%d]", i); |
714 | _picoReadProperty(q, count, keyname, (char*)gdata->parm.map[i], sizeof(gdata->parm.map[i]), false); |
716 | _picoReadProperty(q, count, keyname, (char*)gdata->parm.map[i], sizeof(gdata->parm.map[i]), false); |
715 | } |
717 | } |
716 | 718 | ||
717 | //These will be set when the expressions are evaluated: |
719 | //These will be set when the expressions are evaluated anyway. So this part is optional: |
- | 720 | checksliders(4, ctls, maps); |
|
718 | //gdata->parm.ctl_used[i] |
721 | for (i = 0; i < 8; i++) gdata->parm.ctl_used[i] = ctls[i]; |
719 | //gdata->parm.map_used[i] |
722 | for (i = 0; i < 4; i++) gdata->parm.map_used[i] = maps[i]; |
720 | 723 | ||
721 | res = true; |
724 | res = true; |
722 | } |
725 | } |
723 | 726 | ||
724 | PIUNLOCKHANDLE(h); |
727 | PIUNLOCKHANDLE(h); |
Line 735... | Line 738... | ||
735 | Handle h; |
738 | Handle h; |
736 | Boolean res = false; |
739 | Boolean res = false; |
737 | 740 | ||
738 | if(FSpOpenDF(&sfr->sfFile,fsRdPerm,&r) == noErr){ |
741 | if(FSpOpenDF(&sfr->sfFile,fsRdPerm,&r) == noErr){ |
739 | if( (h = readfileintohandle(r)) ){ |
742 | if( (h = readfileintohandle(r)) ){ |
740 | if( (res = readparams(h,true,reason)) ) { |
743 | if( (res = readparams_afs_pff(h,true,reason)) ) { |
741 | gdata->standalone = false; // so metadata fields will default, if user chooses Make... |
744 | gdata->standalone = false; // so metadata fields will default, if user chooses Make... |
742 | 745 | ||
743 | if (fileHasExtension(sfr, ".pff")) { |
746 | if (fileHasExtension(sfr, ".pff")) { |
744 | // If it is a Premiere settings file, we need to swap the channels red and blue |
747 | // If it is a Premiere settings file, we need to swap the channels red and blue |
745 | // We just swap the pointers! |
748 | // We just swap the pointers! |