Rev 503 | Rev 518 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 503 | Rev 505 | ||
---|---|---|---|
Line 547... | Line 547... | ||
547 | } |
547 | } |
548 | } |
548 | } |
549 | 549 | ||
550 | // isFormula=false => outputFile is C string. TXT linebreaks become spaces. |
550 | // isFormula=false => outputFile is C string. TXT linebreaks become spaces. |
551 | // isFormula=true => outputFile is C string. TXT line breaks become CRLF line breaks |
551 | // isFormula=true => outputFile is C string. TXT line breaks become CRLF line breaks |
552 | Boolean _picoReadProperty(char* inputFile, int maxInput, const char* property, char* outputFile, size_t maxOutput, Boolean isFormula) { |
552 | Boolean _picoReadProperty(char* inputFile, size_t maxInput, const char* property, char* outputFile, size_t maxOutput, Boolean isFormula) { |
553 | int i; |
553 | size_t i; |
554 | char* outputwork; |
554 | char* outputwork; |
555 | char* sline; |
555 | char* sline; |
556 | char* svalue; |
556 | char* svalue; |
557 | char* inputwork; |
557 | char* inputwork; |
558 | char* inputworkinitial; |
558 | char* inputworkinitial; |
Line 585... | Line 585... | ||
585 | x = strstr(inputwork, "AUTHOR:"); |
585 | x = strstr(inputwork, "AUTHOR:"); |
586 | if (x) memcpy(x, "Author:", strlen("Author:")); |
586 | if (x) memcpy(x, "Author:", strlen("Author:")); |
587 | // Controls: |
587 | // Controls: |
588 | for (i = 0; i < 8; i++) { |
588 | for (i = 0; i < 8; i++) { |
589 | k1 = (char*)malloc(strlen("Control X:") + 1); |
589 | k1 = (char*)malloc(strlen("Control X:") + 1); |
590 | sprintf(k1, "Control %d:", i); |
590 | sprintf(k1, "Control %d:", (int)i); |
591 | x = strstr(inputwork, k1); |
591 | x = strstr(inputwork, k1); |
592 | if (x) { |
592 | if (x) { |
593 | k2 = (char*)malloc(strlen("ctl[X]: ") + 1); |
593 | k2 = (char*)malloc(strlen("ctl[X]: ") + 1); |
594 | sprintf(k2, "ctl[%d]: ", i); |
594 | sprintf(k2, "ctl[%d]: ", (int)i); |
595 | memcpy(x, k2, strlen(k2)); |
595 | memcpy(x, k2, strlen(k2)); |
596 | x += strlen("ctl[X]"); |
596 | x += strlen("ctl[X]"); |
597 | _ffdcomp_removebrackets(x, inputwork + maxInput - 1); |
597 | _ffdcomp_removebrackets(x, inputwork + maxInput - 1); |
598 | free(k2); |
598 | free(k2); |
599 | } |
599 | } |
600 | free(k1); |
600 | free(k1); |
601 | } |
601 | } |
602 | // Maps: |
602 | // Maps: |
603 | for (i = 0; i < 4; i++) { |
603 | for (i = 0; i < 4; i++) { |
604 | k1 = (char*)malloc(strlen("Map X:") + 1); |
604 | k1 = (char*)malloc(strlen("Map X:") + 1); |
605 | sprintf(k1, "Map %d:", i); |
605 | sprintf(k1, "Map %d:", (int)i); |
606 | x = strstr(inputwork, k1); |
606 | x = strstr(inputwork, k1); |
607 | if (x) { |
607 | if (x) { |
608 | k2 = (char*)malloc(strlen("map[X]:") + 1); |
608 | k2 = (char*)malloc(strlen("map[X]:") + 1); |
609 | sprintf(k2, "map[%d]:", i); |
609 | sprintf(k2, "map[%d]:", (int)i); |
610 | memcpy(x, k2, strlen(k2)); |
610 | memcpy(x, k2, strlen(k2)); |
611 | x += strlen("map[X]"); |
611 | x += strlen("map[X]"); |
612 | _ffdcomp_removebrackets(x, inputwork + maxInput - 1); |
612 | _ffdcomp_removebrackets(x, inputwork + maxInput - 1); |
613 | free(k2); |
613 | free(k2); |
614 | } |
614 | } |
Line 713... | Line 713... | ||
713 | 713 | ||
714 | if (!fileHasExtension(sfr, TEXT(".txt"))) return false; |
714 | if (!fileHasExtension(sfr, TEXT(".txt"))) return false; |
715 | 715 | ||
716 | if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) { |
716 | if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) { |
717 | if ((h = readfileintohandle(refnum))) { |
717 | if ((h = readfileintohandle(refnum))) { |
718 | FILECOUNT count = PIGETHANDLESIZE(h); |
718 | FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h); |
719 | char* q = PILOCKHANDLE(h, false); |
719 | char* q = PILOCKHANDLE(h, false); |
720 | 720 | ||
721 | char out[256]; |
721 | char out[256]; |
722 | if (_picoReadProperty(q, count, "Title", out, sizeof(out), false)) { |
722 | if (_picoReadProperty(q, count, "Title", out, sizeof(out), false)) { |
723 | int i; |
723 | int i; |