Subversion Repositories filter_foundry

Rev

Rev 85 | Rev 94 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.     This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
  3.     Copyright (C) 2003-7 Toby Thain, toby@telegraphics.com.au
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by  
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License  
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18. */
  19.  
  20. #include "world.h"
  21.  
  22. #include "PIFilter.h"
  23.  
  24. #include "entry.h"
  25.  
  26. #include "choosefile.h"
  27. #include "ui.h"
  28. #include "file_compat.h"
  29. #include "symtab.h"
  30. #include "PARM.h"
  31.  
  32. enum{
  33.         TAB = 011,
  34.         LF  = 012,
  35.         CR  = 015,
  36.  
  37.         CHUNK_ROWS = 64,
  38.  
  39.         PARM_TYPE = 'PARM',
  40.         PARM_ID = 16000,
  41.         OBFUSCDATA_ID = 16001,
  42.         TEXT_FILETYPE = 'TEXT',
  43.         SIG_SIMPLETEXT = 'ttxt',
  44.         PS_FILTER_FILETYPE = '8BFM'
  45. };
  46.  
  47. typedef struct{
  48.         Boolean standalone,parmloaded,obfusc;
  49.         PARM_T parm;
  50. } globals_t;
  51.  
  52. extern globals_t *gdata;
  53. extern FilterRecordPtr gpb;
  54.  
  55. extern struct node *tree[4];
  56. extern char *err[4];
  57. extern int errpos[4],errstart[4],nplanes;
  58. extern value_type slider[8],cell[0x100],map[4][0x100];
  59. extern char *expr[4];
  60. extern long maxSpace;
  61.  
  62. extern int tokpos,tokstart,varused[];
  63. extern char *errstr;
  64.  
  65. #if 1
  66. #define PINEWHANDLE             gpb->handleProcs->newProc
  67. #define PIDISPOSEHANDLE gpb->handleProcs->disposeProc
  68. #define PIGETHANDLESIZE gpb->handleProcs->getSizeProc
  69. #define PISETHANDLESIZE gpb->handleProcs->setSizeProc
  70. #define PILOCKHANDLE    gpb->handleProcs->lockProc
  71. #define PIUNLOCKHANDLE  gpb->handleProcs->unlockProc
  72. #else
  73. // avoid host callbacks for AE
  74. #define PINEWHANDLE             NewHandle
  75. #define PIDISPOSEHANDLE DisposeHandle
  76. #define PIGETHANDLESIZE GetHandleSize
  77. #define PISETHANDLESIZE(h,s) ( SetHandleSize(h,s),MemError() )
  78. #define PILOCKHANDLE(h,f) ( HLock(h),*(h) )
  79. #define PIUNLOCKHANDLE  HUnlock
  80. #endif
  81.  
  82. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  83. #define MAX(a,b) ((a) > (b) ? (a) : (b))
  84.  
  85. #define DBG(x)
  86. //#define DEBUG
  87.  
  88.  
  89. DLLEXPORT MACPASCAL
  90. void ENTRYPOINT(short selector,FilterRecordPtr epb,long *data,short *result);
  91.  
  92. void DoPrepare (FilterRecordPtr epb);
  93. void DoStart (FilterRecordPtr epb);
  94. OSErr DoContinue (FilterRecordPtr epb);
  95. void DoFinish (FilterRecordPtr epb);
  96. void RequestNext (FilterRecordPtr epb,long);
  97.  
  98. Boolean readparams(Handle h,Boolean alerts,char **reason);
  99. Handle readfileintohandle(FILEREF r);
  100. Boolean readfile(StandardFileReply *sfr,char **reason);
  101. Boolean readPARM(Ptr h,PARM_T *parm,char **reasonstr,int fromwin);
  102.  
  103. OSErr saveparams(Handle h);
  104. OSErr savehandleintofile(Handle h,FILEREF r);
  105. Boolean savefile(StandardFileReply *sfr);
  106.  
  107. OSErr make_standalone(StandardFileReply *sfr);
  108.  
  109. Boolean setup(FilterRecordPtr pb);
  110. void evalpixel(unsigned char *outp,unsigned char *inp);
  111. OSErr process_scaled(FilterRecordPtr pb, Boolean progress,
  112.                                          Rect *filterRect, Rect *outRect,
  113.                                          void *outData, long outRowBytes, double zoom);
  114.  
  115. unsigned long printablehash(unsigned long hash);
  116. long fixpipl(PIPropertyList *pipl,long origsize,StringPtr title);
  117. long fixaete(unsigned char *p,long origsize,StringPtr title);
  118. void obfusc(unsigned char *pparm,size_t size);
  119.  
  120. Boolean loadfile(StandardFileReply *sfr,char **reason);
  121. Boolean readPARMresource(HMODULE hm,char **reason,int readobfusc);
  122.  
  123. void dbglasterror(char*);
  124.  
  125. // from parser.y
  126. struct node *parseexpr(char *s);
  127.