home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 439.lha / Spy_v1.0 / src / SPY.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-13  |  80.8 KB  |  3,827 lines

  1.  /****************************************************************************
  2.  
  3.  
  4.  
  5.                     *********    *********    *       *
  6.                     *            *       *    *       *
  7.                     *            *       *    *       *
  8.                     *********    *********    *********
  9.                             *    *                *
  10.                             *    *                *
  11.                     *********    *                *
  12.  
  13.  
  14.  
  15.                               Version 1.0
  16.  
  17.  
  18.  
  19.                           by Federico Giannici
  20.  
  21.                              Viale Francia 4
  22.                              90146 Palermo
  23.                              Italy
  24.  
  25.  
  26.  
  27.  
  28. It's a SPY of the main AmigaDOS and EXEC function calls.
  29.  
  30.  
  31. -----------------------------------------------------------------------------
  32. This source is provided for you to see the techniques I used to write SPY.
  33. You can, obviously, use it to make your experiments and you can take some
  34. routines to insert in your programs. But you CANNOT modify, recompile and
  35. distribute the modified version to anyone without my permission.
  36. Be a programmer not a copier.
  37. -----------------------------------------------------------------------------
  38.  
  39.  
  40.  
  41. Compile with Lattice C 5.02 or subsequent, with the -v compiler option
  42. (also for SPYFunc.c).
  43.  
  44.  
  45.  
  46. STORY:
  47.     21/08/89    v0.1
  48.                     Inizio sperimentazioni
  49.     26/10/89    v0.2
  50.                     Nuovo inizio
  51.                     Preparazione menu`
  52.                     Inizio prima routine (newopen())
  53.                     Routines di condivisione della finestra in multitasking
  54.                     Gadget GO ON
  55.                     Utilizzo del timer.device
  56.                     Quit sicuro (il piu` possibile)
  57.                     La maggior parte delle funzioni DOS
  58.                     Menu Functions
  59.     20/12/89    v0.3
  60.                     Sostituzione menu functions con finestra
  61.                     Altre funzioni DOS
  62.                     Gadgets in fwindow
  63.     24/12/89    v0.4
  64.                     LOGO!
  65.                     Divisione del source in piu` parti
  66.                     Inizio routines EXEC
  67.                     Gestione msg del WAIT FOR GO
  68.                     AllocMem solo se fallisce (pericolo di loop infiniti)
  69.                     Quit ancora piu` sicuro
  70.                     Problemi con le funzioni EXEC
  71.                     Niente informazioni con stack insufficiente
  72.                     Attesa in ownwindow()
  73.                     Bug in ownwindow()
  74.                     Modifica funzione newexit()
  75.                     Implementate ultime funzioni EXEC
  76.                     Eliminata funzione newfindtask(), troppi problemi!
  77.                     Problemi funzione AddPort()
  78.     27/01/90    v0.5
  79.                     Revisione generale
  80.                     ScreenFlash
  81.                     Logo autocentrante
  82.                     GO ON con tastiera
  83.     02/02/90    v0.6
  84.                     Inizio save e load configuration
  85.     20/02/90    v0.7
  86.                     logoImage, wallImage, wallhImage
  87.                     Risistemazione gadget (con wall)
  88.                     Risistemazione info
  89.                     Save e Load config
  90.                     Ricostruzione nome e path del lock
  91.                     Utilizzo della stampante
  92.     05/03/90    v0.8
  93.                     Memorizzazione nome dei FileHandle
  94.                     Scrittura buffer di Read() e Write()
  95.     13/02/90    v1.0
  96.                     PRIMA RELEASE UFFICIALE
  97.     28/02/90    Adesso
  98.  
  99.  
  100. ****************************************************************************/
  101.  
  102.  
  103.  
  104. #include    "SPY.h"
  105.  
  106.  
  107. #define    VERSIONE    "1.0 "        /*   4 caratteri   */
  108. #define    LIBVER    33
  109.  
  110. #define    ITEML    4        /*   leftborder degli item   */
  111. #define    ITEMD    12        /*   distanza tra gli item   */
  112. #define    ITEMH    ITEMD
  113. #define    ITEM0W    (21*8)        /*   width degli item   */
  114. #define    ITEM1W    (15*8)
  115. #define    ITEMTEXTT    ((ITEMH-8)/2)
  116.  
  117. #define    WINDW    400        /*   Largezza iniziale della finestra principale   */
  118. #define    WINDH    150        /*   Altezza     "       "       "        "        */
  119. #define    WINDL    (640-WINDW-10)        /*   Left   */
  120. #define    WINDT    (8)                    /*   Top   */
  121.  
  122. #define    FWINDW    580        /*   Parametri gadget delle nuove funzioni   */
  123. #define    FWINDH    190
  124. #define    FTEXTL    (CHECKWIDTH)        /*   Distanza del testo elementi fwindow dal bordo   */
  125. #define    FGADGL    30        /*   Distanza fgadget dal bordo   */
  126. #define    FGADGT    30
  127. #define    FGADGT2    (FGADGT+FGADGD*6+FGADGD*2)
  128. #define    FGADGW    125
  129. #define    FGADGH    10
  130. #define    FGADGD    10
  131. #define    FGADGCOL    (FGADGW+10)        /*   Distanza tra colonne di gadget in fwindow   */
  132.  
  133. #define    WALLW    93        /*   Dimensioni wallImage   */
  134. #define    WALLH    16
  135.  
  136. #define    FWWALLNUM    6        /*   Numero di wall in fwindow   */
  137. #define    FWALLL    ((FWINDW-WALLW*FWWALLNUM)/2)
  138. #define    FWALLT    (FWINDH-WALLH-8)
  139.  
  140. #define    WALLHW    56
  141. #define    WALLHH    8
  142. #define    WALLHT    (-WALLHH)
  143. #define    WALLHL    ((GADGW-WALLHW)/2)
  144.  
  145. #define    GADGW    80        /*   Dimensioni gadget (wall)   */
  146. #define    GADGH    WALLH
  147.  
  148. #define    FWGW    GADGW        /*   Width dei gadget fwindow   */
  149. #define    FWGH    GADGH
  150. #define    FWGT    FWALLT
  151. #define    FWGD    ((WALLW*FWWALLNUM)/5)
  152. #define    FWGL    (FWALLL+(FWGD-FWGW)/2)
  153. #define    FWGTT    ((FWGH-8)/2)        /*   Top del testo gadget fwindow   */
  154. #define    FOKID        1        /*   ID gadget fwindow   */
  155. #define    FRESTOREID    2
  156. #define    FALLID        3
  157. #define    FNONEID        4
  158. #define    FCANCELID    5
  159.  
  160. #define    CWINDW    310        /*   cwindow, richiesta nome configurazione   */
  161. #define    CWINDH    80
  162. #define    CWGW    FWGW
  163. #define    CWGH    FWGH
  164. #define    CWGTT    FWGTT
  165. #define    CWWALLNUM    3
  166. #define    CWALLL    ((CWINDW-WALLW*CWWALLNUM)/2)
  167. #define    CWALLT    (CWINDH-WALLH-8)
  168. #define    CWGD    ((WALLW*CWWALLNUM)/2)
  169. #define    CWGL    (CWALLL+(CWGD-CWGW)/2)
  170. #define    CWGT    CWALLT
  171. #define    CGSTRLEN    30        /*   Lunghezza gadget nome configurazione   */
  172. #define    CSTRLEN        50        /*   Lunghezza nome configurazione   */
  173. #define    COKID        1        /*   ID Gadget cwindow   */
  174. #define    CCANCELID    2
  175.  
  176. #define    IWINDW    (window->GZZWidth)        /*   Larghezza finestra interna   */
  177. #define    IWINDH    (window->GZZHeight)
  178.  
  179. #define    LOGOW    164        /*   Parametri info   */
  180. #define    LOGOH    41
  181. #define    ALLLOGOW    LOGOW
  182. #define    ALLLOGOH    (LOGOH+4+20+10)
  183. #define    INFOT        (-30)
  184. #define    INFOLOGOT    (INFOT+5)
  185. #define    INFOTEXTT    (LOGOH+INFOLOGOT+25-INFOT)
  186. #define    INFOTEXTD    11
  187. #define    INFOADDRT    (INFOTEXTT+2*INFOTEXTD)
  188.  
  189. #define INFOW    (40*8)        /*   Dimensioni subitem info   */
  190. #define    INFOMAXH    (INFOADDRT+4*INFOTEXTD+1+INFOT)
  191.  
  192. #define    NOTIMPVECTNUM    0        /*   Numero di funzioni non ancora implementate   */
  193. #define    GADGNUM        VECTNUM
  194.  
  195. #define    FLASHDELAY    300000        /*   .3 secondi   */
  196. #define    QUITDELAY    200000
  197. #define    CONFIGDELAY    200000
  198. #define    OWNWINDOWDELAY    400000
  199.  
  200. #define    MINSTACK    1600        /*   Minimo stack per poter fare l'ouput   */
  201. #define    ERRORTEXTLEN    80        /*   Lunghezza massima del messaggio di errore   */
  202. #define    LOCKNAMELEN    60        /*   Lunghezza massima del nome del lock   */
  203. #define    FHNAMELEN    39        /*   Lunghezza massima nome FileHandle   */
  204. #define    BUFFERLEN    60        /*   Lunghezza massima di buffer visualizzato   */
  205. #define    TEXTLEN        80        /*   Lunghezza massima delle stringhe   */
  206.  
  207. #define    ALLFHLIST    for( fhn=(struct fhnode *)(fhlist.mlh_Head); fhn->node.mln_Succ; fhn=(struct fhnode *)(fhn->node.mln_Succ) )
  208.  
  209. #define    JMPCODE    0x4EF9            /*   Opcode di JMP <address>   */
  210.  
  211. #define    FINEHELP    ((UBYTE *)-1)
  212.  
  213. #define    IO    (struct IORequest *)
  214.  
  215. #define    fgadget        gadgetopen
  216. #define    itemactivated    item00
  217. #define    itemprinter        item00b
  218.  
  219.  
  220.  
  221. /*****   Le mie proto   *****/
  222. void quit( void );
  223. void saveconfig( void );
  224. BOOL writeitem( struct MenuItem *item );
  225. BOOL write( UBYTE *data, COUNT len );
  226. void loadconfig( void );
  227. BOOL readitem( struct MenuItem *item );
  228. BOOL read( UBYTE *data, COUNT len );
  229. BOOL getconfigname( UBYTE *saveorload );
  230. void goin( void );
  231. void goout( void );
  232. BOOL canoutput( void );
  233. void ownwindow( void );
  234. void initout( UBYTE    *funname );
  235. void endout( void );
  236. void status( UBYTE *text );
  237. struct vect *vectadd( WORD v );
  238. void getoldvect( void );
  239. void setvect( WORD v );
  240. void resetvect( WORD v );
  241. void fsetvect( WORD v );
  242. void fresetvect( WORD v );
  243. void newline( void );
  244. void littlenewline( void );
  245. void prints( UBYTE *testo );
  246. void printname( UBYTE *name );
  247. void printpname( UBYTE *name );
  248. void printbuffer( UBYTE    *buffer, LONG len );
  249. void printlock( BPTR lock );
  250. void spyprintlock( BPTR lock );
  251. void locknameadd( UBYTE *add );
  252. void printfh( BPTR fh );
  253. void printd( LONG numero );
  254. void printpd( LONG numero );
  255. void printh( ULONG numero );
  256. void printerprint( UBYTE *text );
  257. void spyprinterprint( UBYTE *text );
  258. void setprinter( void );
  259. void addfh( BPTR fh, UBYTE    *name );
  260. void remfh( BPTR fh );
  261. struct fhnode *findfh( BPTR fh );
  262. void clearfh( void );
  263. void functions( void );
  264. void setfgadget( void );
  265. void openall( void );
  266. void openwindow( void );
  267. void fine( UBYTE *text );
  268.  
  269.  
  270. /*****   Nuove Funzioni, definite in SPYFunc; non sono esatte ma e` piu` breve   *****/
  271. extern void    newopen();
  272. extern void    newclose();
  273. extern void    newread();
  274. extern void    newwrite();
  275. extern void    newinput();
  276. extern void    newoutput();
  277. extern void    newlock();
  278. extern void    newunlock();
  279. extern void    newduplock();
  280. extern void    newexamine();
  281. extern void    newexnext();
  282. extern void    newinfo();
  283. extern void    newdeletefile();
  284. extern void    newrename();
  285. extern void    newcreatedir();
  286. extern void    newcurrentdir();
  287. extern void    newparentdir();
  288. extern void    newseek();
  289. extern void    newexecute();
  290. extern void    newloadseg();
  291. extern void    newunloadseg();
  292. extern void    newcreateproc();
  293. extern void    newexit();
  294. extern void    newioerr();
  295. extern void newallocmem();
  296. extern void newopendevice();
  297. extern void newclosedevice();
  298. extern void newadddevice();
  299. extern void newopenlibrary();
  300. extern void newoldopenlibrary();
  301. extern void newcloselibrary();
  302. extern void newaddlibrary();
  303. extern void newopenresource();
  304. extern void newaddresource();
  305. extern void newfindport();
  306. extern void newaddport();
  307. extern void newfindsemaphore();
  308. extern void newaddsemaphore();
  309. extern void newfindname();
  310.  
  311.  
  312.  
  313.  
  314. /*****   Stringe ricorrenti   *****/
  315. UBYTE    topaz[]="topaz.font";
  316. UBYTE    notimer[]="Cannot open timer.device";
  317.  
  318.  
  319. /*****   Per la stampante   *****/
  320. UBYTE    prtnameon[]="";
  321. UBYTE    prtnameoff[]="";
  322. UBYTE    prtfunnameon[]="---w";
  323. UBYTE    prtfunnameoff[]="w------";
  324.  
  325.  
  326. struct TextAttr tanormal=
  327.     {
  328.     topaz,
  329.     8,
  330.     FS_NORMAL,
  331.     FPF_ROMFONT,
  332.     };
  333. struct TextAttr tai=
  334.     {
  335.     topaz,
  336.     8,
  337.     FSF_ITALIC,
  338.     FPF_ROMFONT
  339.     };
  340. struct TextAttr tab=
  341.     {
  342.     topaz,
  343.     8,
  344.     FSF_BOLD,
  345.     FPF_ROMFONT
  346.     };
  347. struct TextAttr taiu=
  348.     {
  349.     topaz,
  350.     8,
  351.     FSF_ITALIC | FSF_UNDERLINED,
  352.     FPF_ROMFONT
  353.     };
  354. struct TextAttr tabu=
  355.     {
  356.     topaz,
  357.     8,
  358.     FSF_BOLD | FSF_UNDERLINED,
  359.     FPF_ROMFONT
  360.     };
  361.  
  362.  
  363. UWORD __chip logoData[902] = {
  364.     /* BitPlane 0 */
  365.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1E00,0x0000,0x0000,0x0000,0x0000,
  366.    0x0000,0x0000,0x0000,0x0000,0x0000,0x3FF0,0xFF80,0x0000,0x0000,0x0000,0x0000,
  367.    0x0000,0x0000,0x0000,0x0000,0x0000,0x7FFE,0xFFC0,0x0000,0x0000,0x0000,0x0000,
  368.    0x0000,0x0000,0x0000,0x0000,0x0000,0xFFE1,0xFFE0,0x0000,0x0000,0x0000,0x0000,
  369.    0x0000,0x0000,0x0000,0x0000,0x0000,0xFFCB,0xFFF0,0x0000,0x0000,0x0000,0x0000,
  370.    0x0000,0x0000,0x0000,0x0000,0x0001,0xFFFF,0xFFF8,0x0000,0x0000,0x0000,0x0000,
  371.    0x0000,0x0000,0x0000,0x0000,0x0001,0xFFFF,0xFFF8,0x0000,0x0000,0x0000,0x0000,
  372.    0x0000,0x0000,0x0000,0x0000,0x0002,0xFFFF,0xFFFF,0xF800,0x0000,0x0000,0x0000,
  373.    0x0000,0x0000,0x0000,0x0000,0x005F,0xFFE0,0x0000,0x0000,0x0000,0x0000,0x0000,
  374.    0x0000,0x0000,0x0000,0x0000,0x00FC,0x001F,0xFFE0,0x0000,0x0000,0x0000,0x0000,
  375.    0x0000,0x0000,0x0000,0x0000,0x0003,0xFFFF,0xFFF0,0x0000,0x0000,0x0000,0x0000,
  376.    0x0000,0x0000,0x0000,0x0000,0x0007,0xFC06,0xC078,0x0000,0x0000,0x0000,0x0000,
  377.    0x0000,0x0000,0x0000,0x0000,0x0007,0x8000,0x0008,0x0000,0x0000,0x0000,0x0000,
  378.    0x0000,0x0000,0x0000,0x0000,0x0004,0x7803,0x8020,0x0000,0x0000,0x0000,0x0000,
  379.    0x0000,0x0000,0x0000,0x0000,0x0007,0xF803,0x8038,0x0000,0x0000,0x0000,0x0000,
  380.    0x0000,0x0000,0x0000,0x0000,0x0007,0xFC07,0xC078,0x0000,0x0000,0x0000,0x0000,
  381.    0x0000,0x0000,0x0000,0x0000,0x0003,0xFFFF,0xFFF0,0x0000,0x0000,0x0000,0x0000,
  382.    0x0000,0x0000,0x0000,0x06EC,0x0001,0xFFFF,0xFFE0,0x000D,0xD800,0x0000,0x0000,
  383.    0x0000,0x0000,0x0000,0x0FFE,0x0000,0xFFFF,0xFFC0,0x001F,0xFC00,0x0000,0x0000,
  384.    0x0000,0x0000,0x0000,0x0FFF,0x0000,0x007F,0xF000,0x003F,0xFC00,0x0000,0x0000,
  385.    0x0000,0x0000,0x0000,0x0EEF,0x0000,0x00FF,0xF000,0x003D,0xDC00,0x0000,0x0000,
  386.    0x0000,0x0000,0x0000,0x0EEE,0x0000,0x3DFF,0xF800,0x1C1D,0xDC00,0x0000,0x0000,
  387.    0x0000,0x0000,0x000F,0xFFEC,0x0001,0xFFFF,0xF800,0x3C0D,0xD9E0,0x0000,0x0000,
  388.    0x0000,0x0000,0x007F,0xFFC0,0x0001,0xF3FF,0xFC00,0x0E00,0x03E0,0x0000,0x0000,
  389.    0x0000,0x0000,0x00D8,0x0000,0x0001,0xC3FF,0xFC00,0x0700,0x0F80,0x0000,0x0000,
  390.    0x0000,0x0000,0x0380,0x0000,0x0003,0xC3FF,0xFC00,0x0300,0x0E00,0x0000,0x0000,
  391.    0x0000,0x0000,0x0380,0x0000,0x0001,0xC1FF,0xFC00,0x0180,0x1C00,0x0000,0x0000,
  392.    0x0000,0x0000,0x0380,0x0000,0x0003,0xC1FF,0xF800,0x01C0,0x7800,0x0000,0x0000,
  393.    0x0000,0x0000,0x0780,0x0000,0x0001,0xC0FF,0xE000,0x0160,0x7000,0x0000,0x0000,
  394.    0x0000,0x0000,0x01FF,0xFFF8,0x0000,0xC03F,0x8000,0x00A1,0xD000,0x0000,0x0000,
  395.    0x0000,0x0000,0x007E,0xDDFC,0x0000,0x7FFC,0x0000,0x007F,0xE000,0x0000,0x0000,
  396.    0x0000,0x0000,0x0000,0x001C,0x0000,0xFFB0,0x0000,0x001F,0x8000,0x0000,0x0000,
  397.    0x0000,0x0000,0x0000,0x001E,0x0000,0x6000,0x0000,0x003E,0x0000,0x0000,0x0000,
  398.    0x0000,0x0000,0x0000,0x001C,0x0000,0x7000,0x0000,0x001C,0x0000,0x0000,0x0000,
  399.    0x0000,0x0000,0x0000,0x07FC,0x0000,0x7000,0x0000,0x0078,0x0000,0x0000,0x0000,
  400.    0x0000,0x0000,0x00FF,0x71F0,0x0000,0x7800,0x0000,0x0060,0x0000,0xFC3E,0x0000,
  401.    0x0000,0x0000,0x03FB,0x3800,0x0000,0x3C00,0x0000,0x00E0,0x0001,0x8060,0x0000,
  402.    0x0000,0x0000,0x01C0,0x0000,0x0000,0x1E00,0x0000,0x01C0,0x0001,0xF060,0x0000,
  403.    0x0000,0x0000,0x0000,0x0000,0x0000,0x3E00,0x0000,0x03E0,0x0001,0x8067,0x0000,
  404.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03C0,0x0001,0x803C,0x0000,
  405.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  406.     /* BitPlane 1 */
  407.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  408.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  409.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  410.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  411.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  412.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  413.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  414.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  415.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  416.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  417.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  418.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFC06,0xC07F,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  419.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8000,0x000F,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  420.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFC,0x7803,0x8027,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  421.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xF803,0x803F,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  422.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFC07,0xC07F,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  423.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  424.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  425.    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  426.    0xFFFF,0xFF80,0x0000,0x0FFF,0x0000,0x007F,0xF000,0x003F,0xFC00,0x003F,0xFFFF,
  427.    0xFFFF,0xFF3F,0xFFFF,0xFFFF,0xFF3F,0xFFFF,0xFFFF,0xFFBF,0xFFFF,0xFF9F,0xFFFF,
  428.    0xFFFF,0xFF7F,0xFFFF,0xFFFF,0xFFBF,0xC3FF,0xFFFF,0xE39F,0xFFFF,0xFFC5,0xFFFF,
  429.    0xFFFF,0xFF3F,0xFFF0,0x06FF,0xFF3E,0x01FF,0xFFFF,0xC39F,0xFE1F,0xFFFC,0x7FFF,
  430.    0xFFFF,0xFF3F,0xFF80,0x003F,0xFF3E,0x0FFF,0xFFFF,0xF19F,0xFC1F,0xFFFF,0x1FFF,
  431.    0xFFFF,0xFF3F,0xFF27,0xFFFF,0xFF3E,0x3FFF,0xFFFF,0xF89F,0xF07F,0xFFFF,0xCFFF,
  432.    0xFFFF,0xFF3F,0xFC7F,0xFFFF,0xFE3C,0x3FFF,0xFFFF,0xFC9F,0xF1FF,0xFFFF,0xCFFF,
  433.    0xFFF8,0x0000,0x0000,0x0000,0x0000,0x07FF,0xFC00,0x0000,0x0000,0x0000,0x5FFF,
  434.    0xFFF3,0xFFFF,0xFC7F,0xFE7F,0xFFFC,0x3FFF,0xFF1F,0xFE3F,0x87FF,0xFF3F,0xFFFF,
  435.    0xFFF3,0xFFFF,0xF87F,0xFE7F,0xFFFE,0x3FFF,0xFF3F,0xFE9F,0x8FFF,0xFF7F,0xFFFF,
  436.    0xFFF3,0xFFFF,0xFE00,0x0007,0xFFFF,0x3FFF,0xFF3F,0xFF5E,0x2FFF,0xFF3F,0xFFFF,
  437.    0xFFF3,0xFFFF,0xFF81,0x2203,0xFFFF,0x8003,0xFF3F,0xFF80,0x1FFF,0xFFBF,0xFFFF,
  438.    0xFFF3,0xFFFF,0xFFFF,0xFE63,0xFFFF,0x004F,0xFFBF,0xFFE0,0x7FFF,0xFF3F,0xFFFF,
  439.    0xFFF1,0xFFFF,0xFFFF,0xFE61,0xFFFF,0x9FFF,0xFF3F,0xFFC1,0xFFFF,0xFF3F,0xFFFF,
  440.    0xFF00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3FFF,
  441.    0xFE7F,0xFF07,0xFFFF,0xF803,0xFFF3,0x8FFF,0xFFFF,0xFF84,0x7FFF,0xFFFF,0xCFFF,
  442.    0xFEFF,0xFFE7,0xFF00,0x8E0F,0xFFFB,0x87FF,0xFFFF,0xFF9C,0xFFFF,0xFFFF,0xCFFF,
  443.    0xFE7F,0xFFE7,0xFC04,0xC7FF,0xFFF3,0xC3FF,0xFFFF,0xFF1C,0xFFFF,0xFFFF,0xCFFF,
  444.    0xFCFF,0xFFE7,0xFE3F,0xFFFF,0xFFF3,0xE1FF,0xFFFF,0xFE3C,0xFFFF,0xFFFF,0xCFFF,
  445.    0x81FF,0xFFF7,0xFFFF,0xFFFF,0xFFF3,0xC1FF,0xFFFF,0xFC1E,0xFFFF,0xFFFF,0xCFFF,
  446.    0x1FFF,0xFFE7,0xFFFF,0xFFFF,0xFFE3,0xFFFF,0xFFFF,0xFC3C,0xFFFF,0xFFFF,0xCFFF,
  447.    0x8000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1FFF
  448. };
  449. struct Image logoImage = {
  450.     0, 0,        /* LeftEdge, TopEdge */
  451.     164, 41, 2,    /* Width, Height, Depth */
  452.     &logoData[0],    /* ImageData */
  453.     0x03, 0x00,    /* PlanePick, PlaneOnOff */
  454.     NULL        /* NextImage */
  455. };
  456.  
  457. UWORD __chip wallData[192/2] = {
  458.     /* BitPlane 1 */
  459.    0x0000,0x0800,0x0000,0x0000,0x0000,0x0007,
  460.    0xE7FF,0xFF9F,0xFFFF,0x9FFF,0xFF9F,0xFFFF,
  461.    0xEFFF,0xFF9F,0xFFFF,0x9FFF,0xFF9F,0xFFFF,
  462.    0xE7FF,0xFF9F,0xFFFF,0xBFFF,0xFF9F,0xFFFF,
  463.    0xE7FF,0xFF9F,0xFFFF,0x9FFF,0xFF9F,0xFFFF,
  464.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0007,
  465.    0xFFF9,0xFFFF,0xF3FF,0xFFE7,0xFFFF,0xF3FF,
  466.    0xFFF9,0xFFFF,0xF3FF,0xFFE7,0xFFFF,0xF7FF,
  467.    0xFFF9,0xFFFF,0xF3FF,0xFFE7,0xFFFF,0xF3FF,
  468.    0xFFFD,0xFFFF,0xF3FF,0xFFE7,0xFFFF,0xF3FF,
  469.    0x0000,0x0000,0x0000,0x0000,0x0200,0x0007,
  470.    0xCFFF,0xFF3F,0xFFFF,0x7FFF,0xFF3F,0xFFFF,
  471.    0xCFFF,0xFF3F,0xFFFF,0x3FFF,0xFF3F,0xFFFF,
  472.    0xCFFF,0xFF3F,0xFFFF,0x3FFF,0xFF3F,0xFFFF,
  473.    0xDFFF,0xFF3F,0xFFFF,0x3FFF,0xFF3F,0xFFFF,
  474.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0007
  475. };
  476. struct Image wallImage = {
  477.     0, 0,        /* LeftEdge, TopEdge */
  478.     93, 16, 2,    /* Width, Height, Depth */
  479.     &wallData[0],    /* ImageData */
  480.     0x2, 0x00,    /* PlanePick, PlaneOnOff */
  481.     NULL        /* NextImage */
  482. };
  483.  
  484. UWORD __chip wallhData[64] = {
  485.     /* BitPlane 0 */
  486.    0x0000,0x0007,0x0000,0x00FF,
  487.    0x0000,0x07DF,0x8000,0x00FF,
  488.    0x0000,0x0FBF,0xC000,0x00FF,
  489.    0x0000,0x0FFF,0xE000,0x00FF,
  490.    0x0000,0xFFFF,0xFC00,0x00FF,
  491.    0x0000,0x1FFF,0xE000,0x00FF,
  492.    0x4900,0x1000,0x0000,0x92FF,
  493.    0xFF80,0x0E18,0x6001,0xFFFF,
  494.     /* BitPlane 1 */
  495.    0xFFFF,0xFFFF,0xFFFF,0xFF00,
  496.    0xFFFF,0xFFFF,0xFFFF,0xFF00,
  497.    0xFFFF,0xFFFF,0xFFFF,0xFF00,
  498.    0xFFFF,0xFFFF,0xFFFF,0xFF00,
  499.    0xFFFF,0xFFFF,0xFFFF,0xFF00,
  500.    0xFFFF,0xFFFF,0xFFFF,0xFF00,
  501.    0xFFFF,0xF000,0x1FFF,0xFF00,
  502.    0xFFFF,0xEE18,0x7FFF,0xFF00
  503. };
  504. struct Image wallhImage = {
  505.     WALLHL, WALLHT,        /* LeftEdge, TopEdge */
  506.     56, 8, 2,    /* Width, Height, Depth */
  507.     &wallhData[0],    /* ImageData */
  508.     0x03, 0x00,    /* PlanePick, PlaneOnOff */
  509.     NULL        /* NextImage */
  510. };
  511.  
  512. struct Image wallhcImage = {
  513.     WALLHL, WALLHT,        /* LeftEdge, TopEdge */
  514.     56, 8, 2,    /* Width, Height, Depth */
  515.     &wallhData[0],    /* ImageData */
  516.     0x00, 0x02,    /* PlanePick, PlaneOnOff */
  517.     NULL        /* NextImage */
  518. };
  519.  
  520.  
  521. UWORD __chip checkData[16] = {
  522.     /* BitPlane 0 */
  523.    0x0033,
  524.    0x0066,
  525.    0x00CC,
  526.    0x0198,
  527.    0xCF30,
  528.    0x6660,
  529.    0x33C0,
  530.    0x1980,
  531.     /* BitPlane 1 */
  532.    0xFFC3,
  533.    0xFF87,
  534.    0xFF0F,
  535.    0xFE1F,
  536.    0x0C3F,
  537.    0x867F,
  538.    0xC3FF,
  539.    0xE1FF
  540. };
  541. struct Image checkImage = {
  542.     0, 0,        /* LeftEdge, TopEdge */
  543.     16, 8, 2,    /* Width, Height, Depth */
  544.     &checkData[0],    /* ImageData */
  545.     0x03, 0x00,    /* PlanePick, PlaneOnOff */
  546.     NULL        /* NextImage */
  547. };
  548.  
  549. struct Image nullimage = {
  550.     0, 0,        /* LeftEdge, TopEdge */
  551.     16, 8, 2,    /* Width, Height, Depth */
  552.     NULL,    /* ImageData */
  553.     0x0, 0x2,    /* PlanePick, PlaneOnOff */
  554.     NULL        /* NextImage */
  555. };
  556.  
  557.  
  558. struct    IntuiText    logot3=
  559.     {
  560.     3, 2,
  561.     JAM1,
  562.     (ALLLOGOW-20*8)/2+3*8, LOGOH+4+20,
  563.     &tai,
  564.     "Federico Giannici",
  565.     NULL        /*   next   */
  566.     };
  567. struct    IntuiText    logot2=
  568.     {
  569.     3, 2,
  570.     JAM1,
  571.     (ALLLOGOW-20*8)/2, LOGOH+4+20,
  572.     &tanormal,
  573.     "by",
  574.     &logot3        /*   next   */
  575.     };
  576. struct    IntuiText    logotext=
  577.     {
  578.     3, 2,
  579.     JAM1,
  580.     (ALLLOGOW-5*8)/2, LOGOH+4,
  581.     &tanormal,
  582.     "V "VERSIONE,
  583.     &logot2        /*   next   */
  584.     };
  585.  
  586.  
  587. struct    IntuiText    ftext2=
  588.     {
  589.     1, 2,
  590.     JAM1,
  591.     (FWINDW-14*8)/2, FGADGT2-13,
  592.     &tabu,
  593.     " EXEC Library ",
  594.     NULL        /*   next   */
  595.     };
  596. struct    IntuiText    ftext=        /*   Testo della fwindow   */
  597.     {
  598.     1, 2,
  599.     JAM1,
  600.     (FWINDW-13*8)/2, FGADGT-13,
  601.     &tabu,
  602.     " DOS Library ",
  603.     &ftext2        /*   next   */
  604.     };
  605.  
  606.  
  607. struct    IntuiText    gadgettextfindname=
  608.     {
  609.     3, 2,
  610.     JAM1,
  611.     FTEXTL, 1,
  612.     &tanormal,
  613.     "FindName",
  614.     NULL        /*   next   */
  615.     };
  616. struct Gadget    gadgetfindname=
  617.     {
  618.     NULL,
  619.     FGADGL+3*FGADGCOL, FGADGT2+2*FGADGD, FGADGW, FGADGH,
  620.     GADGHIMAGE | GADGIMAGE | SELECTED,
  621.     TOGGLESELECT,
  622.     BOOLGADGET,
  623.     (APTR)&nullimage,
  624.     (APTR)&checkImage,        /*   SelectRender   */
  625.     &gadgettextfindname,
  626.     NULL,
  627.     NULL,
  628.     NULL,        /*   ID   */
  629.     NULL
  630.     };
  631.  
  632. struct    IntuiText    gadgettextaddsemaphore=
  633.     {
  634.     3, 2,
  635.     JAM1,
  636.     FTEXTL, 1,
  637.     &tanormal,
  638.     "AddSemaphore",
  639.     NULL        /*   next   */
  640.     };
  641. struct Gadget    gadgetaddsemaphore=
  642.     {
  643.     &gadgetfindname,
  644.     FGADGL+3*FGADGCOL, FGADGT2+1*FGADGD, FGADGW, FGADGH,
  645.     GADGHIMAGE | GADGIMAGE | SELECTED,
  646.     TOGGLESELECT,
  647.     BOOLGADGET,
  648.     (APTR)&nullimage,
  649.     (APTR)&checkImage,        /*   SelectRender   */
  650.     &gadgettextaddsemaphore,
  651.     NULL,
  652.     NULL,
  653.     NULL,        /*   ID   */
  654.     NULL
  655.     };
  656.  
  657. struct    IntuiText    gadgettextfindsemaphore=
  658.     {
  659.     3, 2,
  660.     JAM1,
  661.     FTEXTL, 1,
  662.     &tanormal,
  663.     "FindSemaphore",
  664.     NULL        /*   next   */
  665.     };
  666. struct Gadget    gadgetfindsemaphore=
  667.     {
  668.     &gadgetaddsemaphore,
  669.     FGADGL+3*FGADGCOL, FGADGT2+0*FGADGD, FGADGW, FGADGH,
  670.     GADGHIMAGE | GADGIMAGE | SELECTED,
  671.     TOGGLESELECT,
  672.     BOOLGADGET,
  673.     (APTR)&nullimage,
  674.     (APTR)&checkImage,        /*   SelectRender   */
  675.     &gadgettextfindsemaphore,
  676.     NULL,
  677.     NULL,
  678.     NULL,        /*   ID   */
  679.     NULL
  680.     };
  681.  
  682. struct    IntuiText    gadgettextaddport=
  683.     {
  684.     3, 2,
  685.     JAM1,
  686.     FTEXTL, 1,
  687.     &tanormal,
  688.     "AddPort",
  689.     NULL        /*   next   */
  690.     };
  691. struct Gadget    gadgetaddport=
  692.     {
  693.     &gadgetfindsemaphore,
  694.     FGADGL+2*FGADGCOL, FGADGT2+3*FGADGD, FGADGW, FGADGH,
  695.     GADGHIMAGE | GADGIMAGE | SELECTED,
  696.     TOGGLESELECT,
  697.     BOOLGADGET,
  698.     (APTR)&nullimage,
  699.     (APTR)&checkImage,        /*   SelectRender   */
  700.     &gadgettextaddport,
  701.     NULL,
  702.     NULL,
  703.     NULL,        /*   ID   */
  704.     NULL
  705.     };
  706.  
  707. struct    IntuiText    gadgettextfindport=
  708.     {
  709.     3, 2,
  710.     JAM1,
  711.     FTEXTL, 1,
  712.     &tanormal,
  713.     "FindPort",
  714.     NULL        /*   next   */
  715.     };
  716. struct Gadget    gadgetfindport=
  717.     {
  718.     &gadgetaddport,
  719.     FGADGL+2*FGADGCOL, FGADGT2+2*FGADGD, FGADGW, FGADGH,
  720.     GADGHIMAGE | GADGIMAGE | SELECTED,
  721.     TOGGLESELECT,
  722.     BOOLGADGET,
  723.     (APTR)&nullimage,
  724.     (APTR)&checkImage,        /*   SelectRender   */
  725.     &gadgettextfindport,
  726.     NULL,
  727.     NULL,
  728.     NULL,        /*   ID   */
  729.     NULL
  730.     };
  731.  
  732. struct    IntuiText    gadgettextaddresource=
  733.     {
  734.     3, 2,
  735.     JAM1,
  736.     FTEXTL, 1,
  737.     &tanormal,
  738.     "AddResource",
  739.     NULL        /*   next   */
  740.     };
  741. struct Gadget    gadgetaddresource=
  742.     {
  743.     &gadgetfindport,
  744.     FGADGL+2*FGADGCOL, FGADGT2+1*FGADGD, FGADGW, FGADGH,
  745.     GADGHIMAGE | GADGIMAGE | SELECTED,
  746.     TOGGLESELECT,
  747.     BOOLGADGET,
  748.     (APTR)&nullimage,
  749.     (APTR)&checkImage,        /*   SelectRender   */
  750.     &gadgettextaddresource,
  751.     NULL,
  752.     NULL,
  753.     NULL,        /*   ID   */
  754.     NULL
  755.     };
  756.  
  757. struct    IntuiText    gadgettextopenresource=
  758.     {
  759.     3, 2,
  760.     JAM1,
  761.     FTEXTL, 1,
  762.     &tanormal,
  763.     "OpenResource",
  764.     NULL        /*   next   */
  765.     };
  766. struct Gadget    gadgetopenresource=
  767.     {
  768.     &gadgetaddresource,
  769.     FGADGL+2*FGADGCOL, FGADGT2+0*FGADGD, FGADGW, FGADGH,
  770.     GADGHIMAGE | GADGIMAGE | SELECTED,
  771.     TOGGLESELECT,
  772.     BOOLGADGET,
  773.     (APTR)&nullimage,
  774.     (APTR)&checkImage,        /*   SelectRender   */
  775.     &gadgettextopenresource,
  776.     NULL,
  777.     NULL,
  778.     NULL,        /*   ID   */
  779.     NULL
  780.     };
  781.  
  782. struct    IntuiText    gadgettextaddlibrary=
  783.     {
  784.     3, 2,
  785.     JAM1,
  786.     FTEXTL, 1,
  787.     &tanormal,
  788.     "AddLibrary",
  789.     NULL        /*   next   */
  790.     };
  791. struct Gadget    gadgetaddlibrary=
  792.     {
  793.     &gadgetopenresource,
  794.     FGADGL+1*FGADGCOL, FGADGT2+3*FGADGD, FGADGW, FGADGH,
  795.     GADGHIMAGE | GADGIMAGE | SELECTED,
  796.     TOGGLESELECT,
  797.     BOOLGADGET,
  798.     (APTR)&nullimage,
  799.     (APTR)&checkImage,        /*   SelectRender   */
  800.     &gadgettextaddlibrary,
  801.     NULL,
  802.     NULL,
  803.     NULL,        /*   ID   */
  804.     NULL
  805.     };
  806.  
  807. struct    IntuiText    gadgettextcloselibrary=
  808.     {
  809.     3, 2,
  810.     JAM1,
  811.     FTEXTL, 1,
  812.     &tanormal,
  813.     "CloseLibrary",
  814.     NULL        /*   next   */
  815.     };
  816. struct Gadget    gadgetcloselibrary=
  817.     {
  818.     &gadgetaddlibrary,
  819.     FGADGL+1*FGADGCOL, FGADGT2+2*FGADGD, FGADGW, FGADGH,
  820.     GADGHIMAGE | GADGIMAGE | SELECTED,
  821.     TOGGLESELECT,
  822.     BOOLGADGET,
  823.     (APTR)&nullimage,
  824.     (APTR)&checkImage,        /*   SelectRender   */
  825.     &gadgettextcloselibrary,
  826.     NULL,
  827.     NULL,
  828.     NULL,        /*   ID   */
  829.     NULL
  830.     };
  831.  
  832. struct    IntuiText    gadgettextoldopenlibrary=
  833.     {
  834.     3, 2,
  835.     JAM1,
  836.     FTEXTL, 1,
  837.     &tanormal,
  838.     "OldOpenLibrary",
  839.     NULL        /*   next   */
  840.     };
  841. struct Gadget    gadgetoldopenlibrary=
  842.     {
  843.     &gadgetcloselibrary,
  844.     FGADGL+1*FGADGCOL, FGADGT2+1*FGADGD, FGADGW, FGADGH,
  845.     GADGHIMAGE | GADGIMAGE | SELECTED,
  846.     TOGGLESELECT,
  847.     BOOLGADGET,
  848.     (APTR)&nullimage,
  849.     (APTR)&checkImage,        /*   SelectRender   */
  850.     &gadgettextoldopenlibrary,
  851.     NULL,
  852.     NULL,
  853.     NULL,        /*   ID   */
  854.     NULL
  855.     };
  856.  
  857. struct    IntuiText    gadgettextopenlibrary=
  858.     {
  859.     3, 2,
  860.     JAM1,
  861.     FTEXTL, 1,
  862.     &tanormal,
  863.     "OpenLibrary",
  864.     NULL        /*   next   */
  865.     };
  866. struct Gadget    gadgetopenlibrary=
  867.     {
  868.     &gadgetoldopenlibrary,
  869.     FGADGL+1*FGADGCOL, FGADGT2+0*FGADGD, FGADGW, FGADGH,
  870.     GADGHIMAGE | GADGIMAGE | SELECTED,
  871.     TOGGLESELECT,
  872.     BOOLGADGET,
  873.     (APTR)&nullimage,
  874.     (APTR)&checkImage,        /*   SelectRender   */
  875.     &gadgettextopenlibrary,
  876.     NULL,
  877.     NULL,
  878.     NULL,        /*   ID   */
  879.     NULL
  880.     };
  881.  
  882. struct    IntuiText    gadgettextadddevice=
  883.     {
  884.     3, 2,
  885.     JAM1,
  886.     FTEXTL, 1,
  887.     &tanormal,
  888.     "AddDevice",
  889.     NULL        /*   next   */
  890.     };
  891. struct Gadget    gadgetadddevice=
  892.     {
  893.     &gadgetopenlibrary,
  894.     FGADGL+0*FGADGCOL, FGADGT2+3*FGADGD, FGADGW, FGADGH,
  895.     GADGHIMAGE | GADGIMAGE | SELECTED,
  896.     TOGGLESELECT,
  897.     BOOLGADGET,
  898.     (APTR)&nullimage,
  899.     (APTR)&checkImage,        /*   SelectRender   */
  900.     &gadgettextadddevice,
  901.     NULL,
  902.     NULL,
  903.     NULL,        /*   ID   */
  904.     NULL
  905.     };
  906.  
  907. struct    IntuiText    gadgettextclosedevice=
  908.     {
  909.     3, 2,
  910.     JAM1,
  911.     FTEXTL, 1,
  912.     &tanormal,
  913.     "CloseDevice",
  914.     NULL        /*   next   */
  915.     };
  916. struct Gadget    gadgetclosedevice=
  917.     {
  918.     &gadgetadddevice,
  919.     FGADGL+0*FGADGCOL, FGADGT2+2*FGADGD, FGADGW, FGADGH,
  920.     GADGHIMAGE | GADGIMAGE | SELECTED,
  921.     TOGGLESELECT,
  922.     BOOLGADGET,
  923.     (APTR)&nullimage,
  924.     (APTR)&checkImage,        /*   SelectRender   */
  925.     &gadgettextclosedevice,
  926.     NULL,
  927.     NULL,
  928.     NULL,        /*   ID   */
  929.     NULL
  930.     };
  931.  
  932. struct    IntuiText    gadgettextopendevice=
  933.     {
  934.     3, 2,
  935.     JAM1,
  936.     FTEXTL, 1,
  937.     &tanormal,
  938.     "OpenDevice",
  939.     NULL        /*   next   */
  940.     };
  941. struct Gadget    gadgetopendevice=
  942.     {
  943.     &gadgetclosedevice,
  944.     FGADGL+0*FGADGCOL, FGADGT2+1*FGADGD, FGADGW, FGADGH,
  945.     GADGHIMAGE | GADGIMAGE | SELECTED,
  946.     TOGGLESELECT,
  947.     BOOLGADGET,
  948.     (APTR)&nullimage,
  949.     (APTR)&checkImage,        /*   SelectRender   */
  950.     &gadgettextopendevice,
  951.     NULL,
  952.     NULL,
  953.     NULL,        /*   ID   */
  954.     NULL
  955.     };
  956.  
  957. struct    IntuiText    gadgettextallocmem=
  958.     {
  959.     3, 2,
  960.     JAM1,
  961.     FTEXTL, 1,
  962.     &tanormal,
  963.     "(fail)AllocMem",
  964.     NULL        /*   next   */
  965.     };
  966. struct Gadget    gadgetallocmem=
  967.     {
  968.     &gadgetopendevice,
  969.     FGADGL+0*FGADGCOL, FGADGT2+0*FGADGD, FGADGW, FGADGH,
  970.     GADGHIMAGE | GADGIMAGE | SELECTED,
  971.     TOGGLESELECT,
  972.     BOOLGADGET,
  973.     (APTR)&nullimage,
  974.     (APTR)&checkImage,        /*   SelectRender   */
  975.     &gadgettextallocmem,
  976.     NULL,
  977.     NULL,
  978.     NULL,        /*   ID   */
  979.     NULL
  980.     };
  981.  
  982. /*****   Funzioni DOS   *****/
  983.  
  984. struct    IntuiText    gadgettextioerr=
  985.     {
  986.     3, 2,
  987.     JAM1,
  988.     FTEXTL, 1,
  989.     &tanormal,
  990.     "IoErr",
  991.     NULL        /*   next   */
  992.     };
  993. struct Gadget    gadgetioerr=
  994.     {
  995.     &gadgetallocmem,
  996.     FGADGL+3*FGADGCOL, FGADGT+5*FGADGD, FGADGW, FGADGH,
  997.     GADGHIMAGE | GADGIMAGE | SELECTED,
  998.     TOGGLESELECT,
  999.     BOOLGADGET,
  1000.     (APTR)&nullimage,
  1001.     (APTR)&checkImage,        /*   SelectRender   */
  1002.     &gadgettextioerr,
  1003.     NULL,
  1004.     NULL,
  1005.     NULL,        /*   ID   */
  1006.     NULL
  1007.     };
  1008.  
  1009. struct    IntuiText    gadgettextexit=
  1010.     {
  1011.     3, 2,
  1012.     JAM1,
  1013.     FTEXTL, 1,
  1014.     &tanormal,
  1015.     "Exit",
  1016.     NULL        /*   next   */
  1017.     };
  1018. struct Gadget    gadgetexit=
  1019.     {
  1020.     &gadgetioerr,
  1021.     FGADGL+3*FGADGCOL, FGADGT+4*FGADGD, FGADGW, FGADGH,
  1022.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1023.     TOGGLESELECT,
  1024.     BOOLGADGET,
  1025.     (APTR)&nullimage,
  1026.     (APTR)&checkImage,        /*   SelectRender   */
  1027.     &gadgettextexit,
  1028.     NULL,
  1029.     NULL,
  1030.     NULL,        /*   ID   */
  1031.     NULL
  1032.     };
  1033.  
  1034. struct    IntuiText    gadgettextcreateproc=
  1035.     {
  1036.     3, 2,
  1037.     JAM1,
  1038.     FTEXTL, 1,
  1039.     &tanormal,
  1040.     "CreateProc",
  1041.     NULL        /*   next   */
  1042.     };
  1043. struct Gadget    gadgetcreateproc=
  1044.     {
  1045.     &gadgetexit,
  1046.     FGADGL+3*FGADGCOL, FGADGT+3*FGADGD, FGADGW, FGADGH,
  1047.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1048.     TOGGLESELECT,
  1049.     BOOLGADGET,
  1050.     (APTR)&nullimage,
  1051.     (APTR)&checkImage,        /*   SelectRender   */
  1052.     &gadgettextcreateproc,
  1053.     NULL,
  1054.     NULL,
  1055.     NULL,        /*   ID   */
  1056.     NULL
  1057.     };
  1058.  
  1059. struct    IntuiText    gadgettextunloadseg=
  1060.     {
  1061.     3, 2,
  1062.     JAM1,
  1063.     FTEXTL, 1,
  1064.     &tanormal,
  1065.     "UnLoadSeg",
  1066.     NULL        /*   next   */
  1067.     };
  1068. struct Gadget    gadgetunloadseg=
  1069.     {
  1070.     &gadgetcreateproc,
  1071.     FGADGL+3*FGADGCOL, FGADGT+2*FGADGD, FGADGW, FGADGH,
  1072.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1073.     TOGGLESELECT,
  1074.     BOOLGADGET,
  1075.     (APTR)&nullimage,
  1076.     (APTR)&checkImage,        /*   SelectRender   */
  1077.     &gadgettextunloadseg,
  1078.     NULL,
  1079.     NULL,
  1080.     NULL,        /*   ID   */
  1081.     NULL
  1082.     };
  1083.  
  1084. struct    IntuiText    gadgettextloadseg=
  1085.     {
  1086.     3, 2,
  1087.     JAM1,
  1088.     FTEXTL, 1,
  1089.     &tanormal,
  1090.     "LoadSeg",
  1091.     NULL        /*   next   */
  1092.     };
  1093. struct Gadget    gadgetloadseg=
  1094.     {
  1095.     &gadgetunloadseg,
  1096.     FGADGL+3*FGADGCOL, FGADGT+1*FGADGD, FGADGW, FGADGH,
  1097.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1098.     TOGGLESELECT,
  1099.     BOOLGADGET,
  1100.     (APTR)&nullimage,
  1101.     (APTR)&checkImage,        /*   SelectRender   */
  1102.     &gadgettextloadseg,
  1103.     NULL,
  1104.     NULL,
  1105.     NULL,        /*   ID   */
  1106.     NULL
  1107.     };
  1108.  
  1109. struct    IntuiText    gadgettextexecute=
  1110.     {
  1111.     3, 2,
  1112.     JAM1,
  1113.     FTEXTL, 1,
  1114.     &tanormal,
  1115.     "Execute",
  1116.     NULL        /*   next   */
  1117.     };
  1118. struct Gadget    gadgetexecute=
  1119.     {
  1120.     &gadgetloadseg,
  1121.     FGADGL+3*FGADGCOL, FGADGT+0*FGADGD, FGADGW, FGADGH,
  1122.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1123.     TOGGLESELECT,
  1124.     BOOLGADGET,
  1125.     (APTR)&nullimage,
  1126.     (APTR)&checkImage,        /*   SelectRender   */
  1127.     &gadgettextexecute,
  1128.     NULL,
  1129.     NULL,
  1130.     NULL,        /*   ID   */
  1131.     NULL
  1132.     };
  1133.  
  1134. struct    IntuiText    gadgettextseek=
  1135.     {
  1136.     3, 2,
  1137.     JAM1,
  1138.     FTEXTL, 1,
  1139.     &tanormal,
  1140.     "Seek",
  1141.     NULL        /*   next   */
  1142.     };
  1143. struct Gadget    gadgetseek=
  1144.     {
  1145.     &gadgetexecute,
  1146.     FGADGL+2*FGADGCOL, FGADGT+5*FGADGD, FGADGW, FGADGH,
  1147.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1148.     TOGGLESELECT,
  1149.     BOOLGADGET,
  1150.     (APTR)&nullimage,
  1151.     (APTR)&checkImage,        /*   SelectRender   */
  1152.     &gadgettextseek,
  1153.     NULL,
  1154.     NULL,
  1155.     NULL,        /*   ID   */
  1156.     NULL
  1157.     };
  1158.  
  1159. struct    IntuiText    gadgettextparentdir=
  1160.     {
  1161.     3, 2,
  1162.     JAM1,
  1163.     FTEXTL, 1,
  1164.     &tanormal,
  1165.     "ParentDir",
  1166.     NULL        /*   next   */
  1167.     };
  1168. struct Gadget    gadgetparentdir=
  1169.     {
  1170.     &gadgetseek,
  1171.     FGADGL+2*FGADGCOL, FGADGT+4*FGADGD, FGADGW, FGADGH,
  1172.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1173.     TOGGLESELECT,
  1174.     BOOLGADGET,
  1175.     (APTR)&nullimage,
  1176.     (APTR)&checkImage,        /*   SelectRender   */
  1177.     &gadgettextparentdir,
  1178.     NULL,
  1179.     NULL,
  1180.     NULL,        /*   ID   */
  1181.     NULL
  1182.     };
  1183.  
  1184. struct    IntuiText    gadgettextcurrentdir=
  1185.     {
  1186.     3, 2,
  1187.     JAM1,
  1188.     FTEXTL, 1,
  1189.     &tanormal,
  1190.     "CurrentDir",
  1191.     NULL        /*   next   */
  1192.     };
  1193. struct Gadget    gadgetcurrentdir=
  1194.     {
  1195.     &gadgetparentdir,
  1196.     FGADGL+2*FGADGCOL, FGADGT+3*FGADGD, FGADGW, FGADGH,
  1197.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1198.     TOGGLESELECT,
  1199.     BOOLGADGET,
  1200.     (APTR)&nullimage,
  1201.     (APTR)&checkImage,        /*   SelectRender   */
  1202.     &gadgettextcurrentdir,
  1203.     NULL,
  1204.     NULL,
  1205.     NULL,        /*   ID   */
  1206.     NULL
  1207.     };
  1208.  
  1209. struct    IntuiText    gadgettextcreatedir=
  1210.     {
  1211.     3, 2,
  1212.     JAM1,
  1213.     FTEXTL, 1,
  1214.     &tanormal,
  1215.     "CreateDir",
  1216.     NULL        /*   next   */
  1217.     };
  1218. struct Gadget    gadgetcreatedir=
  1219.     {
  1220.     &gadgetcurrentdir,
  1221.     FGADGL+2*FGADGCOL, FGADGT+2*FGADGD, FGADGW, FGADGH,
  1222.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1223.     TOGGLESELECT,
  1224.     BOOLGADGET,
  1225.     (APTR)&nullimage,
  1226.     (APTR)&checkImage,        /*   SelectRender   */
  1227.     &gadgettextcreatedir,
  1228.     NULL,
  1229.     NULL,
  1230.     NULL,        /*   ID   */
  1231.     NULL
  1232.     };
  1233.  
  1234. struct    IntuiText    gadgettextrename=
  1235.     {
  1236.     3, 2,
  1237.     JAM1,
  1238.     FTEXTL, 1,
  1239.     &tanormal,
  1240.     "Rename",
  1241.     NULL        /*   next   */
  1242.     };
  1243. struct Gadget    gadgetrename=
  1244.     {
  1245.     &gadgetcreatedir,
  1246.     FGADGL+2*FGADGCOL, FGADGT+1*FGADGD, FGADGW, FGADGH,
  1247.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1248.     TOGGLESELECT,
  1249.     BOOLGADGET,
  1250.     (APTR)&nullimage,
  1251.     (APTR)&checkImage,        /*   SelectRender   */
  1252.     &gadgettextrename,
  1253.     NULL,
  1254.     NULL,
  1255.     NULL,        /*   ID   */
  1256.     NULL
  1257.     };
  1258.  
  1259. struct    IntuiText    gadgettextdeletefile=
  1260.     {
  1261.     3, 2,
  1262.     JAM1,
  1263.     FTEXTL, 1,
  1264.     &tanormal,
  1265.     "DeleteFile",
  1266.     NULL        /*   next   */
  1267.     };
  1268. struct Gadget    gadgetdeletefile=
  1269.     {
  1270.     &gadgetrename,
  1271.     FGADGL+2*FGADGCOL, FGADGT+0*FGADGD, FGADGW, FGADGH,
  1272.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1273.     TOGGLESELECT,
  1274.     BOOLGADGET,
  1275.     (APTR)&nullimage,
  1276.     (APTR)&checkImage,        /*   SelectRender   */
  1277.     &gadgettextdeletefile,
  1278.     NULL,
  1279.     NULL,
  1280.     NULL,        /*   ID   */
  1281.     NULL
  1282.     };
  1283.  
  1284. struct    IntuiText    gadgettextinfo=
  1285.     {
  1286.     3, 2,
  1287.     JAM1,
  1288.     FTEXTL, 1,
  1289.     &tanormal,
  1290.     "Info",
  1291.     NULL        /*   next   */
  1292.     };
  1293. struct Gadget    gadgetinfo=
  1294.     {
  1295.     &gadgetdeletefile,
  1296.     FGADGL+1*FGADGCOL, FGADGT+5*FGADGD, FGADGW, FGADGH,
  1297.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1298.     TOGGLESELECT,
  1299.     BOOLGADGET,
  1300.     (APTR)&nullimage,
  1301.     (APTR)&checkImage,        /*   SelectRender   */
  1302.     &gadgettextinfo,
  1303.     NULL,
  1304.     NULL,
  1305.     NULL,        /*   ID   */
  1306.     NULL
  1307.     };
  1308.  
  1309. struct    IntuiText    gadgettextexnext=
  1310.     {
  1311.     3, 2,
  1312.     JAM1,
  1313.     FTEXTL, 1,
  1314.     &tanormal,
  1315.     "ExNext",
  1316.     NULL        /*   next   */
  1317.     };
  1318. struct Gadget    gadgetexnext=
  1319.     {
  1320.     &gadgetinfo,
  1321.     FGADGL+1*FGADGCOL, FGADGT+4*FGADGD, FGADGW, FGADGH,
  1322.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1323.     TOGGLESELECT,
  1324.     BOOLGADGET,
  1325.     (APTR)&nullimage,
  1326.     (APTR)&checkImage,        /*   SelectRender   */
  1327.     &gadgettextexnext,
  1328.     NULL,
  1329.     NULL,
  1330.     NULL,        /*   ID   */
  1331.     NULL
  1332.     };
  1333.  
  1334. struct    IntuiText    gadgettextexamine=
  1335.     {
  1336.     3, 2,
  1337.     JAM1,
  1338.     FTEXTL, 1,
  1339.     &tanormal,
  1340.     "Examine",
  1341.     NULL        /*   next   */
  1342.     };
  1343. struct Gadget    gadgetexamine=
  1344.     {
  1345.     &gadgetexnext,
  1346.     FGADGL+1*FGADGCOL, FGADGT+3*FGADGD, FGADGW, FGADGH,
  1347.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1348.     TOGGLESELECT,
  1349.     BOOLGADGET,
  1350.     (APTR)&nullimage,
  1351.     (APTR)&checkImage,        /*   SelectRender   */
  1352.     &gadgettextexamine,
  1353.     NULL,
  1354.     NULL,
  1355.     NULL,        /*   ID   */
  1356.     NULL
  1357.     };
  1358.  
  1359. struct    IntuiText    gadgettextduplock=
  1360.     {
  1361.     3, 2,
  1362.     JAM1,
  1363.     FTEXTL, 1,
  1364.     &tanormal,
  1365.     "DupLock",
  1366.     NULL        /*   next   */
  1367.     };
  1368. struct Gadget    gadgetduplock=
  1369.     {
  1370.     &gadgetexamine,
  1371.     FGADGL+1*FGADGCOL, FGADGT+2*FGADGD, FGADGW, FGADGH,
  1372.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1373.     TOGGLESELECT,
  1374.     BOOLGADGET,
  1375.     (APTR)&nullimage,
  1376.     (APTR)&checkImage,        /*   SelectRender   */
  1377.     &gadgettextduplock,
  1378.     NULL,
  1379.     NULL,
  1380.     NULL,        /*   ID   */
  1381.     NULL
  1382.     };
  1383.  
  1384. struct    IntuiText    gadgettextunlock=
  1385.     {
  1386.     3, 2,
  1387.     JAM1,
  1388.     FTEXTL, 1,
  1389.     &tanormal,
  1390.     "UnLock",
  1391.     NULL        /*   next   */
  1392.     };
  1393. struct Gadget    gadgetunlock=
  1394.     {
  1395.     &gadgetduplock,
  1396.     FGADGL+1*FGADGCOL, FGADGT+1*FGADGD, FGADGW, FGADGH,
  1397.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1398.     TOGGLESELECT,
  1399.     BOOLGADGET,
  1400.     (APTR)&nullimage,
  1401.     (APTR)&checkImage,        /*   SelectRender   */
  1402.     &gadgettextunlock,
  1403.     NULL,
  1404.     NULL,
  1405.     NULL,        /*   ID   */
  1406.     NULL
  1407.     };
  1408.  
  1409. struct    IntuiText    gadgettextlock=
  1410.     {
  1411.     3, 2,
  1412.     JAM1,
  1413.     FTEXTL, 1,
  1414.     &tanormal,
  1415.     "Lock",
  1416.     NULL        /*   next   */
  1417.     };
  1418. struct Gadget    gadgetlock=
  1419.     {
  1420.     &gadgetunlock,
  1421.     FGADGL+1*FGADGCOL, FGADGT+0*FGADGD, FGADGW, FGADGH,
  1422.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1423.     TOGGLESELECT,
  1424.     BOOLGADGET,
  1425.     (APTR)&nullimage,
  1426.     (APTR)&checkImage,        /*   SelectRender   */
  1427.     &gadgettextlock,
  1428.     NULL,
  1429.     NULL,
  1430.     NULL,        /*   ID   */
  1431.     NULL
  1432.     };
  1433.  
  1434. struct    IntuiText    gadgettextoutput=
  1435.     {
  1436.     3, 2,
  1437.     JAM1,
  1438.     FTEXTL, 1,
  1439.     &tanormal,
  1440.     "Output",
  1441.     NULL        /*   next   */
  1442.     };
  1443. struct Gadget    gadgetoutput=
  1444.     {
  1445.     &gadgetlock,
  1446.     FGADGL+0*FGADGCOL, FGADGT+5*FGADGD, FGADGW, FGADGH,
  1447.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1448.     TOGGLESELECT,
  1449.     BOOLGADGET,
  1450.     (APTR)&nullimage,
  1451.     (APTR)&checkImage,        /*   SelectRender   */
  1452.     &gadgettextoutput,
  1453.     NULL,
  1454.     NULL,
  1455.     NULL,        /*   ID   */
  1456.     NULL
  1457.     };
  1458.  
  1459. struct    IntuiText    gadgettextinput=
  1460.     {
  1461.     3, 2,
  1462.     JAM1,
  1463.     FTEXTL, 1,
  1464.     &tanormal,
  1465.     "Input",
  1466.     NULL        /*   next   */
  1467.     };
  1468. struct Gadget    gadgetinput=
  1469.     {
  1470.     &gadgetoutput,
  1471.     FGADGL+0*FGADGCOL, FGADGT+4*FGADGD, FGADGW, FGADGH,
  1472.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1473.     TOGGLESELECT,
  1474.     BOOLGADGET,
  1475.     (APTR)&nullimage,
  1476.     (APTR)&checkImage,        /*   SelectRender   */
  1477.     &gadgettextinput,
  1478.     NULL,
  1479.     NULL,
  1480.     NULL,        /*   ID   */
  1481.     NULL
  1482.     };
  1483.  
  1484. struct    IntuiText    gadgettextwrite=
  1485.     {
  1486.     3, 2,
  1487.     JAM1,
  1488.     FTEXTL, 1,
  1489.     &tanormal,
  1490.     "Write",
  1491.     NULL        /*   next   */
  1492.     };
  1493. struct Gadget    gadgetwrite=
  1494.     {
  1495.     &gadgetinput,
  1496.     FGADGL+0*FGADGCOL, FGADGT+3*FGADGD, FGADGW, FGADGH,
  1497.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1498.     TOGGLESELECT,
  1499.     BOOLGADGET,
  1500.     (APTR)&nullimage,
  1501.     (APTR)&checkImage,        /*   SelectRender   */
  1502.     &gadgettextwrite,
  1503.     NULL,
  1504.     NULL,
  1505.     NULL,        /*   ID   */
  1506.     NULL
  1507.     };
  1508.  
  1509. struct    IntuiText    gadgettextread=
  1510.     {
  1511.     3, 2,
  1512.     JAM1,
  1513.     FTEXTL, 1,
  1514.     &tanormal,
  1515.     "Read",
  1516.     NULL        /*   next   */
  1517.     };
  1518. struct Gadget    gadgetread=
  1519.     {
  1520.     &gadgetwrite,
  1521.     FGADGL+0*FGADGCOL, FGADGT+2*FGADGD, FGADGW, FGADGH,
  1522.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1523.     TOGGLESELECT,
  1524.     BOOLGADGET,
  1525.     (APTR)&nullimage,
  1526.     (APTR)&checkImage,        /*   SelectRender   */
  1527.     &gadgettextread,
  1528.     NULL,
  1529.     NULL,
  1530.     NULL,        /*   ID   */
  1531.     NULL
  1532.     };
  1533.  
  1534. struct    IntuiText    gadgettextclose=
  1535.     {
  1536.     3, 2,
  1537.     JAM1,
  1538.     FTEXTL, 1,
  1539.     &tanormal,
  1540.     "Close",
  1541.     NULL        /*   next   */
  1542.     };
  1543. struct Gadget    gadgetclose=
  1544.     {
  1545.     &gadgetread,
  1546.     FGADGL+0*FGADGCOL, FGADGT+1*FGADGD, FGADGW, FGADGH,
  1547.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1548.     TOGGLESELECT,
  1549.     BOOLGADGET,
  1550.     (APTR)&nullimage,
  1551.     (APTR)&checkImage,        /*   SelectRender   */
  1552.     &gadgettextclose,
  1553.     NULL,
  1554.     NULL,
  1555.     NULL,        /*   ID   */
  1556.     NULL
  1557.     };
  1558.  
  1559. struct    IntuiText    gadgettextopen=
  1560.     {
  1561.     3, 2,
  1562.     JAM1,
  1563.     FTEXTL, 1,
  1564.     &tanormal,
  1565.     "Open",
  1566.     NULL        /*   next   */
  1567.     };
  1568. struct Gadget    gadgetopen=
  1569.     {
  1570.     &gadgetclose,
  1571.     FGADGL+0*FGADGCOL, FGADGT+0*FGADGD, FGADGW, FGADGH,
  1572.     GADGHIMAGE | GADGIMAGE | SELECTED,
  1573.     TOGGLESELECT,
  1574.     BOOLGADGET,
  1575.     (APTR)&nullimage,
  1576.     (APTR)&checkImage,        /*   SelectRender   */
  1577.     &gadgettextopen,
  1578.     NULL,
  1579.     NULL,
  1580.     NULL,        /*   ID   */
  1581.     NULL
  1582.     };
  1583.  
  1584. struct    IntuiText    fwindowgadgettext5=
  1585.     {
  1586.     1, 2,
  1587.     JAM1,
  1588.     (FWGW-6*8)/2, FWGTT,
  1589.     &tanormal,
  1590.     "CANCEL",
  1591.     NULL        /*   next   */
  1592.     };
  1593. struct Gadget    fwindowgadget5=
  1594.     {
  1595.     &fgadget,
  1596.     FWGL+4*FWGD, FWGT, FWGW, FWGH,
  1597.     GADGHIMAGE | GADGIMAGE,
  1598.     RELVERIFY,
  1599.     BOOLGADGET,
  1600.     (APTR)&wallhcImage,
  1601.     (APTR)&wallhImage,        /*   SelectRender   */
  1602.     &fwindowgadgettext5,
  1603.     NULL,
  1604.     NULL,
  1605.     FCANCELID,        /*   ID   */
  1606.     NULL
  1607.     };
  1608.  
  1609. struct    IntuiText    fwindowgadgettext4=
  1610.     {
  1611.     1, 2,
  1612.     JAM1,
  1613.     (FWGW-2*8)/2, FWGTT,
  1614.     &tab,
  1615.     "OK",
  1616.     NULL        /*   next   */
  1617.     };
  1618. struct Gadget    fwindowgadget4=
  1619.     {
  1620.     &fwindowgadget5,
  1621.     FWGL, FWGT, FWGW, FWGH,
  1622.     GADGHIMAGE | GADGIMAGE,
  1623.     RELVERIFY,
  1624.     BOOLGADGET,
  1625.     (APTR)&wallhcImage,
  1626.     (APTR)&wallhImage,        /*   SelectRender   */
  1627.     &fwindowgadgettext4,
  1628.     NULL,
  1629.     NULL,
  1630.     FOKID,        /*   ID   */
  1631.     NULL
  1632.     };
  1633.  
  1634. struct    IntuiText    fwindowgadgettext3=
  1635.     {
  1636.     1, 2,
  1637.     JAM1,
  1638.     (FWGW-3*8)/2, FWGTT,
  1639.     &tanormal,
  1640.     "ALL",
  1641.     NULL        /*   next   */
  1642.     };
  1643. struct Gadget    fwindowgadget3=
  1644.     {
  1645.     &fwindowgadget4,
  1646.     FWGL+FWGD, FWGT, FWGW, FWGH,
  1647.     GADGHIMAGE | GADGIMAGE,
  1648.     RELVERIFY,
  1649.     BOOLGADGET,
  1650.     (APTR)&wallhcImage,
  1651.     (APTR)&wallhImage,        /*   SelectRender   */
  1652.     &fwindowgadgettext3,
  1653.     NULL,
  1654.     NULL,
  1655.     FALLID,        /*   ID   */
  1656.     NULL
  1657.     };
  1658.  
  1659. struct    IntuiText    fwindowgadgettext2=
  1660.     {
  1661.     1, 2,
  1662.     JAM1,
  1663.     (FWGW-4*8)/2, FWGTT,
  1664.     &tanormal,
  1665.     "NONE",
  1666.     NULL        /*   next   */
  1667.     };
  1668. struct Gadget    fwindowgadget2=
  1669.     {
  1670.     &fwindowgadget3,
  1671.     FWGL+2*FWGD, FWGT, FWGW, FWGH,
  1672.     GADGHIMAGE | GADGIMAGE,
  1673.     RELVERIFY,
  1674.     BOOLGADGET,
  1675.     (APTR)&wallhcImage,
  1676.     (APTR)&wallhImage,        /*   SelectRender   */
  1677.     &fwindowgadgettext2,
  1678.     NULL,
  1679.     NULL,
  1680.     FNONEID,        /*   ID   */
  1681.     NULL
  1682.     };
  1683.  
  1684. struct    IntuiText    fwindowgadgettext1=
  1685.     {
  1686.     1, 2,
  1687.     JAM1,
  1688.     (FWGW-7*8)/2, FWGTT,
  1689.     &tanormal,
  1690.     "RESTORE",
  1691.     NULL        /*   next   */
  1692.     };
  1693. struct Gadget    fwindowgadget=
  1694.     {
  1695.     &fwindowgadget2,
  1696.     FWGL+3*FWGD, FWGT, FWGW, FWGH,
  1697.     GADGHIMAGE | GADGIMAGE,
  1698.     RELVERIFY,
  1699.     BOOLGADGET,
  1700.     (APTR)&wallhcImage,
  1701.     (APTR)&wallhImage,        /*   SelectRender   */
  1702.     &fwindowgadgettext1,
  1703.     NULL,
  1704.     NULL,
  1705.     FRESTOREID,        /*   ID   */
  1706.     NULL
  1707.     };
  1708.  
  1709.  
  1710. struct    IntuiText    cwindowcancelgadgettext=
  1711.     {
  1712.     1, 2,
  1713.     JAM1,
  1714.     (CWGW-6*8)/2, CWGTT,
  1715.     &tanormal,
  1716.     "CANCEL",        /*   Verra` messo poi   */
  1717.     NULL        /*   next   */
  1718.     };
  1719. struct Gadget    cwindowcancelgadget=
  1720.     {
  1721.     NULL,
  1722.     CWGL+CWGD, CWGT, CWGW, CWGH,
  1723.     GADGHIMAGE | GADGIMAGE,
  1724.     RELVERIFY,
  1725.     BOOLGADGET,
  1726.     (APTR)&wallhcImage,
  1727.     (APTR)&wallhImage,        /*   SelectRender   */
  1728.     &cwindowcancelgadgettext,
  1729.     NULL,
  1730.     NULL,
  1731.     CCANCELID,        /*   ID   */
  1732.     NULL
  1733.     };
  1734.  
  1735. struct    IntuiText    cwindowokgadgettext=
  1736.     {
  1737.     1, 2,
  1738.     JAM1,
  1739.     (CWGW-4*8)/2, CWGTT,
  1740.     &tab,
  1741.     NULL,        /*   Verra` messo poi   */
  1742.     NULL        /*   next   */
  1743.     };
  1744. struct Gadget    cwindowokgadget=
  1745.     {
  1746.     &cwindowcancelgadget,
  1747.     CWGL, CWGT, CWGW, CWGH,
  1748.     GADGHIMAGE | GADGIMAGE,
  1749.     RELVERIFY,
  1750.     BOOLGADGET,
  1751.     (APTR)&wallhcImage,
  1752.     (APTR)&wallhImage,        /*   SelectRender   */
  1753.     &cwindowokgadgettext,
  1754.     NULL,
  1755.     NULL,
  1756.     COKID,        /*   ID   */
  1757.     NULL
  1758.     };
  1759.  
  1760. UBYTE    gconfigname[ CSTRLEN ];
  1761. struct    StringInfo    cwindowgadgetstrinfo=
  1762.     {
  1763.     gconfigname,
  1764.     NULL,
  1765.     0,
  1766.     CSTRLEN,
  1767.     0
  1768.     };
  1769. struct    Gadget    cwindowgadget=
  1770.     {
  1771.     &cwindowokgadget,        /*   Next   */
  1772.     (CWINDW-8*CGSTRLEN)/2, 30,
  1773.     8*CGSTRLEN, 8,
  1774.     GADGHCOMP,
  1775.     RELVERIFY | STRINGCENTER,
  1776.     STRGADGET,
  1777.     NULL,
  1778.     NULL,
  1779.     NULL,        /*   Text   */
  1780.     NULL,
  1781.     (APTR)&cwindowgadgetstrinfo,
  1782.     COKID,        /*   ID   */
  1783.     NULL
  1784.     };
  1785.  
  1786.  
  1787.  
  1788. struct    IntuiText    itemtextflashoff=
  1789.     {
  1790.     3, 2,
  1791.     JAM1,
  1792.     ITEML+CHECKWIDTH, ITEMTEXTT,
  1793.     &tanormal,
  1794.     "Deactivated",
  1795.     NULL        /*   next   */
  1796.     };
  1797. struct    MenuItem    itemflashoff=
  1798.     {
  1799.     NULL,        /*   next   */
  1800.     0, 11*ITEMD+5*3,
  1801.     ITEM1W, ITEMH,
  1802.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  1803.     0x40,        /*   mutualexclude   */
  1804.     (APTR)&itemtextflashoff,
  1805.     NULL,
  1806.     NULL,        /*   command   */
  1807.     NULL,        /*   subitem   */
  1808.     NULL
  1809.     };
  1810. struct    IntuiText    itemtextflashonb=
  1811.     {
  1812.     1, 2,
  1813.     JAM1,
  1814.     ITEML, ITEMTEXTT-ITEMD,
  1815.     &taiu,
  1816.     "  ScreenFlash ",
  1817.     NULL        /*   next   */
  1818.     };
  1819. struct    IntuiText    itemtextflashon=
  1820.     {
  1821.     3, 2,
  1822.     JAM1,
  1823.     ITEML+CHECKWIDTH, ITEMTEXTT,
  1824.     &tanormal,
  1825.     "Activated",
  1826.     &itemtextflashonb        /*   next   */
  1827.     };
  1828. struct    MenuItem    itemflashon=
  1829.     {
  1830.     &itemflashoff,        /*   next   */
  1831.     0, 10*ITEMD+5*3,
  1832.     ITEM1W, ITEMH,
  1833.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | CHECKED,
  1834.     0x80,        /*   mutualexclude   */
  1835.     (APTR)&itemtextflashon,
  1836.     NULL,
  1837.     NULL,        /*   command   */
  1838.     NULL,        /*   subitem   */
  1839.     NULL
  1840.     };
  1841. struct    IntuiText    itemtextimmediately=
  1842.     {
  1843.     3, 2,
  1844.     JAM1,
  1845.     ITEML+CHECKWIDTH, ITEMTEXTT,
  1846.     &tanormal,
  1847.     "Immediately",
  1848.     NULL        /*   next   */
  1849.     };
  1850. struct    MenuItem    itemimmediately=
  1851.     {
  1852.     &itemflashon,        /*   next   */
  1853.     0, 8*ITEMD+5*2,
  1854.     ITEM1W, ITEMH,
  1855.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  1856.     0x10,        /*   mutualexclude   */
  1857.     (APTR)&itemtextimmediately,
  1858.     NULL,
  1859.     NULL,        /*   command   */
  1860.     NULL,        /*   subitem   */
  1861.     NULL
  1862.     };
  1863. struct    IntuiText    itemtextwaitforgob=
  1864.     {
  1865.     1, 2,
  1866.     JAM1,
  1867.     ITEML, ITEMTEXTT-ITEMD,
  1868.     &taiu,
  1869.     "     Go on    ",
  1870.     NULL        /*   next   */
  1871.     };
  1872. struct    IntuiText    itemtextwaitforgo=
  1873.     {
  1874.     3, 2,
  1875.     JAM1,
  1876.     ITEML+CHECKWIDTH, ITEMTEXTT,
  1877.     &tanormal,
  1878.     "Wait for GO",
  1879.     &itemtextwaitforgob        /*   next   */
  1880.     };
  1881. struct    MenuItem    itemwaitforgo=
  1882.     {
  1883.     &itemimmediately,        /*   next   */
  1884.     0, 7*ITEMD+5*2,
  1885.     ITEM1W, ITEMH,
  1886.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | CHECKED,
  1887.     0x20,        /*   mutualexclude   */
  1888.     (APTR)&itemtextwaitforgo,
  1889.     NULL,
  1890.     NULL,        /*   command   */
  1891.     NULL,        /*   subitem   */
  1892.     NULL
  1893.     };
  1894. struct    IntuiText    itemtextfailedonly=
  1895.     {
  1896.     3, 2,
  1897.     JAM1,
  1898.     ITEML+CHECKWIDTH, ITEMTEXTT,
  1899.     &tanormal,
  1900.     "Failed only",
  1901.     NULL        /*   next   */
  1902.     };
  1903. struct    MenuItem    itemfailedonly=
  1904.     {
  1905.     &itemwaitforgo,        /*   next   */
  1906.     0, 5*ITEMD+5,
  1907.     ITEM1W, ITEMH,
  1908.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  1909.     0x4,        /*   mutualexclude   */
  1910.     (APTR)&itemtextfailedonly,
  1911.     NULL,
  1912.     NULL,        /*   command   */
  1913.     NULL,        /*   subitem   */
  1914.     NULL
  1915.     };
  1916. struct    IntuiText    itemtexteverytimeb=
  1917.     {
  1918.     1, 2,
  1919.     JAM1,
  1920.     ITEML, ITEMTEXTT-ITEMD,
  1921.     &taiu,
  1922.     "  Activation  ",
  1923.     NULL        /*   next   */
  1924.     };
  1925. struct    IntuiText    itemtexteverytime=
  1926.     {
  1927.     3, 2,
  1928.     JAM1,
  1929.     ITEML+CHECKWIDTH, ITEMTEXTT,
  1930.     &tanormal,
  1931.     "Every time",
  1932.     &itemtexteverytimeb        /*   next   */
  1933.     };
  1934. struct    MenuItem    itemeverytime=
  1935.     {
  1936.     &itemfailedonly,        /*   next   */
  1937.     0, 4*ITEMD+5,
  1938.     ITEM1W, ITEMH,
  1939.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | CHECKED,
  1940.     0x8,        /*   mutualexclude   */
  1941.     (APTR)&itemtexteverytime,
  1942.     NULL,
  1943.     NULL,        /*   command   */
  1944.     NULL,        /*   subitem   */
  1945.     NULL
  1946.     };
  1947. struct    IntuiText    itemtextbrief=
  1948.     {
  1949.     3, 2,
  1950.     JAM1,
  1951.     ITEML+CHECKWIDTH, ITEMTEXTT,
  1952.     &tanormal,
  1953.     "Brief",
  1954.     NULL        /*   next   */
  1955.     };
  1956. struct    MenuItem    itembrief=
  1957.     {
  1958.     &itemeverytime,        /*   next   */
  1959.     0, 2*ITEMD,
  1960.     ITEM1W, ITEMH,
  1961.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  1962.     0x1,        /*   mutualexclude   */
  1963.     (APTR)&itemtextbrief,
  1964.     NULL,
  1965.     NULL,        /*   command   */
  1966.     NULL,        /*   subitem   */
  1967.     NULL
  1968.     };
  1969. struct    IntuiText    itemtextverboseb=
  1970.     {
  1971.     1, 2,
  1972.     JAM1,
  1973.     ITEML, ITEMTEXTT-ITEMD,
  1974.     &taiu,
  1975.     "  Description ",
  1976.     NULL        /*   next   */
  1977.     };
  1978. struct    IntuiText    itemtextverbose=
  1979.     {
  1980.     3, 2,
  1981.     JAM1,
  1982.     ITEML+CHECKWIDTH, ITEMTEXTT,
  1983.     &tanormal,
  1984.     "Verbose",
  1985.     &itemtextverboseb        /*   next   */
  1986.     };
  1987. struct    MenuItem    itemverbose=
  1988.     {
  1989.     &itembrief,        /*   next   */
  1990.     0, ITEMD,
  1991.     ITEM1W, ITEMH,
  1992.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | CHECKED,
  1993.     0x2,        /*   mutualexclude   */
  1994.     (APTR)&itemtextverbose,
  1995.     NULL,
  1996.     NULL,        /*   command   */
  1997.     NULL,        /*   subitem   */
  1998.     NULL
  1999.     };
  2000. struct    Menu    menu1=
  2001.     {
  2002.     NULL,        /*   next   */
  2003.     100, 0,
  2004.     14*8, 10,
  2005.     MENUENABLED,
  2006.     " Preferences",
  2007.     &itemverbose
  2008.     };
  2009.  
  2010.  
  2011. struct    IntuiText    itemtext05=
  2012.     {
  2013.     3, 2,
  2014.     JAM1,
  2015.     ITEML, ITEMTEXTT,
  2016.     &tanormal,
  2017.     "Quit",
  2018.     NULL        /*   next   */
  2019.     };
  2020. struct    MenuItem    item05=
  2021.     {
  2022.     NULL,        /*   next   */
  2023.     0, 7*ITEMD,
  2024.     ITEM0W, ITEMH,
  2025.     ITEMTEXT | ITEMENABLED | HIGHCOMP,
  2026.     NULL,        /*   mutualexclude   */
  2027.     (APTR)&itemtext05,
  2028.     NULL,
  2029.     NULL,        /*   command   */
  2030.     NULL,        /*   subitem   */
  2031.     NULL
  2032.     };
  2033.  
  2034. struct    IntuiText    subitemtext0addre=
  2035.     {
  2036.     3, 2,
  2037.     JAM1,
  2038.     (INFOW-38*8)/2, INFOADDRT+3*INFOTEXTD,
  2039.     &tanormal,
  2040.     "Viale Francia 4, 90146 Palermo, Italy.",
  2041.     NULL        /*   next   */
  2042.     };
  2043. struct    IntuiText    subitemtext0addrd=
  2044.     {
  2045.     3, 2,
  2046.     JAM1,
  2047.     (INFOW-20*8)/2+3*8, INFOADDRT+2*INFOTEXTD,
  2048.     &tai,
  2049.     "Federico Giannici",
  2050.     &subitemtext0addre        /*   next   */
  2051.     };
  2052. struct    IntuiText    subitemtext0addrc=
  2053.     {
  2054.     3, 2,
  2055.     JAM1,
  2056.     (INFOW-20*8)/2, INFOADDRT+2*INFOTEXTD,
  2057.     &tanormal,
  2058.     "by",
  2059.     &subitemtext0addrd        /*   next   */
  2060.     };
  2061. struct    IntuiText    subitemtext04addrb=
  2062.     {
  2063.     3, 2,
  2064.     JAM1,
  2065.     (INFOW-23*8)/2, INFOADDRT+1*INFOTEXTD,
  2066.     &tanormal,
  2067.     "Concept, Code & Graphic",
  2068.     &subitemtext0addrc        /*   next   */
  2069.     };
  2070. struct    IntuiText    subitemtext04addra=
  2071.     {
  2072.     3, 2,
  2073.     JAM1,
  2074.     0, INFOADDRT-4,
  2075.     &tab,
  2076.     "________________________________________",
  2077.     &subitemtext04addrb        /*   next   */
  2078.     };
  2079. struct    IntuiText    subitemtext04c=
  2080.     {
  2081.     3, 2,
  2082.     JAM1,
  2083.     (INFOW-33*8)/2, INFOTEXTT+1*INFOTEXTD,
  2084.     &tanormal,
  2085.     "but you CANNOT modify or sell it!",
  2086.     &subitemtext04addra        /*   next   */
  2087.     };
  2088. struct    IntuiText    subitemtext04b=
  2089.     {
  2090.     3, 2,
  2091.     JAM1,
  2092.     (INFOW-32*8)/2, INFOTEXTT+0*INFOTEXTD,
  2093.     &tanormal,
  2094.     "This is a Public Domain program,",
  2095.     &subitemtext04c        /*   next   */
  2096.     };
  2097. struct    IntuiText    subitemtext04=
  2098.     {
  2099.     3, 2,
  2100.     JAM1,
  2101.     (INFOW-5*8)/2, LOGOH+INFOLOGOT+5-INFOT,
  2102.     &tanormal,
  2103.     "V "VERSIONE,
  2104.     &subitemtext04b        /*   next   */
  2105.     };
  2106. struct    MenuItem    subitem04c=        /*   Per il LOGO   */
  2107.     {
  2108.     NULL,        /*   next   */
  2109.     (INFOW-LOGOW)/2, INFOLOGOT,
  2110.     0, 0,
  2111.     HIGHNONE,
  2112.     NULL,        /*   mutualexclude   */
  2113.     (APTR)&logoImage,
  2114.     NULL,
  2115.     NULL,        /*   command   */
  2116.     NULL,        /*   subitem   */
  2117.     NULL
  2118.     };
  2119. struct    MenuItem    subitem04b=        /*   Per la dimensione   */
  2120.     {
  2121.     &subitem04c,        /*   next   */
  2122.     INFOW, INFOMAXH,
  2123.     0, 0,
  2124.     HIGHNONE,
  2125.     NULL,        /*   mutualexclude   */
  2126.     NULL,
  2127.     NULL,
  2128.     NULL,        /*   command   */
  2129.     NULL,        /*   subitem   */
  2130.     NULL
  2131.     };
  2132. struct    MenuItem    subitem04=
  2133.     {
  2134.     &subitem04b,        /*   next   */
  2135.     0, INFOT,
  2136.     0, 0,
  2137.     ITEMTEXT | HIGHNONE,
  2138.     NULL,        /*   mutualexclude   */
  2139.     (APTR)&subitemtext04,
  2140.     NULL,
  2141.     NULL,        /*   command   */
  2142.     NULL,        /*   subitem   */
  2143.     NULL
  2144.     };
  2145. struct    IntuiText    itemtext04=
  2146.     {
  2147.     3, 2,
  2148.     JAM1,
  2149.     ITEML, ITEMTEXTT,
  2150.     &tanormal,
  2151.     "Informations",
  2152.     NULL        /*   next   */
  2153.     };
  2154. struct    MenuItem    item04=
  2155.     {
  2156.     &item05,        /*   next   */
  2157.     0, 6*ITEMD,
  2158.     ITEM0W, ITEMH,
  2159.     ITEMTEXT | ITEMENABLED | HIGHCOMP,
  2160.     NULL,        /*   mutualexclude   */
  2161.     (APTR)&itemtext04,
  2162.     NULL,
  2163.     NULL,        /*   command   */
  2164.     &subitem04,        /*   subitem   */
  2165.     NULL
  2166.     };
  2167. struct    IntuiText    itemtext03b=
  2168.     {
  2169.     3, 2,
  2170.     JAM1,
  2171.     ITEML, ITEMTEXTT,
  2172.     &tanormal,
  2173.     "Clear FileHandle mem",
  2174.     NULL        /*   next   */
  2175.     };
  2176. struct    MenuItem    item03b=
  2177.     {
  2178.     &item04,        /*   next   */
  2179.     0, 5*ITEMD,
  2180.     ITEM0W, ITEMH,
  2181.     ITEMTEXT | ITEMENABLED | HIGHCOMP,
  2182.     NULL,        /*   mutualexclude   */
  2183.     (APTR)&itemtext03b,
  2184.     NULL,
  2185.     NULL,        /*   command   */
  2186.     NULL,        /*   subitem   */
  2187.     NULL
  2188.     };
  2189. struct    IntuiText    itemtext03=
  2190.     {
  2191.     3, 2,
  2192.     JAM1,
  2193.     ITEML, ITEMTEXTT,
  2194.     &tanormal,
  2195.     "Load configuration",
  2196.     NULL        /*   next   */
  2197.     };
  2198. struct    MenuItem    item03=
  2199.     {
  2200.     &item03b,        /*   next   */
  2201.     0, 4*ITEMD,
  2202.     ITEM0W, ITEMH,
  2203.     ITEMTEXT | ITEMENABLED | HIGHCOMP,
  2204.     NULL,        /*   mutualexclude   */
  2205.     (APTR)&itemtext03,
  2206.     NULL,
  2207.     NULL,        /*   command   */
  2208.     NULL,        /*   subitem   */
  2209.     NULL
  2210.     };
  2211. struct    IntuiText    itemtext02=
  2212.     {
  2213.     3, 2,
  2214.     JAM1,
  2215.     ITEML, ITEMTEXTT,
  2216.     &tanormal,
  2217.     "Save configuration",
  2218.     NULL        /*   next   */
  2219.     };
  2220. struct    MenuItem    item02=
  2221.     {
  2222.     &item03,        /*   next   */
  2223.     0, 3*ITEMD,
  2224.     ITEM0W, ITEMH,
  2225.     ITEMTEXT | ITEMENABLED | HIGHCOMP,
  2226.     NULL,        /*   mutualexclude   */
  2227.     (APTR)&itemtext02,
  2228.     NULL,
  2229.     NULL,        /*   command   */
  2230.     NULL,        /*   subitem   */
  2231.     NULL
  2232.     };
  2233. struct    IntuiText    itemtext01=
  2234.     {
  2235.     3, 2,
  2236.     JAM1,
  2237.     ITEML, ITEMTEXTT,
  2238.     &tanormal,
  2239.     "Functions",
  2240.     NULL        /*   next   */
  2241.     };
  2242. struct    MenuItem    item01=
  2243.     {
  2244.     &item02,        /*   next   */
  2245.     0, 2*ITEMD,
  2246.     ITEM0W, ITEMH,
  2247.     ITEMTEXT | ITEMENABLED | HIGHCOMP,
  2248.     NULL,        /*   mutualexclude   */
  2249.     (APTR)&itemtext01,
  2250.     NULL,
  2251.     NULL,        /*   command   */
  2252.     NULL,        /*   subitem   */
  2253.     NULL
  2254.     };
  2255. struct    IntuiText    itemtext00b=
  2256.     {
  2257.     3, 2,
  2258.     JAM1,
  2259.     ITEML+CHECKWIDTH, ITEMTEXTT,
  2260.     &tanormal,
  2261.     "Printer",
  2262.     NULL        /*   next   */
  2263.     };
  2264. struct    MenuItem    item00b=
  2265.     {
  2266.     &item01,        /*   next   */
  2267.     0, ITEMD,
  2268.     ITEM0W, ITEMH,
  2269.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | MENUTOGGLE | COMMSEQ,
  2270.     NULL,        /*   mutualexclude   */
  2271.     (APTR)&itemtext00b,
  2272.     NULL,
  2273.     'P',        /*   command   */
  2274.     NULL,        /*   subitem   */
  2275.     NULL
  2276.     };
  2277. struct    IntuiText    itemtext00=
  2278.     {
  2279.     3, 2,
  2280.     JAM1,
  2281.     ITEML+CHECKWIDTH, ITEMTEXTT,
  2282.     &tanormal,
  2283.     "Activated",
  2284.     NULL        /*   next   */
  2285.     };
  2286. struct    MenuItem    item00=
  2287.     {
  2288.     &item00b,        /*   next   */
  2289.     0, 0,
  2290.     ITEM0W, ITEMH,
  2291.     ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | CHECKED | MENUTOGGLE | COMMSEQ,
  2292.     NULL,        /*   mutualexclude   */
  2293.     (APTR)&itemtext00,
  2294.     NULL,
  2295.     'A',        /*   command   */
  2296.     NULL,        /*   subitem   */
  2297.     NULL
  2298.     };
  2299. struct    Menu    menu0=
  2300.     {
  2301.     &menu1,        /*   next   */
  2302.     0, 0,
  2303.     10*8, 10,
  2304.     MENUENABLED,
  2305.     " General",
  2306.     &item00
  2307.     };
  2308.  
  2309.  
  2310. struct    IntuiText    gadgetgoontext=
  2311.     {
  2312.     3, 2,
  2313.     JAM1,
  2314.     6, 1,
  2315.     &tab,
  2316.     "Click here or press a key to GO ON",
  2317.     NULL        /*   next   */
  2318.     };
  2319. struct Gadget    gadgetgoon=
  2320.     {
  2321.     NULL,
  2322.     4, -9, -20-2, 9,
  2323.     GADGHCOMP | GRELBOTTOM | GRELWIDTH | GADGDISABLED,
  2324.     RELVERIFY | BOTTOMBORDER,
  2325.     BOOLGADGET | GZZGADGET,
  2326.     NULL,
  2327.     NULL,
  2328.     &gadgetgoontext,
  2329.     NULL,
  2330.     NULL,
  2331.     1,        /*   ID   */
  2332.     NULL
  2333.     };
  2334.  
  2335.  
  2336. struct  NewWindow windowdata=
  2337.     {
  2338.     WINDL, WINDT, WINDW, WINDH,
  2339.     3, 2,
  2340.     CLOSEWINDOW | REFRESHWINDOW | GADGETUP | VANILLAKEY | MENUPICK | MOUSEBUTTONS,
  2341.     WINDOWDRAG | WINDOWDEPTH | WINDOWCLOSE | WINDOWSIZING
  2342.         | SIZEBBOTTOM | SMART_REFRESH | ACTIVATE | GIMMEZEROZERO,
  2343.     &gadgetgoon,     /* Gadget */
  2344.     &checkImage,
  2345.     "SPY  v"VERSIONE"    by Federico Giannici",
  2346.     NULL,
  2347.     NULL,
  2348.     LOGOW+10, LOGOH+22, 10000, 10000,
  2349.     WBENCHSCREEN,
  2350.     };
  2351.  
  2352. struct  NewWindow fwindowdata=
  2353.     {
  2354.     0, 0, FWINDW, FWINDH,
  2355.     3, 2,
  2356.     GADGETUP,
  2357.     WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | ACTIVATE | RMBTRAP,
  2358.     NULL,     /* Gadget */
  2359.     NULL,
  2360.     "Activated functions of SPY",
  2361.     NULL,
  2362.     NULL,
  2363.     0, 0, 0, 0,
  2364.     WBENCHSCREEN,
  2365.     };
  2366.  
  2367. struct  NewWindow cwindowdata=
  2368.     {
  2369.     0, 0, CWINDW, CWINDH,
  2370.     3, 2,
  2371.     GADGETUP,
  2372.     WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | ACTIVATE | RMBTRAP,
  2373.     NULL,     /* Gadget */
  2374.     NULL,
  2375.     "Name of the Configuration file",
  2376.     NULL,
  2377.     NULL,
  2378.     0, 0, 0, 0,
  2379.     WBENCHSCREEN,
  2380.     };
  2381.  
  2382.  
  2383. struct    SPYMsg
  2384.     {
  2385.     struct    Message    msg;
  2386.     ULONG    data;
  2387.     };
  2388.  
  2389. struct    MsgPort    goport=
  2390.     {
  2391.     { NULL, NULL, NT_MSGPORT, NULL, "SPY port for GO ON" },        /*   node   */
  2392.     PA_SIGNAL,
  2393.     NULL,        /*   mettere poi   */
  2394.     NULL,        /*   mettere poi   */
  2395.     { (struct Node *)(&(goport.mp_MsgList.lh_Tail)), NULL, (struct Node *)(&(goport.mp_MsgList.lh_Head)) }
  2396.     };
  2397.  
  2398. struct    Message    gomsg=
  2399.     {
  2400.     { NULL },        /*   node   */
  2401.     &goport
  2402.     };
  2403.  
  2404. struct    MsgPort    prtport=
  2405.     {
  2406.     { NULL, NULL, NT_MSGPORT, NULL, "SPY port for printing" },        /*   node   */
  2407.     PA_SIGNAL,
  2408.     NULL,        /*   mettere poi   */
  2409.     NULL,        /*   mettere poi   */
  2410.     { (struct Node *)(&(prtport.mp_MsgList.lh_Tail)), NULL, (struct Node *)(&(prtport.mp_MsgList.lh_Head)) }
  2411.     };
  2412. struct    SPYMsg    prtmsg=
  2413.     {
  2414.     {        /*   Message   */
  2415.     { NULL },        /*   node   */
  2416.     &prtport
  2417.     },
  2418.     NULL
  2419.     };
  2420.  
  2421. struct    MsgPort    lockport=
  2422.     {
  2423.     { NULL, NULL, NT_MSGPORT, NULL, "SPY port for lock" },        /*   node   */
  2424.     PA_SIGNAL,
  2425.     NULL,        /*   mettere poi   */
  2426.     NULL,        /*   mettere poi   */
  2427.     { (struct Node *)(&(lockport.mp_MsgList.lh_Tail)), NULL, (struct Node *)(&(lockport.mp_MsgList.lh_Head)) }
  2428.     };
  2429. struct    SPYMsg    lockmsg=
  2430.     {
  2431.     {        /*   Message   */
  2432.     { NULL },        /*   node   */
  2433.     &lockport
  2434.     },
  2435.     NULL
  2436.     };
  2437.  
  2438. struct    timerequest    tmflash=        /*   Per il flash   */
  2439.     {
  2440.     {        /*   IORequest   */
  2441.     { NULL },        /*   message   */
  2442.     NULL,
  2443.     NULL,
  2444.     TR_ADDREQUEST        /*   io_Command   */
  2445.     }
  2446.     };
  2447.  
  2448. struct    timerequest    tmquit=        /*   Per il Quit   */
  2449.     {
  2450.     {        /*   IORequest   */
  2451.     { NULL },        /*   message   */
  2452.     NULL,
  2453.     NULL,
  2454.     TR_ADDREQUEST        /*   io_Command   */
  2455.     }
  2456.     };
  2457.  
  2458. struct    timerequest    tmconfig=        /*   Per il Load Config   */
  2459.     {
  2460.     {        /*   IORequest   */
  2461.     { NULL },        /*   message   */
  2462.     NULL,
  2463.     NULL,
  2464.     TR_ADDREQUEST        /*   io_Command   */
  2465.     }
  2466.     };
  2467.  
  2468.  
  2469. struct    MinList    fhlist=
  2470.     {
  2471.     (struct MinNode *)&(fhlist.mlh_Tail),
  2472.     NULL,
  2473.     (struct MinNode *)&(fhlist.mlh_Head),
  2474.     };
  2475. struct    fhnode
  2476.     {
  2477.     struct    MinNode    node;
  2478.     BPTR    fh;
  2479.     UBYTE    name[FHNAMELEN+1];
  2480.     };
  2481.  
  2482.  
  2483.  
  2484. /*****   Questi sono necessari per CBack.o   *****/
  2485. long     _stack = 4000;             /* a reasonable amount of stack space */
  2486. char     *_procname = "SPY   by FG";
  2487. long     _priority = SPYPRIORITY;
  2488. long     _BackGroundIO = 1;         /* perform background I/O */
  2489. extern     BPTR     _Backstdout;       /* file handle we will write to with */
  2490.  
  2491.  
  2492. UBYTE    errtext[ERRORTEXTLEN]="\n\nSPY Error: ";
  2493.  
  2494. UBYTE    helptext[]="\nSPY  V"VERSIONE" by Federico Giannici \n"
  2495.                    "\n"
  2496.                    "Usage: SPY [config.file]\n\n";
  2497.  
  2498. UBYTE    *paramtext[]=
  2499.     {
  2500.     "Verbose",
  2501.     "Brief",
  2502.     "Every time",
  2503.     "Failed only",
  2504.     "Wait for GO",
  2505.     "Return immediately",
  2506.     "ScreenFlash Activated",
  2507.     "ScreenFlash Deactivated",
  2508.     };
  2509.  
  2510.  
  2511. UWORD    vectoffset[ VECTNUM ]=
  2512.     {
  2513.     0x1e,        /*   Open   */
  2514.     0x24,        /*   Close   */
  2515.     0x2a,        /*   Read   */
  2516.     0x30,        /*   Write   */
  2517.     0x36,        /*   Input   */
  2518.     0x3c,        /*   Output   */
  2519.     0x54,        /*   Lock   */
  2520.     0x5a,        /*   UnLock   */
  2521.     0x60,        /*   DupLock   */
  2522.     0x66,        /*   Examine   */
  2523.     0x6c,        /*   ExNext   */
  2524.     0x72,        /*   Info   */
  2525.     0x48,        /*   DeleteFile   */
  2526.     0x4e,        /*   Rename   */
  2527.     0x78,        /*   CreateDir   */
  2528.     0x7e,        /*   CurrentDir   */
  2529.     0xd2,        /*   ParentDir   */
  2530.     0x42,        /*   Seek   */
  2531.     0xde,        /*   Execute   */
  2532.     0x96,        /*   LoadSeg   */
  2533.     0x9c,        /*   UnLoadSeg   */
  2534.     0x8a,        /*   CreateProc   */
  2535.     0x90,        /*   Exit   */
  2536.     0x84,        /*   IoErr   */
  2537.         /*   Funzioni EXEC   */
  2538.     0xc6,        /*   AllocMem   */
  2539.     0x1bc,        /*   OpenDevice   */
  2540.     0x1c2,        /*   CloseDevice   */
  2541.     0x1b0,        /*   AddDevice   */
  2542.     0x228,        /*   OpenLibrary   */
  2543.     0x198,        /*   OldOpenLibrary   */
  2544.     0x19e,        /*   CloseLibrary   */
  2545.     0x18c,        /*   AddLibrary   */
  2546.     0x1f2,        /*   OpenResource   */
  2547.     0x1e6,        /*   AddResource   */
  2548.     0x186,        /*   FindPort   */
  2549.     0x162,        /*   AddPort   */
  2550.     0x252,        /*   FindSemaphore   */
  2551.     0x258,        /*   AddSemaphore   */
  2552.     0x114        /*   FindName   */
  2553.     };
  2554.  
  2555. struct    vect
  2556.     {
  2557.     UWORD vect1;
  2558.     ULONG vect2;
  2559.     };
  2560.  
  2561. struct    vect    newvect[ VECTNUM ]=
  2562.     {
  2563.         /*   Funzioni DOS   */
  2564.     {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},
  2565.     {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},
  2566.     {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},
  2567.     {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},
  2568.         /*   Funzioni EXEC   */
  2569.     {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},
  2570.     {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},
  2571.     {JMPCODE},    {JMPCODE},    {JMPCODE},    {JMPCODE},
  2572.     {JMPCODE},    {JMPCODE},    {JMPCODE},
  2573.     };
  2574.  
  2575. struct    vect    oldvect[ VECTNUM ];
  2576.  
  2577. BOOL    selectedfun[ VECTNUM ]=        /*   Nuove funzioni attualmente attive   */
  2578.     {
  2579.     TRUE,    TRUE,    TRUE,    TRUE,    TRUE,    TRUE,
  2580.     TRUE,    TRUE,    TRUE,    TRUE,    TRUE,    TRUE,
  2581.     TRUE,    TRUE,    TRUE,    TRUE,    TRUE,    TRUE,
  2582.     TRUE,    TRUE,    TRUE,    TRUE,    TRUE,    TRUE,
  2583.         /*   Funzioni EXEC   */
  2584.     TRUE,    TRUE,    TRUE,    TRUE,
  2585.     TRUE,    TRUE,    TRUE,    TRUE,
  2586.     TRUE,    TRUE,    TRUE,    TRUE,
  2587.     TRUE,    TRUE,    FALSE,
  2588.     };
  2589.  
  2590. extern    UBYTE    *SysBase;
  2591. struct    IntuitionBase    *IntuitionBase=NULL;
  2592. struct    GfxBase        *GfxBase=NULL;
  2593. struct    Window        *window=NULL;
  2594. struct    RastPort    *rp;
  2595.  
  2596. struct    IntuiMessage    *msg;
  2597. ULONG    class;
  2598. UWORD    code;
  2599. ULONG    seconds, micros, lastseconds, lastmicros;
  2600.  
  2601. UBYTE    configname[ CSTRLEN ]="spy.config";        /*   Nome del config.file   */
  2602. BPTR    configfile=NULL;        /*   File-Handle del file di configurazione   */
  2603. UBYTE    configid[4]={ 'S', 'P', 'Y', 0 };        /*   Identificativo, 4 caratteri   */
  2604.  
  2605. WORD    executing=0;        /*   Numero di processi che stanno eseguendo SPY   */
  2606. BOOL    quitting=FALSE;        /*   Sto per cancellare SPY   */
  2607. BOOL    loading=FALSE;        /*   Sto attendedo di poter spostare window    */
  2608. BOOL    goon=FALSE;            /*   E` stato dato il GO ON   */
  2609. BOOL    gotvect=FALSE;        /*   Memorizzati i vecchi vettori   */
  2610. BOOL    windowinuse=FALSE;        /*   Window gia` in uso   */
  2611. BOOL    cannotwait;                /*   Non si puo` fare il WAIT FOR GO   */
  2612. BOOL    customfile=FALSE;        /*   C'e` un argometo da CLI   */
  2613. struct    Task    *spytask;        /*   Puntatore al Task di SPY   */
  2614. COUNT    flashcount;        /*   Contatore per ScreenFlash   */
  2615.  
  2616. UBYTE    lockname[LOCKNAMELEN+1];        /*   Usate da spyprintlock()   */
  2617. UBYTE    locknametmp[LOCKNAMELEN+1];
  2618. struct    FileInfoBlock    *lockfib;
  2619.  
  2620. BPTR    printerfh=NULL;        /*   Usate da printerprint   */
  2621. BOOL    noprint=FALSE;
  2622. BOOL    notrapprt=FALSE;
  2623.  
  2624.  
  2625.  
  2626. /*****   Main   *****/
  2627. void main( int argc, char **argv)
  2628. {
  2629.     if( argc>1 )
  2630.         {
  2631.         if( argc>2 )
  2632.             fine( "Too many arguments" );
  2633.         if( argv[1][0]=='?' )
  2634.             fine( FINEHELP );
  2635.         strncpy( configname, argv[1], CSTRLEN );
  2636.         customfile=TRUE;
  2637.         }
  2638.  
  2639.     loadconfig();
  2640.     openall();
  2641.     setprinter();
  2642.  
  2643.     getoldvect();
  2644.     setvect( TUTTIV );
  2645.  
  2646.     FOREVER
  2647.         {
  2648.         WaitPort( window->UserPort );
  2649.         msg=(struct IntuiMessage *)GetMsg( window->UserPort );
  2650.  
  2651.         if( (struct Message *)msg==&gomsg )        /*   Wait fo GO   */
  2652.             {
  2653.             if( SCREENFLASH )
  2654.                 {
  2655.                 flashcount=0;
  2656.                 DisplayBeep( NULL );
  2657.                 }
  2658.             goon=FALSE;
  2659.             OnGadget( &gadgetgoon, window, NULL );
  2660.             tmflash.tr_time.tv_micro=FLASHDELAY;
  2661.             SendIO( IO &tmflash );
  2662.             }
  2663.         else if( (struct timerequest *)msg==&tmflash )        /*   Timer   */
  2664.             {
  2665.             if( goon )
  2666.                 {
  2667.                 ReplyMsg( &gomsg );
  2668.                 }
  2669.             else
  2670.                 {
  2671.                 if( SCREENFLASH )
  2672.                     if( flashcount++==6 )
  2673.                         {
  2674.                         flashcount=0;
  2675.                         DisplayBeep( NULL );
  2676.                         }
  2677.                 gadgetgoontext.FrontPen= gadgetgoontext.FrontPen==1 ? 3 : 1;
  2678.                 RefreshGList( &gadgetgoon, window, NULL, 1);
  2679.                 tmflash.tr_time.tv_micro=FLASHDELAY;
  2680.                 SendIO( IO &tmflash );
  2681.                 }
  2682.             }
  2683.         else if( (struct timerequest *)msg==&tmquit )        /*   Quiting   */
  2684.             {
  2685.             if( executing )        /*   C'e` ancora qualcuno   */
  2686.                 {
  2687.                 quitting=1;
  2688.                 tmquit.tr_time.tv_micro=QUITDELAY;
  2689.                 SendIO( IO &tmquit );
  2690.                 }
  2691.             else
  2692.                 {
  2693.                 if( quitting==2 )        /*   non c'e` nessuno per due volte consecutive   */
  2694.                     fine( NULL );
  2695.                 else
  2696.                     {
  2697.                     ++quitting;
  2698.                     tmquit.tr_time.tv_micro=QUITDELAY;
  2699.                     SendIO( IO &tmquit );
  2700.                     }
  2701.                 }
  2702.             }
  2703.         else if( (struct timerequest *)msg==&tmconfig )        /*   Loading Config   */
  2704.             {
  2705.             Forbid();
  2706.             if( windowinuse )
  2707.                 {                
  2708.                 Permit();
  2709.                 tmconfig.tr_time.tv_micro=CONFIGDELAY;
  2710.                 SendIO( IO &tmconfig );
  2711.                 }
  2712.             else
  2713.                 {
  2714.                 windowinuse=TRUE;
  2715.                 Permit();
  2716.                 ClearMenuStrip( window );
  2717.                 CloseWindow( window );
  2718.                 openwindow();
  2719.                 windowinuse=FALSE;
  2720.                 loading=FALSE;
  2721.                 setprinter();
  2722.                 }
  2723.             }
  2724.         else if( (struct SPYMsg *)msg==&lockmsg )        /*   Scrive un lock   */
  2725.             {
  2726.             spyprintlock( (BPTR)(lockmsg.data) );
  2727.             ReplyMsg( (struct Message *)msg );
  2728.             }
  2729.         else if( (struct SPYMsg *)msg==&prtmsg )        /*   Stampa una stringa   */
  2730.             {
  2731.             spyprinterprint( (UBYTE *)(prtmsg.data) );
  2732.             ReplyMsg( (struct Message *)msg );
  2733.             }
  2734.         else if( msg->Class==NULL )        /*   Mandato da newexit()   */
  2735.             {
  2736.             setvect( EXITV );
  2737.             FreeMem( msg, sizeof(struct IntuiMessage) );
  2738.             }
  2739.         else
  2740.             {
  2741.             class=msg->Class;
  2742.             code=msg->Code;
  2743.             seconds=msg->Seconds;
  2744.             micros=msg->Micros;
  2745.             ReplyMsg( (struct Message *)msg );
  2746.  
  2747.             switch( class )
  2748.                 {
  2749.                 case CLOSEWINDOW:
  2750.                     quit();
  2751.                     break;
  2752.  
  2753.                 case REFRESHWINDOW:
  2754.                     BeginRefresh( window );
  2755.                     SetRast( rp, 2 );
  2756.                     EndRefresh( window, TRUE );
  2757.                     break;
  2758.  
  2759.                 case GADGETUP:
  2760.                 case VANILLAKEY:
  2761.                     if( goon==FALSE )
  2762.                         {
  2763.                         gadgetgoon.Flags|=GADGDISABLED;
  2764.                         gadgetgoontext.FrontPen=3;
  2765.                         RefreshWindowFrame( window );
  2766.                         goon=TRUE;
  2767.                         }
  2768.                     break;
  2769.  
  2770.                 case MOUSEBUTTONS:
  2771.                     if( code==SELECTDOWN )
  2772.                         {
  2773.                         if( DoubleClick( lastseconds, lastmicros, seconds, micros ) )
  2774.                             functions();
  2775.                         else
  2776.                             {
  2777.                             lastseconds=seconds;
  2778.                             lastmicros=micros;
  2779.                             }
  2780.                         }
  2781.                     break;
  2782.  
  2783.                 case MENUPICK:
  2784.                     while( code!=MENUNULL )
  2785.                         {
  2786.                         switch( MENUNUM(code) )
  2787.                             {
  2788.                             case 0:
  2789.                                 switch( ITEMNUM(code) )
  2790.                                     {
  2791.                                     case 0:        /*   Activated   */
  2792.                                         status( ACTIVATED ? "Activated" : "Deactivated" );
  2793.                                         break;
  2794.                                     case 1:        /*   Printer On/Off   */
  2795.                                         setprinter();
  2796.                                         break;
  2797.                                     case 2:
  2798.                                         functions();
  2799.                                         break;
  2800.                                     case 3:        /*   Save Config   */
  2801.                                         saveconfig();
  2802.                                         break;
  2803.                                     case 4:        /*   Load Config   */
  2804.                                         loadconfig();
  2805.                                         break;
  2806.                                     case 5:        /*   Clear FileHandle   */
  2807.                                         clearfh();
  2808.                                         status( "FileHandle memory cleared" );
  2809.                                         break;
  2810.                                     case 7:        /*   Quit   */
  2811.                                         quit();
  2812.                                         break;
  2813.                                     default:
  2814.                                         status( "***ITEM NOT IMPLEMENTED" );
  2815.                                     }
  2816.                                 break;
  2817.                             case 1:
  2818.                                 status( paramtext[ITEMNUM(code)] );
  2819.                                 break;
  2820.                             default:
  2821.                                 status( "***MENU NOT IMPLEMENTED" );
  2822.                             }
  2823.                         code=ItemAddress( &menu0, code )->NextSelect;
  2824.                         }
  2825.                     break;
  2826.  
  2827.                 default:
  2828.                     fine( "INTERNAL ERROR #1" );
  2829.                 }
  2830.             }
  2831.         }
  2832. }
  2833.  
  2834.  
  2835. /*****   Quit   *****/
  2836. void quit( void )
  2837. {
  2838.     if( !quitting )
  2839.         {
  2840.         status( "Quitting" );
  2841.         quitting=1;
  2842.         resetvect( TUTTIV );        /*   Disabilita ulteriori chiamate   */
  2843.         tmquit.tr_time.tv_micro=QUITDELAY;
  2844.         SendIO( IO &tmquit );
  2845.         }
  2846. }
  2847.  
  2848.  
  2849.  
  2850. /*****   Save della configurazione   *****/
  2851. void saveconfig( void )
  2852. {
  2853.     if( getconfigname( "SAVE" )==NULL )
  2854.         {
  2855.         configfile=Open( configname, MODE_NEWFILE );
  2856.         if( configfile==NULL )
  2857.             {
  2858.             status( "Cannot open config file!" );
  2859.             return;
  2860.             }
  2861.         if( write( configid, 4 ) )        /*   ID   */
  2862.             goto saveerr;
  2863.         if( write( (UBYTE *)selectedfun, sizeof(selectedfun) ) )
  2864.             goto saveerr;
  2865.         if( writeitem( &itemactivated ) )        /*   Flag vari   */
  2866.             goto saveerr;
  2867.         if( writeitem( &itemprinter ) )
  2868.             goto saveerr;
  2869.         if( writeitem( &itemverbose ) )
  2870.             goto saveerr;
  2871.         if( writeitem( &itemeverytime ) )
  2872.             goto saveerr;
  2873.         if( writeitem( &itemwaitforgo ) )
  2874.             goto saveerr;
  2875.         if( writeitem( &itemflashon ) )
  2876.             goto saveerr;
  2877.         if( write( (UBYTE *)&(window->LeftEdge), 4*2 ) )        /*   Dimensioni window   */
  2878.             goto saveerr;
  2879.         Close( configfile );
  2880.         status( "Saved current configuration" );
  2881.         }
  2882.     return;
  2883.  
  2884. saveerr:
  2885.     status( "Error while saving config file!" );
  2886.     Close( configfile );
  2887.     return;
  2888. }
  2889.  
  2890. /*****   Scrive un BOOL a seconda se l'item e` CHECKED   *****/
  2891. BOOL writeitem( struct MenuItem *item )
  2892. {
  2893.     BOOL    boolbuff;
  2894.  
  2895.     boolbuff= (item->Flags & CHECKED) ? TRUE : FALSE;
  2896.     return( write( (UBYTE *)&boolbuff, 2 ) );
  2897. }
  2898.  
  2899. /*****   Versione sintetica di Write   *****/
  2900. BOOL write( UBYTE *data, COUNT len )
  2901. {
  2902.     return( (BOOL)((Write( configfile, data, len )==len) ?  FALSE : TRUE) );
  2903. }
  2904.  
  2905.  
  2906. /*****   Load della configurazione   *****/
  2907. void loadconfig( void )
  2908. {
  2909.     UBYTE    buff[4];
  2910.     BOOL    boolbuff;
  2911.     BPTR    lock, oldlock;
  2912.  
  2913.     if( loading || quitting )
  2914.         return;
  2915.     if( window )
  2916.         if( getconfigname( "LOAD" ) )
  2917.             return;
  2918.     configfile=Open( configname, MODE_OLDFILE );
  2919.     if( configfile==NULL && IoErr()==ERROR_OBJECT_NOT_FOUND )
  2920.         {
  2921.         lock=Lock( "s:", ACCESS_READ );
  2922.         if( lock )
  2923.             {
  2924.             oldlock=CurrentDir( lock );
  2925.             configfile=Open( configname, MODE_OLDFILE );
  2926.             CurrentDir( oldlock );
  2927.             UnLock( lock );
  2928.             }
  2929.         }
  2930.     if( configfile==NULL )
  2931.         {
  2932.         if( !window && !customfile )
  2933.             return;
  2934.         if( IoErr()==ERROR_OBJECT_NOT_FOUND )
  2935.             status( "That config file doesn't exist!" );
  2936.         else
  2937.             status( "Cannot open the config file!" );
  2938.         return;
  2939.         }
  2940.     if( read( buff, 4 ) || strncmp( buff, configid, 4 )!=0 )
  2941.         {
  2942.         Close( configfile );
  2943.         status( "NOT a SPY config file (or old version)!" );
  2944.         return;
  2945.         }
  2946.     if( read( (UBYTE *)selectedfun, sizeof(selectedfun) ) )
  2947.         goto loaderr;
  2948.     if( read( (UBYTE *)&boolbuff, 2 ) )
  2949.         goto loaderr;
  2950.     if( boolbuff )
  2951.         itemactivated.Flags|=CHECKED;
  2952.     else
  2953.         itemactivated.Flags&= ~CHECKED;
  2954.     if( read( (UBYTE *)&boolbuff, 2 ) )
  2955.         goto loaderr;
  2956.     if( boolbuff )
  2957.         itemprinter.Flags|=CHECKED;
  2958.     else
  2959.         itemprinter.Flags&= ~CHECKED;
  2960.     if( readitem( &itemverbose ) )
  2961.         goto loaderr;
  2962.     if( readitem( &itemeverytime ) )
  2963.         goto loaderr;
  2964.     if( readitem( &itemwaitforgo ) )
  2965.         goto loaderr;
  2966.     if( readitem( &itemflashon ) )
  2967.         goto loaderr;
  2968.     if( read( (UBYTE *)&windowdata, 4*2 ) )
  2969.         goto loaderr;
  2970.     Close( configfile );
  2971.     if( !window )
  2972.         return;
  2973.     status( "Waiting for modifying window" );
  2974.     loading=TRUE;
  2975.     tmconfig.tr_time.tv_micro=CONFIGDELAY;
  2976.     SendIO( IO &tmconfig );
  2977.     setvect( TUTTIV );
  2978.     return;
  2979.  
  2980. loaderr:
  2981.     Close( configfile );
  2982.     status( "Error while loading config file!" );
  2983.     return;
  2984. }
  2985.  
  2986. /*****   Legge lo stato di un item dal config file   *****/
  2987. BOOL readitem( struct MenuItem *item )
  2988. {
  2989.     BOOL    buff;
  2990.  
  2991.     if( read( (UBYTE *)&buff, 2 ) )
  2992.         return( TRUE );
  2993.     if( buff )
  2994.         {
  2995.         item->Flags|=CHECKED;
  2996.         (item->NextItem)->Flags&= ~CHECKED;
  2997.         }
  2998.     else
  2999.         {
  3000.         item->Flags&= ~CHECKED;
  3001.         (item->NextItem)->Flags|=CHECKED;
  3002.         }
  3003.     return( FALSE );
  3004. }
  3005.  
  3006. /*****   Versione sintetica di Read   *****/
  3007. BOOL read( UBYTE *data, COUNT len )
  3008. {
  3009.     return( (BOOL)((Read( configfile, data, len )==len) ?  FALSE : TRUE) );
  3010. }
  3011.  
  3012.  
  3013. /*****   Input del nome del file di configurazione   *****/
  3014. BOOL getconfigname( UBYTE *saveorload )
  3015. {
  3016.     struct    Window    *cwindow;
  3017.     struct    RastPort    *crp;
  3018.     USHORT    gid;
  3019.     COUNT    i;
  3020.  
  3021.     if( quitting )
  3022.         return( 1 );
  3023.  
  3024.     if( (cwindow=OpenWindow( &cwindowdata ))==NULL )
  3025.         {
  3026.         status( "Can't open CONFIGURATION window!" );
  3027.         return( 1 );
  3028.         }
  3029.  
  3030.     crp=cwindow->RPort;
  3031.     SetAPen( crp, 2 );
  3032.     RectFill( crp, 0, 10, CWINDW-1, CWINDH-1 );
  3033.     SetAPen( crp, 3 );
  3034.     RectFill( crp, 4, 12, CWINDW-4-1, CWINDH-2-1 );
  3035.     SetAPen( crp, 2 );
  3036.     RectFill( crp, 6, 13, CWINDW-6-1, CWINDH-3-1 );
  3037.     for( i=0; i<CWWALLNUM; i++ )
  3038.         DrawImage( crp, &wallImage, CWALLL+WALLW*i, CWALLT );
  3039.     cwindowokgadgettext.IText=saveorload;
  3040.     strcpy( gconfigname, configname );
  3041.     AddGList( cwindow, &cwindowgadget, 0, -1, NULL );
  3042.     RefreshGList( &cwindowgadget, cwindow, NULL, -1 );
  3043.  
  3044.     ActivateGadget( &cwindowgadget, cwindow, NULL );
  3045.  
  3046.     FOREVER
  3047.         {
  3048.         WaitPort( cwindow->UserPort );
  3049.         msg=(struct IntuiMessage *)GetMsg( cwindow->UserPort );
  3050.         gid=((struct Gadget *)msg->IAddress)->GadgetID;
  3051.         ReplyMsg( (struct Message *)msg );
  3052.         if( gid==COKID )
  3053.             {
  3054.             CloseWindow( cwindow );
  3055.             strcpy( configname, gconfigname );
  3056.             return( NULL );
  3057.             }
  3058.         else
  3059.             {
  3060.             CloseWindow( cwindow );
  3061.             return( 1 );
  3062.             }
  3063.         }
  3064. }
  3065.  
  3066.  
  3067.  
  3068. /*****   Entra in SPY   *****/
  3069. void goin( void )
  3070. {
  3071.     Forbid();
  3072.     ++executing;
  3073.     Permit();
  3074. }
  3075.  
  3076. /*****   Esce da SPY   *****/
  3077. void goout( void )
  3078. {
  3079.     Forbid();
  3080.     --executing;
  3081.     Permit();
  3082. }
  3083.  
  3084.  
  3085. /*****   Controlla se si deve fare l'output delle informazioni   *****/
  3086. BOOL canoutput( void )
  3087. {
  3088.     struct    Task    *task;
  3089.  
  3090.     task=FindTask( NULL );
  3091.     if( task==spytask ||
  3092.             !ACTIVATED ||
  3093.             (notrapprt && strcmp( task->tc_Node.ln_Name, "PRT" )==NULL) ||
  3094.             (LONG)task->tc_SPUpper-(LONG)task->tc_SPLower<MINSTACK)
  3095.         return( FALSE );
  3096.     else
  3097.         return( TRUE );
  3098. }
  3099.  
  3100.  
  3101. /*****   Prende possesso della window, eventualmente aspetta, esce in Forbid   *****/
  3102. void ownwindow( void )
  3103. {
  3104.     struct    timerequest    *tr;
  3105.     struct    MsgPort        *myport;
  3106.     LONG    odret;
  3107.  
  3108.     FOREVER
  3109.         {
  3110.         Forbid();
  3111.         if( windowinuse==FALSE )
  3112.             {
  3113.             windowinuse=TRUE;
  3114.             break;
  3115.             }
  3116.         Permit();        /*   Adesso attendiamo un po`   */
  3117.         tr=NULL;
  3118.         myport=NULL;
  3119.         if( (tr=AllocMem( sizeof(struct timerequest), MEMF_CLEAR | MEMF_PUBLIC ))==NULL )
  3120.             status( "***NO MEMORY FOR TIMEREQUEST" );
  3121.         else
  3122.             {
  3123.             tr->tr_node.io_Command=TR_ADDREQUEST;
  3124.             tr->tr_time.tv_micro=OWNWINDOWDELAY;
  3125.             myport=CreatePort( NULL, 0 );
  3126.             if( myport==NULL )
  3127.                 status( "***CANNOT CREATE PORT" );
  3128.             else
  3129.                 {
  3130.                 tr->tr_node.io_Message.mn_ReplyPort=myport;
  3131.                 fresetvect( OPENDEVICEV );
  3132.                 odret=OpenDevice( TIMERNAME, UNIT_VBLANK, IO tr, NULL );
  3133.                 fsetvect( OPENDEVICEV );
  3134.                 if( odret!=NULL )
  3135.                     status( "***CANNOT OPEN TIMER" );
  3136.                 else
  3137.                     {
  3138.                     SendIO( IO tr );
  3139.                     WaitPort( myport );
  3140.                     fresetvect( CLOSEDEVICEV );
  3141.                     CloseDevice( IO tr );
  3142.                     fsetvect( CLOSEDEVICEV );
  3143.                     }
  3144.                 DeletePort( myport );
  3145.                 }
  3146.             FreeMem( tr, sizeof(struct timerequest) );
  3147.             }
  3148.         }
  3149. /*   Adesso e` in Forbid   */
  3150. }
  3151.  
  3152.  
  3153. /*****   Prende possesso della finestra, disabilita multitasking,   *****/
  3154. /*****   ed inizia l'output delle informazioni   *****/
  3155. void initout( UBYTE    *funname )
  3156. {
  3157.     ownwindow();
  3158.         /*   Da qui e` in forbid   */
  3159.     cannotwait=FALSE;
  3160.     if( strcmp(FindTask( NULL )->tc_Node.ln_Name, "input.device")==NULL )
  3161.         cannotwait=TRUE;
  3162.     if( VERBOSE )
  3163.         {
  3164.         newline();
  3165.         littlenewline();
  3166.         Move( rp, 0, window->GZZHeight-7 );
  3167.         Draw( rp, window->GZZWidth, window->GZZHeight-7 );
  3168.         Move( rp, 0, window->GZZHeight-4 );
  3169.         Draw( rp, window->GZZWidth, window->GZZHeight-4 );
  3170.         Move( rp, 25, window->GZZHeight-3 );
  3171.         SetDrMd( rp, INVERSVID | JAM2 );
  3172.         printerprint( prtfunnameon );
  3173.         prints( " " );
  3174.         prints( funname );
  3175.         prints( " " );
  3176.         SetDrMd( rp, JAM1 );
  3177.         printerprint( prtfunnameoff );
  3178.         newline();
  3179.         prints( "TaskName: " );
  3180.         prints( FindTask( NULL )->tc_Node.ln_Name );
  3181.         newline();
  3182.         }
  3183.     else
  3184.         {
  3185.         newline();
  3186.         prints( funname );
  3187.         prints( ": " );
  3188.         }
  3189. }
  3190.  
  3191.  
  3192. /*****   Ripristina multitasking, se necessario aspetta il GO   *****/
  3193. /*****   e infine rilascia la finestra   *****/
  3194. void endout( void )
  3195. {
  3196.     Permit();
  3197.  
  3198.     if( WAITGO )
  3199.         {
  3200.         if( cannotwait )
  3201.             {
  3202.             status( "Cannot wait for GO" );
  3203.             }
  3204.         else
  3205.             {
  3206.             if( (goport.mp_SigBit=AllocSignal(-1))==-1 )
  3207.                 status( "Cannot wait for GO (no free signal)" );
  3208.             else
  3209.                 {
  3210.                 goport.mp_SigTask=FindTask( NULL );
  3211.                 PutMsg( window->UserPort, &gomsg );
  3212.                 WaitPort( &goport );
  3213.                 if( GetMsg( &goport )!=&gomsg )
  3214.                     fine( "INTERNAL ERROR #3" );
  3215.                 FreeSignal( goport.mp_SigBit );
  3216.                 }
  3217.             }
  3218.         }
  3219.  
  3220.     windowinuse=FALSE;        /*   Rilascia la finestra   */
  3221. }
  3222.  
  3223.  
  3224. /*****   Scrive un messaggio di SPY nella finestra, senza interferenze   *****/
  3225. void status( UBYTE *text )
  3226. {
  3227.     if( window )        /*   Finestra gia` aperta   */
  3228.         {
  3229.         Forbid();
  3230.         littlenewline();
  3231.         newline();
  3232.         prints( "<" );
  3233.         prints( text );
  3234.         prints( ">" );
  3235.         littlenewline();
  3236.         Permit();
  3237.         }
  3238.     else
  3239.         fine( text );
  3240. }
  3241.  
  3242.  
  3243. /*****   Restituisce l'indirizzo di un vettore   *****/
  3244. struct vect *vectadd( WORD v )
  3245. {
  3246.     if( v<DOSVECTNUM )
  3247.         return( ((struct vect *)(((UBYTE *)DOSBase)-vectoffset[v])) );
  3248.     else
  3249.         return( ((struct vect *)(((UBYTE *)SysBase)-vectoffset[v])) );
  3250. }
  3251.  
  3252.  
  3253. /*****   Registra i veri indirizzi   *****/
  3254. void getoldvect( void )
  3255. {
  3256.     COUNT    i;
  3257.  
  3258.     newvect[ OPENV ].vect2=(ULONG)newopen;
  3259.     newvect[ CLOSEV ].vect2=(ULONG)newclose;
  3260.     newvect[ READV ].vect2=(ULONG)newread;
  3261.     newvect[ WRITEV ].vect2=(ULONG)newwrite;
  3262.     newvect[ INPUTV ].vect2=(ULONG)newinput;
  3263.     newvect[ OUTPUTV ].vect2=(ULONG)newoutput;
  3264.     newvect[ LOCKV ].vect2=(ULONG)newlock;
  3265.     newvect[ UNLOCKV ].vect2=(ULONG)newunlock;
  3266.     newvect[ DUPLOCKV ].vect2=(ULONG)newduplock;
  3267.     newvect[ EXAMINEV ].vect2=(ULONG)newexamine;
  3268.     newvect[ EXNEXTV ].vect2=(ULONG)newexnext;
  3269.     newvect[ INFOV ].vect2=(ULONG)newinfo;
  3270.     newvect[ DELETEFILEV ].vect2=(ULONG)newdeletefile;
  3271.     newvect[ RENAMEV ].vect2=(ULONG)newrename;
  3272.     newvect[ CREATEDIRV ].vect2=(ULONG)newcreatedir;
  3273.     newvect[ CURRENTDIRV ].vect2=(ULONG)newcurrentdir;
  3274.     newvect[ PARENTDIRV ].vect2=(ULONG)newparentdir;
  3275.     newvect[ SEEKV ].vect2=(ULONG)newseek;
  3276.     newvect[ EXECUTEV ].vect2=(ULONG)newexecute;
  3277.     newvect[ LOADSEGV ].vect2=(ULONG)newloadseg;
  3278.     newvect[ UNLOADSEGV ].vect2=(ULONG)newunloadseg;
  3279.     newvect[ CREATEPROCV ].vect2=(ULONG)newcreateproc;
  3280.     newvect[ EXITV ].vect2=(ULONG)newexit;
  3281.     newvect[ IOERRV ].vect2=(ULONG)newioerr;
  3282.         /*   Funzioni EXEC   */
  3283.     newvect[ ALLOCMEMV ].vect2=(ULONG)newallocmem;
  3284.     newvect[ OPENDEVICEV ].vect2=(ULONG)newopendevice;
  3285.     newvect[ CLOSEDEVICEV ].vect2=(ULONG)newclosedevice;
  3286.     newvect[ ADDDEVICEV ].vect2=(ULONG)newadddevice;
  3287.     newvect[ OPENLIBRARYV ].vect2=(ULONG)newopenlibrary;
  3288.     newvect[ OLDOPENLIBRARYV ].vect2=(ULONG)newoldopenlibrary;
  3289.     newvect[ CLOSELIBRARYV ].vect2=(ULONG)newcloselibrary;
  3290.     newvect[ ADDLIBRARYV ].vect2=(ULONG)newaddlibrary;
  3291.     newvect[ OPENRESOURCEV ].vect2=(ULONG)newopenresource;
  3292.     newvect[ ADDRESOURCEV ].vect2=(ULONG)newaddresource;
  3293.     newvect[ FINDPORTV ].vect2=(ULONG)newfindport;
  3294.     newvect[ ADDPORTV ].vect2=(ULONG)newaddport;
  3295.     newvect[ FINDSEMAPHOREV ].vect2=(ULONG)newfindsemaphore;
  3296.     newvect[ ADDSEMAPHOREV ].vect2=(ULONG)newaddsemaphore;
  3297.     newvect[ FINDNAMEV ].vect2=(ULONG)newfindname;
  3298.  
  3299.     for( i=0; i<VECTNUM-NOTIMPVECTNUM; i++ )
  3300.         oldvect[i]=*vectadd(i);
  3301.     gotvect=TRUE;
  3302. }
  3303.  
  3304. /*****   Setta le nuove routines, se si devono settare   *****/
  3305. void setvect( WORD v )
  3306. {
  3307.     COUNT    i;
  3308.  
  3309.     if( !quitting )
  3310.         {
  3311.         if( v==TUTTIV )
  3312.             {
  3313.             for( i=0; i<VECTNUM-NOTIMPVECTNUM; i++ )
  3314.                 *vectadd(i)= selectedfun[i] ? newvect[i] : oldvect[i];
  3315.             }
  3316.         else
  3317.             *vectadd(v)= selectedfun[v] ? newvect[v] : oldvect[v];
  3318.  
  3319. /*         ((struct Library *)DOSBase)->lib_Flags|=LIBF_CHANGED; */
  3320. /*         ((struct Library *)SysBase)->lib_Flags|=LIBF_CHANGED; */
  3321. /*         SumLibrary( (struct Library *)DOSBase ); */
  3322. /*         SumLibrary( (struct Library *)SysBase ); */
  3323.         }
  3324. }
  3325.  
  3326. /*****   Resetta le vecchie routines   *****/
  3327. void resetvect( WORD v )
  3328. {
  3329.     COUNT    i;
  3330.  
  3331.     if( v==TUTTIV )
  3332.         {
  3333.         for( i=0; i<VECTNUM-NOTIMPVECTNUM; i++ )
  3334.             *vectadd(i)=oldvect[i];
  3335.         }
  3336.     else
  3337.         *vectadd(v)=oldvect[v];
  3338.  
  3339. /*     ((struct Library *)DOSBase)->lib_Flags|=LIBF_CHANGED; */
  3340. /*     ((struct Library *)SysBase)->lib_Flags|=LIBF_CHANGED; */
  3341. /*     SumLibrary( (struct Library *)DOSBase ); */
  3342. /*     SumLibrary( (struct Library *)SysBase ); */
  3343. }
  3344.  
  3345.  
  3346. /*****   Setta le nuove routines, se si devono settare, e va in Forbid   *****/
  3347. void fsetvect( WORD v )
  3348. {
  3349.     Forbid();
  3350.     setvect( v );
  3351. }
  3352.  
  3353.  
  3354. /*****   Resetta le vecchie routines, ed esce dal Forbid   *****/
  3355. void fresetvect( WORD v )
  3356. {
  3357.     resetvect( v );
  3358.     Permit();
  3359. }
  3360.  
  3361.  
  3362. /*****   Inizio routines di scrittura   *****/
  3363.  
  3364. /*****   Scrolla la finestra di un rigo   *****/
  3365. void newline( void )
  3366. {
  3367.     ScrollRaster( rp, 0, 9, 0, 0, window->GZZWidth-1, window->GZZHeight-1 );
  3368.     Move( rp, 0, window->GZZHeight-3 );
  3369.     printerprint( "\n" );
  3370. }
  3371.  
  3372.  
  3373. /*****   Scrolla la finestra di mezzo rigo   *****/
  3374. void littlenewline( void )
  3375. {
  3376.     ScrollRaster( rp, 0, 3, 0, 0, window->GZZWidth-1, window->GZZHeight-1 );
  3377.     Move( rp, 0, window->GZZHeight-3 );
  3378.     printerprint( "\n" );
  3379. }
  3380.  
  3381.  
  3382. /*****   Scrive una stringa   *****/
  3383. void prints( UBYTE *testo )
  3384. {
  3385.     if( !testo )
  3386.         prints( "*NULL*" );
  3387.     else
  3388.         {
  3389.         Text( rp, testo, MIN( strlen(testo), TEXTLEN ) );
  3390.         printerprint( testo );
  3391.         }
  3392. }
  3393.  
  3394.  
  3395. /*****   Scrive un nome in HighLight   *****/
  3396. void printname( UBYTE *name )
  3397. {
  3398.     if( name )
  3399.         {
  3400.         SetAPen( rp, 1 );
  3401.         printerprint( prtnameon );
  3402.         prints( name );
  3403.         SetAPen( rp, 3 );
  3404.         printerprint( prtnameoff );
  3405.         }
  3406.     else
  3407.         prints( "NULL" );
  3408. }
  3409.  
  3410.  
  3411. /*****   Scrive il contenuto di un buffer come stringa ASCII, solo schermo   *****/
  3412. void printbuffer( UBYTE    *buffer, LONG len )
  3413. {
  3414.     printh( (ULONG)buffer );
  3415.     Text( rp, "  (", 3 );
  3416.     Text( rp, buffer, MIN(len, BUFFERLEN) );
  3417.     Text( rp, ")", 1 ); 
  3418. }
  3419.  
  3420.  
  3421. /*****   Scrive un nome in HighLight tra parenteri   *****/
  3422. void printpname( UBYTE *name )
  3423. {
  3424.     prints( "  (" );
  3425.     printname( name );
  3426.     prints( ")" );
  3427. }
  3428.  
  3429.  
  3430. /*****   Chiede a SPY di scrivere un lock   *****/
  3431. /*****   Non posso scriverlo io perche` si modifica IoErr()   *****/
  3432. void printlock( BPTR lock )
  3433. {
  3434.     if( (lockport.mp_SigBit=AllocSignal(-1))==-1 )
  3435.         prints( "Cannot print lock (no free signal)" );
  3436.     else
  3437.         {
  3438.         lockport.mp_SigTask=FindTask( NULL );
  3439.         lockmsg.data=(ULONG)lock;
  3440.         PutMsg( window->UserPort, (struct Message *)&lockmsg );
  3441.         WaitPort( &lockport );
  3442.         if( GetMsg( &lockport )!=(struct Message *)&lockmsg )
  3443.             fine( "INTERNAL ERROR #4" );
  3444.         FreeSignal( lockport.mp_SigBit );
  3445.         }
  3446. }
  3447.  
  3448.  
  3449.  
  3450. /*****   Scrive un lock, indirizzo e nome   *****/
  3451. void spyprintlock( BPTR lock )
  3452. {
  3453.     BPTR    plock;
  3454.  
  3455.     printh( (ULONG)lock );
  3456.  
  3457. /*     if( !lock ) */
  3458. /*         { */
  3459. /*         prints( "  (Root)" ); */
  3460. /*         return; */
  3461. /*         } */
  3462.  
  3463.     lockname[0]='\0';
  3464.     lock=DupLock( lock );
  3465.     do
  3466.         {
  3467.         if( Examine( lock, lockfib )==DOSFALSE )
  3468.             break;
  3469.         plock=ParentDir( lock );
  3470.         UnLock( lock );
  3471.         lock=plock;
  3472.         if( lockfib->fib_DirEntryType>0 )
  3473.             locknameadd( plock ? "/" : ":" );
  3474.         locknameadd( lockfib->fib_FileName );
  3475.         }while( lock );
  3476.     printpname( lockname );
  3477. }
  3478. /*****   Aggiunge una stringa all'inizio di lockname, max LOCKNAMELEN   *****/
  3479. void locknameadd( UBYTE *add )
  3480. {
  3481.     strncpy( locknametmp, add, LOCKNAMELEN );
  3482.     strncat( locknametmp, lockname, LOCKNAMELEN );
  3483.     strcpy( lockname, locknametmp );
  3484. }
  3485.  
  3486.  
  3487. /*****   Scrive un FileHandle, eventualmente anche il nome   *****/
  3488. void printfh( BPTR fh )
  3489. {
  3490.     struct    fhnode    *fhn;
  3491.  
  3492.     printh( (ULONG)fh );
  3493.     fhn=findfh( fh );
  3494.     if( fhn )
  3495.         printpname( fhn->name );
  3496. }
  3497.  
  3498.  
  3499. /*****   Scrive un numero in decimale   *****/
  3500. void printd( LONG numero )
  3501. {
  3502.     BYTE    buff[12];
  3503.  
  3504.     stci_d( buff, numero );
  3505.     prints( buff );
  3506. }
  3507.  
  3508.  
  3509. /*****   Scrive un numero decimale fra parentesi   *****/
  3510. void printpd( LONG numero )
  3511. {
  3512.     prints( "  (" );
  3513.     printd( numero );
  3514.     prints( ")" );
  3515. }
  3516.  
  3517.  
  3518. /*****   Scrive un numero in esadecimale   *****/
  3519. void printh( ULONG numero )
  3520. {
  3521.     BYTE    buff[12]="$";
  3522.  
  3523.     if( numero==0 )
  3524.         prints( "NULL" );
  3525.     else if( numero==-1 )
  3526.         prints( "-1" );
  3527.     else
  3528.         {
  3529.         stci_h( &buff[1], numero );
  3530.         prints( buff );
  3531.         }
  3532. }
  3533.  
  3534.  
  3535. /*****   Manda del testo alla stampante   *****/
  3536. /*****   Dobbiamo chiedere a SPY di farlo   *****/
  3537. void printerprint( UBYTE *text )
  3538. {
  3539.     if( printerfh && !noprint )
  3540.         {
  3541.         noprint=TRUE;
  3542.         if( FindTask( NULL )==spytask )
  3543.             spyprinterprint( text );
  3544.         else if( (prtport.mp_SigBit=AllocSignal(-1))==-1 )
  3545.             {
  3546.             prints( "Cannot print (no free signal)" );
  3547.             }
  3548.         else
  3549.             {
  3550.             prtport.mp_SigTask=FindTask( NULL );
  3551.             prtmsg.data=(ULONG)text;
  3552.             PutMsg( window->UserPort, (struct Message *)&prtmsg );
  3553.             WaitPort( &prtport );
  3554.             if( GetMsg( &prtport )!=(struct Message *)&prtmsg )
  3555.                 fine( "INTERNAL ERROR #5" );
  3556.             FreeSignal( prtport.mp_SigBit );
  3557.             }
  3558.         noprint=FALSE;
  3559.         }
  3560. }
  3561.  
  3562. /*****   Stampa del testo   *****/
  3563. void spyprinterprint( UBYTE *text )
  3564. {
  3565.     LONG    len;
  3566.  
  3567.     len=MIN( strlen(text), 80 );
  3568.     if( Write( printerfh, text, len )!=len )
  3569.         {
  3570.         status( "Problems with the printer" );
  3571.         }
  3572. }
  3573.  
  3574.  
  3575. /*****   Accende o spegne la stampante   *****/
  3576. void setprinter( void )
  3577. {
  3578.     LONG    oldpri;
  3579.  
  3580.     if( PRINTER )
  3581.         {
  3582.         status( "Printer is ON" );
  3583.         status( "Be SURE your printer is really ON!" );
  3584.         if( !printerfh )
  3585.             {
  3586.             notrapprt=TRUE;
  3587.             printerfh=Open( "PRT:", MODE_OLDFILE );
  3588.             notrapprt=FALSE;
  3589.             if( printerfh==NULL )
  3590.                 status( "Cannot open the printer!" );
  3591.             }
  3592.         }
  3593.     else
  3594.         {
  3595.         if( printerfh )
  3596.             {
  3597.             notrapprt=TRUE;
  3598.             oldpri=SetTaskPri( FindTask(NULL), -10 );        /*   Attende che si chiuda la stampante   */
  3599.             Close( printerfh );
  3600.             SetTaskPri( FindTask(NULL), oldpri );
  3601.             notrapprt=FALSE;
  3602.             }
  3603.         printerfh=NULL;
  3604.         status( "Printer is OFF" );
  3605.         }
  3606. }
  3607.  
  3608.  
  3609. /*****   Funzioni di gestione della lista nomi dei FileHandle   *****/
  3610.  
  3611. /*****   Aggiunge un FH   *****/
  3612. void addfh( BPTR fh, UBYTE    *name )
  3613. {
  3614.     struct    fhnode    *fhn;
  3615.  
  3616.     fhn=AllocMem( sizeof(struct fhnode), MEMF_PUBLIC );
  3617.     if( !fhn )
  3618.         {
  3619.         status( "Cannot memorize the FileHandle name" );
  3620.         return;
  3621.         }
  3622.     fhn->fh=fh;
  3623.     strncpy( fhn->name, name, FHNAMELEN );
  3624.     AddHead( (struct List *)&fhlist, (struct Node *)fhn );
  3625. }
  3626.  
  3627. /*****   Cancella un FH   *****/
  3628. void remfh( BPTR fh )
  3629. {
  3630.     struct    fhnode    *fhn;
  3631.  
  3632.     fhn=findfh( fh );
  3633.     if( !fhn )
  3634.         return;        /*   Non esiste   */
  3635.     Remove( (struct Node *)fhn );
  3636.     FreeMem( fhn, sizeof(struct fhnode) );
  3637. }
  3638.  
  3639. /*****   Cerca un FH   *****/
  3640. struct fhnode *findfh( BPTR fh )
  3641. {
  3642.     struct    fhnode    *fhn;
  3643.  
  3644.     ALLFHLIST
  3645.         {
  3646.         if( fhn->fh==fh )
  3647.             return( fhn );
  3648.         }
  3649.     return( NULL );
  3650. }
  3651.  
  3652. /*****   Cancella tutta la lista dei FH   *****/
  3653. void clearfh( void )
  3654. {
  3655.     struct    fhnode    *fhn;
  3656.  
  3657.     while( fhn=(struct fhnode *)RemHead((struct List *)&fhlist) )
  3658.         FreeMem( fhn, sizeof(struct fhnode) );
  3659. }
  3660.  
  3661.  
  3662.  
  3663. /*****   Apre e gestisce la finestra per attivare/disattivare le nuove funzioni   *****/
  3664. void functions( void )
  3665. {
  3666.     struct    Window    *fwindow;
  3667.     struct    RastPort    *frp;
  3668.     USHORT    gid;
  3669.     struct    Gadget    *g;
  3670.     COUNT    i;
  3671.  
  3672.     if( quitting )
  3673.         return;
  3674.  
  3675.     setfgadget();
  3676.  
  3677.     if( (fwindow=OpenWindow( &fwindowdata ))==NULL )
  3678.         {
  3679.         status( "Can't open FUNCTIONS window!" );
  3680.         return;
  3681.         }
  3682.     frp=fwindow->RPort;
  3683.     SetAPen( frp, 2 );
  3684.     RectFill( frp, 0, 10, FWINDW-1, FWINDH-1 );
  3685.     SetAPen( frp, 3 );
  3686.     RectFill( frp, 4, 12, FWINDW-4-1, FWINDH-2-1 );
  3687.     SetAPen( frp, 2 );
  3688.     RectFill( frp, 6, 13, FWINDW-6-1, FWINDH-3-1 );
  3689.     for( i=0; i<FWWALLNUM; i++ )
  3690.         DrawImage( frp, &wallImage, FWALLL+WALLW*i, FWALLT );
  3691.     PrintIText( frp, &ftext, 0, 0 );
  3692.     AddGList( fwindow, &fwindowgadget, 0, -1, NULL );
  3693.     RefreshGList( &fwindowgadget, fwindow, NULL, -1 );
  3694.  
  3695.     FOREVER
  3696.         {
  3697.         WaitPort( fwindow->UserPort );
  3698.         msg=(struct IntuiMessage *)GetMsg( fwindow->UserPort );
  3699.         gid=((struct Gadget *)msg->IAddress)->GadgetID;
  3700.         ReplyMsg( (struct Message *)msg );
  3701.         if( gid==FOKID )
  3702.             {
  3703.             for( i=0, g=&fgadget; i<GADGNUM && g; i++, g=g->NextGadget )
  3704.                 selectedfun[i]= g->Flags & SELECTED ? TRUE : FALSE;
  3705.             setvect( TUTTIV );
  3706.             break;
  3707.             }
  3708.         else if( gid==FCANCELID )
  3709.             break;
  3710.         else if( gid==FRESTOREID )
  3711.             setfgadget();
  3712.         else
  3713.             {
  3714.             for( i=0, g=&fgadget; i<GADGNUM && g; i++, g=g->NextGadget )
  3715.                 if( gid==FALLID )
  3716.                     g->Flags|=SELECTED;
  3717.                 else
  3718.                     g->Flags&=~SELECTED;
  3719.             gadgetfindname.Flags&=~SELECTED;
  3720.             }
  3721.         RefreshGList( &fgadget, fwindow, NULL, -1 );
  3722.         }
  3723.     CloseWindow( fwindow );
  3724. }
  3725.  
  3726. /*****   Setta i gadget della fwindow   *****/
  3727. void setfgadget( void )
  3728. {
  3729.     COUNT    i;
  3730.     struct    Gadget    *g;
  3731.  
  3732.     for( i=0, g=&fgadget; i<GADGNUM && g; i++, g=g->NextGadget )
  3733.         if( selectedfun[i] )
  3734.             g->Flags|=SELECTED;
  3735.         else
  3736.             g->Flags&=~SELECTED;
  3737. }
  3738.  
  3739.  
  3740. /*****  Apri: la mia porta, screen, window, e i due timer  *****/
  3741. void openall( void )
  3742. {
  3743.     if( FindPort( goport.mp_Node.ln_Name ) )
  3744.         fine( "SPY is already installed" );
  3745.     AddPort( &goport );
  3746.     spytask=FindTask( NULL );
  3747.     if( (lockfib=AllocMem( sizeof(struct FileInfoBlock), MEMF_PUBLIC ))==NULL )
  3748.         fine( "No memory for lockfib" );
  3749.     if( (IntuitionBase=(struct IntuitionBase *)OpenLibrary( "intuition.library", LIBVER ))==NULL )
  3750.         fine( "Intution.library not found" );
  3751.     if( (GfxBase=(struct GfxBase *)OpenLibrary( "graphics.library", LIBVER ))==NULL )
  3752.         fine( "Graphics.library not found" );
  3753.  
  3754.     if( OpenDevice( TIMERNAME, UNIT_VBLANK, IO &tmflash, NULL )!=NULL )
  3755.         fine( notimer );
  3756.     if( OpenDevice( TIMERNAME, UNIT_VBLANK, IO &tmquit, NULL )!=NULL )
  3757.         fine( notimer );
  3758.     if( OpenDevice( TIMERNAME, UNIT_VBLANK, IO &tmconfig, NULL )!=NULL )
  3759.         fine( notimer );
  3760.  
  3761.     openwindow();
  3762.  
  3763.     fwindowdata.LeftEdge=(window->WScreen->Width-FWINDW)/2;
  3764.     fwindowdata.TopEdge=(window->WScreen->Height-FWINDH)/2;
  3765.     cwindowdata.LeftEdge=(window->WScreen->Width-CWINDW)/2;
  3766.     cwindowdata.TopEdge=(window->WScreen->Height-CWINDH)/2;
  3767. }
  3768.  
  3769. /*****   Apre la finestra principale   *****/
  3770. void openwindow( void )
  3771. {
  3772.     LONG    logox, logoy;
  3773.  
  3774.     if( (window=(struct Window *)OpenWindow( &windowdata ))==NULL )
  3775.         fine( "Cannot open window" );
  3776.     rp=window->RPort;
  3777.     SetBPen( rp, 2 );
  3778.     SetRast( rp, 2 );
  3779.     SetMenuStrip( window, &menu0 );
  3780.     logox=(IWINDW-ALLLOGOW)/2;
  3781.     logoy=MAX( (IWINDH-ALLLOGOH)/2+10, 0 );
  3782.     DrawImage( rp, &logoImage, logox, logoy );
  3783.     PrintIText( rp, &logotext, logox, logoy );
  3784.  
  3785.     tmflash.tr_node.io_Message.mn_ReplyPort=window->UserPort;
  3786.     tmquit.tr_node.io_Message.mn_ReplyPort=window->UserPort;
  3787.     tmconfig.tr_node.io_Message.mn_ReplyPort=window->UserPort;
  3788. }
  3789.  
  3790.  
  3791. /***** Chiudi tutto e muori *****/
  3792. void fine( UBYTE *text )
  3793. {
  3794.     if( text && gotvect )        /*   Se non c'e` errore non e` necessario   */
  3795.         resetvect( TUTTIV );
  3796.  
  3797.     clearfh();
  3798.     if( printerfh ) Close( printerfh );
  3799.     if( tmflash.tr_node.io_Device ) CloseDevice( IO &tmflash );
  3800.     if( tmquit.tr_node.io_Device ) CloseDevice( IO &tmquit );
  3801.     if( tmconfig.tr_node.io_Device ) CloseDevice( IO &tmconfig );
  3802.     if( window )
  3803.         {
  3804.         ClearMenuStrip( window );
  3805.         CloseWindow( window );
  3806.         }
  3807.     if( GfxBase ) CloseLibrary( (struct Library *)GfxBase );
  3808.     if( IntuitionBase ) CloseLibrary( (struct Library *)IntuitionBase );
  3809.     if( goport.mp_Node.ln_Succ ) RemPort( &goport );
  3810.     if( lockfib ) FreeMem( lockfib, sizeof(struct FileInfoBlock) );
  3811.  
  3812.     if( text && _Backstdout )
  3813.         {
  3814.         if( text==FINEHELP )
  3815.             Write( _Backstdout, helptext, strlen(helptext) );
  3816.         else
  3817.             {
  3818.             strcat( errtext, text );
  3819.             strcat( errtext, "!\n\n" );
  3820.             Write( _Backstdout, errtext, strlen(errtext) );
  3821.             }
  3822.         }
  3823.  
  3824.     exit( NULL );
  3825. }
  3826.  
  3827.