home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Graphics / PPT / pluginsrc / sample_loader / loader.c next >
C/C++ Source or Header  |  2000-02-06  |  7KB  |  302 lines

  1. /*
  2.     PROJECT: ppt
  3.     MODULE:  testloader
  4.  
  5.     A new style loader.  PPT and this file are (C) Janne Jalkanen 1998.
  6.  
  7.     $Id: loader.c,v 1.2 1999/11/28 18:47:04 jj Exp jj $
  8. */
  9.  
  10. #include <pptplugin.h>
  11.  
  12. /*----------------------------------------------------------------------*/
  13. /* Defines */
  14.  
  15. /*
  16.     You should define this to your module name. Try to use something
  17.     short, as this is the name that is visible in the PPT filter listing.
  18. */
  19.  
  20. #define MYNAME      "Dummy"
  21.  
  22. /*----------------------------------------------------------------------*/
  23. /* Global variables. Generally, you should keep these to the minimum,
  24.    as it may well be that two copies of this same code is run at
  25.    the same time. */
  26.  
  27. /*
  28.     Just a simple string describing this effect.
  29. */
  30.  
  31. const char infoblurb[] =
  32.     "This is just a sample io module,\n"
  33.     "which does nothing.";
  34.  
  35. /*
  36.     This is the global array describing your effect. For a more detailed
  37.     description on how to interpret and use the tags, see docs/tags.doc.
  38. */
  39.  
  40. const struct TagItem MyTagArray[] = {
  41.  
  42.     /*
  43.      *  Tells the capabilities of this loader/saver unit.
  44.      */
  45.  
  46.     PPTX_Load,              TRUE,
  47.     PPTX_ColorSpaces,       CSF_RGB|CSF_GRAYLEVEL|CSF_LUT,
  48.  
  49.     /*
  50.      *  Here are some pretty standard definitions. All iomodules should have
  51.      *  these defined.
  52.      */
  53.  
  54.     PPTX_Name,              (ULONG) MYNAME,
  55.  
  56.     /*
  57.      *  Other tags go here. These are not required, but very useful to have.
  58.      */
  59.  
  60.     PPTX_Author,            (ULONG)"My Own Name",
  61.     PPTX_InfoTxt,           (ULONG)infoblurb,
  62.  
  63.     PPTX_SupportsGetArgs,   TRUE,
  64.  
  65.     PPTX_RexxTemplate,      (ULONG)NULL,
  66.  
  67.     PPTX_PreferredPostFix,(ULONG)".jpg",
  68.     PPTX_PostFixPattern,(ULONG)"#?.(jpg|jpeg|jfif)",
  69.  
  70.     TAG_END, 0L
  71. };
  72.  
  73. struct Values {
  74.     ULONG foobar;
  75. };
  76.  
  77. /*----------------------------------------------------------------------*/
  78. /* Code */
  79.  
  80. #ifdef __SASC
  81. /* Disable SAS/C control-c handling. */
  82. void __regargs __chkabort(void) {}
  83. void __regargs _CXBRK(void) {}
  84. #endif
  85.  
  86. LIBINIT
  87. {
  88.     return 0;
  89. }
  90.  
  91. LIBCLEANUP
  92. {
  93. }
  94.  
  95. IOINQUIRE(attr,PPTBase,IOModuleBase)
  96. {
  97.     return TagData( attr, MyTagArray );
  98. }
  99.  
  100. /****** iomodule/IOCheck ******************************************
  101. *
  102. *   NAME
  103. *       IOCheck - Checks if this module can handle files of this type.
  104. *
  105. *   SYNOPSIS
  106. *       success = IOCheck( fh, len, buf, PPTBase )
  107. *       D0                 D0  D1   A0   A3
  108. *
  109. *       BOOL IOCheck( BPTR, ULONG, UBYTE *, struct PPTBase * );
  110. *
  111. *   FUNCTION
  112. *       Checks if the given file is in a correct format.
  113. *
  114. *   INPUTS
  115. *       fh - open filehandle to the file to be checked.
  116. *       len - how many bytes are in buf
  117. *       buf - len bytes from the beginning of the file
  118. *
  119. *   RESULT
  120. *       Returns TRUE, if this IO module can handle this file,
  121. *       otherwise FALSE.
  122. *
  123. *   EXAMPLE
  124. *
  125. *   NOTES
  126. *
  127. *   BUGS
  128. *
  129. *   SEE ALSO
  130. *
  131. *****************************************************************************
  132. *
  133. */
  134.  
  135. IOCHECK(fh,len,buf,PPTBase,IOModuleBase)
  136. {
  137.     D(bug("IOCheck()\n"));
  138.     return FALSE;
  139. }
  140.  
  141. /****** iomodule/IOLoad ******************************************
  142. *
  143. *   NAME
  144. *       IOLoad - Loads an image from the disk.
  145. *
  146. *   SYNOPSIS
  147. *       result = IOLoad( fh, frame, tags, PPTBase )
  148. *       D0               D0  A0     A1    A3
  149. *
  150. *       PERROR IOLoad( BPTR, FRAME *, struct TagItem *, struct PPTBase * );
  151. *
  152. *   FUNCTION
  153. *       This function should perform the actual loading.
  154. *       Please see the actual example code.
  155. *
  156. *   INPUTS
  157. *
  158. *   RESULT
  159. *
  160. *   EXAMPLE
  161. *
  162. *   NOTES
  163. *
  164. *   BUGS
  165. *       Entry incomplete
  166. *
  167. *   SEE ALSO
  168. *
  169. *****************************************************************************
  170. *
  171. */
  172.  
  173. IOLOAD(fh,frame,tags,PPTBase,IOModuleBase)
  174. {
  175.     D(bug("IOLoad()\n"));
  176.     SetErrorMsg(frame,"This is just a test");
  177.     return PERR_ERROR;
  178. }
  179.  
  180. /****** iomodule/IOSave ******************************************
  181. *
  182. *   NAME
  183. *       IOSave - Saves the frame.
  184. *
  185. *   SYNOPSIS
  186. *       result = IOSave( fh, type, frame, tags, PPTBase )
  187. *       D0               D0  D1    A0     A1    A3
  188. *
  189. *       PERROR IOSave( BPTR, ULONG, FRAME *, struct TagItem *, struct PPTBase * );
  190. *
  191. *   FUNCTION
  192. *       This function should save the frame.
  193. *
  194. *   INPUTS
  195. *       type - Tells the type of the file.  If CSF_LUT, then
  196. *           you should use GetBitmapRow() to read the data from the
  197. *           frame, as it is in bitmapped format.
  198. *
  199. *   RESULT
  200. *
  201. *   EXAMPLE
  202. *
  203. *   NOTES
  204. *
  205. *   BUGS
  206. *       Entry incomplete
  207. *
  208. *   SEE ALSO
  209. *
  210. *****************************************************************************
  211. *
  212. */
  213.  
  214. static
  215. PERROR ParseRexxArgs( struct Values *val, ULONG *args, struct PPTBase *PPTBase )
  216. {
  217.     /* This is just a sample */
  218.     if( args[0] ) {
  219.         val->foobar = PEEKL( args[0] ); // Reads a LONG
  220.     }
  221.  
  222.     return PERR_OK;
  223. }
  224.  
  225. /*
  226.     Format can be any of CSF_* - flags
  227. */
  228. IOSAVE(fh,format,frame,tags,PPTBase,IOModuleBase)
  229. {
  230.     D(bug("IOSave(type=%08X)\n",format));
  231.     SetErrorMsg(frame,"This is just a test");
  232.     return PERR_UNKNOWNTYPE;
  233. }
  234.  
  235. /****** iomodule/IOGetArgs ******************************************
  236. *
  237. *   NAME
  238. *       IOGetArgs (added in PPT v6)
  239. *
  240. *   SYNOPSIS
  241. *       result = IOGetArgs( type, frame, tags, PPTBase )
  242. *       D0                  D1    A0     A1    A3
  243. *
  244. *       PERROR IOGetArgs( ULONG, FRAME *, struct TagItem *, struct PPTBase * );
  245. *
  246. *   FUNCTION
  247. *       Gets an argument string from the user for later use in AREXX.
  248. *
  249. *   INPUTS
  250. *       tags - This array contains a special PPTX_ArgBuffer tag,
  251. *           whose ti_Data points to a string where you should
  252. *           then print your argument array.
  253. *
  254. *   RESULT
  255. *
  256. *   EXAMPLE
  257. *
  258. *   NOTES
  259. *       IO module version should be over 3 or over.  It is not actually checked
  260. *       but it makes life slightly easier.
  261. *
  262. *   BUGS
  263. *       Entry incomplete
  264. *
  265. *   SEE ALSO
  266. *       effect/EffectGetArgs
  267. *
  268. *****************************************************************************
  269. *
  270. */
  271.  
  272. IOGETARGS( type, frame, tags, PPTBase, EffectBase )
  273. {
  274.     struct Values *opt, val;
  275.     ULONG *origargs;
  276.     STRPTR buffer;
  277.     PERROR res = PERR_OK;
  278.  
  279.     if( opt = GetOptions(MYNAME) ) {
  280.         val = *opt;
  281.     }
  282.  
  283.     buffer = (STRPTR) TagData( PPTX_ArgBuffer, tags );
  284.  
  285.     if( origargs = (ULONG *)TagData( PPTX_RexxArgs, tags ) )
  286.         res = ParseRexxArgs( &val, origargs, PPTBase );
  287.  
  288.     if( res == PERR_OK ) {
  289.         /*
  290.          *  Start the GUI
  291.          */
  292.     }
  293.  
  294.     return res;
  295. }
  296.  
  297.  
  298. /*----------------------------------------------------------------------*/
  299. /*                            END OF CODE                               */
  300. /*----------------------------------------------------------------------*/
  301.  
  302.