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

  1. /****************************************************************************
  2.  
  3.  
  4.                             Funzioni catturate da SPY
  5.  
  6.                               by Federico Giannici
  7.  
  8.  
  9.  
  10.  
  11. -----------------------------------------------------------------------------
  12. This source is provided for you to see the techniques I used to write SPY.
  13. You can, obviously, use it to make your experiments and you can take some
  14. routines to insert in your programs. But you CANNOT modify, recompile and
  15. distribute the modified version to anyone without my permission.
  16. Be a programmer not a copier.
  17. -----------------------------------------------------------------------------
  18.  
  19. ****************************************************************************/
  20.  
  21.  
  22. #include    "SPY.h"
  23.  
  24. #define    TEMPLEN    60        /*   Lunghezza stringhe temporanee per i nomi   */
  25. #define    COPYTEMP( to, from )    strncpy( to, from, TEMPLEN )
  26.  
  27. extern    struct    MenuItem    itemverbose;
  28. extern    struct    MenuItem    itemeverytime;
  29.  
  30.  
  31.  
  32. /*****   Le  proto di SPY   *****/
  33. extern void goin( void );
  34. extern void goout( void );
  35. extern BOOL canoutput( void );
  36. extern void initout( UBYTE    *funname );
  37. extern void endout( void );
  38. extern void status( UBYTE *text );
  39. extern void setvect( WORD v );
  40. extern void resetvect( WORD v );
  41. extern void fsetvect( WORD v );
  42. extern void fresetvect( WORD v );
  43. extern void newline( void );
  44. extern void prints( UBYTE *testo );
  45. extern void printname( UBYTE *name );
  46. extern void printpname( UBYTE *name );
  47. extern void printbuffer( UBYTE    *buffer, LONG len );
  48. extern void printlock( BPTR lock );
  49. extern void printfh( BPTR fh );
  50. extern void printd( LONG numero );
  51. extern void printpd( LONG numero );
  52. extern void printh( ULONG numero );
  53. extern void addfh( BPTR fh, UBYTE    *name );
  54. extern void remfh( BPTR fh );
  55. extern struct fhnode *findfh( BPTR fh );
  56. extern void clearfh( void );
  57.  
  58. extern    BOOL    cannotwait;
  59. extern    struct    Window    *window;
  60.  
  61.  
  62.  
  63. UBYTE    returntext[]="Return: ";
  64. UBYTE    unknow[]="Unknow!!";
  65.  
  66. UBYTE    *openmodetext[]=
  67.     {
  68.     unknow,
  69.     "MODE_READWRITE",
  70.     "MODE_OLDFILE",
  71.     "MODE_NEWFILE"
  72.     };
  73.  
  74. UBYTE    *lockmodetext[]=
  75.     {
  76.     unknow,
  77.     "EXCLUSIVE_LOCK",
  78.     "SHARED_LOCK"
  79.     };
  80.  
  81. UBYTE    *seekmodetext[]=
  82.     {
  83.     unknow,
  84.     "OFFSET_BEGINNING",
  85.     "OFFSET_CURRENT",
  86.     "OFFSET_END"
  87.     };
  88.  
  89.  
  90. /*****   Nuova routine Open   *****/
  91. BPTR __saveds __asm newopen( register __d1 char *name, register __d2 long accessmode )
  92. {
  93.     BPTR    ret;
  94.  
  95.     goin();
  96.     fresetvect( OPENV );
  97.     ret=Open( name, accessmode );
  98.     fsetvect( OPENV );
  99.     addfh( ret, name );
  100.     if( canoutput() && (EVERYTIME || ret==NULL) )
  101.         {
  102.         initout( "Open");
  103.         if( VERBOSE )
  104.             prints( "FileName: " );
  105.         printname( name );
  106.         if( VERBOSE )
  107.             {
  108.             newline();
  109.             prints( "AccessMode: " );
  110.             prints( openmodetext[accessmode<1004 && accessmode>1006 ? 0 : accessmode-1003] );
  111.             printpd( accessmode );
  112.             newline();
  113.             prints( returntext );
  114.             printh( (ULONG)ret );
  115.             }
  116.         endout();
  117.         }
  118.     goout();
  119.     return( ret );
  120. }
  121.  
  122.  
  123. /*****   Nuova routine Close   *****/
  124. void  __saveds __asm newclose( register __d1 BPTR file )
  125. {
  126.     goin();
  127.     fresetvect( CLOSEV );
  128.     Close( file );
  129.     fsetvect( CLOSEV );
  130.     if( canoutput() && (EVERYTIME) )
  131.         {
  132.         initout( "Close");
  133.         if( VERBOSE )
  134.             prints( "FileHandle: " );
  135.         printfh( file );
  136.         endout();
  137.         }
  138.     remfh( file );
  139.     goout();
  140.     return;
  141. }
  142.  
  143.  
  144. /*****   Nuova routine Read   *****/
  145. long __saveds __asm newread( register __d1 BPTR file, register __d2 char *buffer, register __d3 long length )
  146. {
  147.     long    ret;
  148.  
  149.     goin();
  150.     fresetvect( READV );
  151.     ret=Read( file, buffer, length );
  152.     fsetvect( READV );
  153.     if( canoutput() && (EVERYTIME || ret==-1) )
  154.         {
  155.         initout( "Read");
  156.         if( VERBOSE )
  157.             prints( "FileHandle: " );
  158.         printfh( file );
  159.         if( VERBOSE )
  160.             {
  161.             newline();
  162.             prints( "Buffer: " );
  163.             printbuffer( buffer, length );
  164.             newline();
  165.             prints( "Length: " );
  166.             printd( length );
  167.             newline();
  168.             prints( returntext );
  169.             printd( (ULONG)ret );
  170.             }
  171.         endout();
  172.         }
  173.     goout();
  174.     return( ret );
  175. }
  176.  
  177.  
  178. /*****   Nuova routine Write   *****/
  179. long __saveds __asm newwrite( register __d1 BPTR file, register __d2 char *buffer, register __d3 long length )
  180. {
  181.     long    ret;
  182.  
  183.     goin();
  184.     fresetvect( WRITEV );
  185.     ret=Write( file, buffer, length );
  186.     fsetvect( WRITEV );
  187.     if( canoutput() && (EVERYTIME || ret==-1) )
  188.         {
  189.         initout( "Write");
  190.         if( VERBOSE )
  191.             prints( "FileHandle: " );
  192.         printfh( file );
  193.         if( VERBOSE )
  194.             {
  195.             newline();
  196.             prints( "Buffer: " );
  197.             printbuffer( buffer, length );
  198.             newline();
  199.             prints( "Length: " );
  200.             printd( length );
  201.             newline();
  202.             prints( returntext );
  203.             printd( (ULONG)ret );
  204.             }
  205.         endout();
  206.         }
  207.     goout();
  208.     return( ret );
  209. }
  210.  
  211.  
  212. /*****   Nuova routine Input   *****/
  213. BPTR __saveds __asm newinput( void )
  214. {
  215.     BPTR    ret;
  216.  
  217.     goin();
  218.     fresetvect( INPUTV );
  219.     ret=Input();
  220.     fsetvect( INPUTV );
  221.     addfh( ret, "<Input>" );
  222.     if( canoutput() && (EVERYTIME || ret==NULL) )
  223.         {
  224.         initout( "Input");
  225.         if( VERBOSE )
  226.             prints( returntext );
  227.         printh( (ULONG)ret );
  228.         endout();
  229.         }
  230.     goout();
  231.     return( ret );
  232. }
  233.  
  234.  
  235. /*****   Nuova routine Output   *****/
  236. BPTR __saveds __asm newoutput( void )
  237. {
  238.     BPTR    ret;
  239.  
  240.     goin();
  241.     fresetvect( OUTPUTV );
  242.     ret=Input();
  243.     fsetvect( OUTPUTV );
  244.     addfh( ret, "<Output>" );
  245.     if( canoutput() && (EVERYTIME || ret==NULL) )
  246.         {
  247.         initout( "Output");
  248.         if( VERBOSE )
  249.             prints( returntext );
  250.         printh( (ULONG)ret );
  251.         endout();
  252.         }
  253.     goout();
  254.     return( ret );
  255. }
  256.  
  257.  
  258. /*****   Nuova routine Lock   *****/
  259. BPTR __saveds __asm newlock( register __d1 char *name, register __d2 long accessmode )
  260. {
  261.     BPTR    ret;
  262.  
  263.     goin();
  264.     fresetvect( LOCKV );
  265.     ret=Lock( name, accessmode );
  266.     fsetvect( LOCKV );
  267.     if( canoutput() && (EVERYTIME || ret==NULL) )
  268.         {
  269.         initout( "Lock");
  270.         if( VERBOSE )
  271.             prints( "FileName: " );
  272.         printname( name );
  273.         if( VERBOSE )
  274.             {
  275.             newline();
  276.             prints( "AccessMode: " );
  277.             prints( lockmodetext[accessmode==-1 || accessmode==-2 ? -accessmode : 0] );
  278.             printpd( accessmode );
  279.             newline();
  280.             prints( returntext );
  281.             printlock( ret );
  282.             }
  283.         endout();
  284.         }
  285.     goout();
  286.     return( ret );
  287. }
  288.  
  289.  
  290. /*****   Nuova routine UnLock   *****/
  291. void  __saveds __asm newunlock( register __d1 BPTR lock )
  292. {
  293.     goin();
  294.         /*   Prima l'output, altrimenti lock non e` piu` valido   */
  295.     if( canoutput() && (EVERYTIME) )
  296.         {
  297.         initout( "UnLock");
  298.         if( VERBOSE )
  299.             prints( "Lock: " );
  300.         printlock( lock );
  301.         endout();
  302.         }
  303.     fresetvect( UNLOCKV );
  304.     UnLock( lock );
  305.     fsetvect( UNLOCKV );
  306.     goout();
  307.     return;
  308. }
  309.  
  310.  
  311. /*****   Nuova routine DupLock   *****/
  312. BPTR  __saveds __asm newduplock( register __d1 BPTR lock )
  313. {
  314.     BPTR    ret;
  315.  
  316.     goin();
  317.     fresetvect( DUPLOCKV );
  318.     ret=DupLock( lock );
  319.     fsetvect( DUPLOCKV );
  320.     if( canoutput() && (EVERYTIME || ret==NULL) )
  321.         {
  322.         initout( "DupLock");
  323.         if( VERBOSE )
  324.             prints( "Lock: " );
  325.         printlock( lock );
  326.         if( VERBOSE )
  327.             {
  328.             newline();
  329.             prints( returntext );
  330.             printlock( ret );
  331.             }
  332.         endout();
  333.         }
  334.     goout();
  335.     return( ret );
  336. }
  337.  
  338.  
  339. /*****   Nuova routine Examine   *****/
  340. long  __saveds __asm newexamine( register __d1 BPTR lock, register __d2 struct FileInfoBlock *fib )
  341. {
  342.     long    ret;
  343.  
  344.     goin();
  345.     fresetvect( EXAMINEV );
  346.     ret=Examine( lock, fib );
  347.     fsetvect( EXAMINEV );
  348.     if( canoutput() && (EVERYTIME || ret==DOSFALSE) )
  349.         {
  350.         initout( "Examine");
  351.         if( VERBOSE )
  352.             prints( "Lock: " );
  353.         printlock( lock );
  354.         if( VERBOSE )
  355.             {
  356.             newline();
  357.             prints( "FileInfoBlock: " );
  358.             printh( (ULONG)fib );
  359.             newline();
  360.             prints( returntext );
  361.             printh( (ULONG)ret );
  362.             }
  363.         endout();
  364.         }
  365.     goout();
  366.     return( ret );
  367. }
  368.  
  369.  
  370. /*****   Nuova routine ExNext   *****/
  371. long  __saveds __asm newexnext( register __d1 BPTR lock, register __d2 struct FileInfoBlock *fib )
  372. {
  373.     long    ret;
  374.  
  375.     goin();
  376.     fresetvect( EXNEXTV );
  377.     ret=ExNext( lock, fib );
  378.     fsetvect( EXNEXTV );
  379.     if( canoutput() && (EVERYTIME || ret==DOSFALSE) )
  380.         {
  381.         initout( "ExNext");
  382.         if( VERBOSE )
  383.             prints( "Lock: " );
  384.         printlock( lock );
  385.         if( VERBOSE )
  386.             {
  387.             newline();
  388.             prints( "FileInfoBlock: " );
  389.             printh( (ULONG)fib );
  390.             if( ret!=DOSFALSE )
  391.                 printpname( fib->fib_FileName );
  392.             newline();
  393.             prints( returntext );
  394.             printh( (ULONG)ret );
  395.             }
  396.         endout();
  397.         }
  398.     goout();
  399.     return( ret );
  400. }
  401.  
  402.  
  403. /*****   Nuova routine Info   *****/
  404. long  __saveds __asm newinfo( register __d1 BPTR lock, register __d2 struct InfoData *infodata )
  405. {
  406.     long    ret;
  407.  
  408.     goin();
  409.     fresetvect( INFOV );
  410.     ret=Info( lock, infodata );
  411.     fsetvect( INFOV );
  412.     if( canoutput() && (EVERYTIME || ret==DOSFALSE) )
  413.         {
  414.         initout( "Info");
  415.         if( VERBOSE )
  416.             prints( "Lock: " );
  417.         printlock( lock );
  418.         if( VERBOSE )
  419.             {
  420.             newline();
  421.             prints( "InfoData: " );
  422.             printh( (ULONG)infodata );
  423.             newline();
  424.             prints( returntext );
  425.             printh( (ULONG)ret );
  426.             }
  427.         endout();
  428.         }
  429.     goout();
  430.     return( ret );
  431. }
  432.  
  433.  
  434. /*****   Nuova routine DeleteFile   *****/
  435. long __saveds __asm newdeletefile( register __d1 char *name )
  436. {
  437.     long    ret;
  438.  
  439.     goin();
  440.     fresetvect( DELETEFILEV );
  441.     ret=DeleteFile( name );
  442.     fsetvect( DELETEFILEV );
  443.     if( canoutput() && (EVERYTIME || ret==DOSFALSE) )
  444.         {
  445.         initout( "DeleteFile");
  446.         if( VERBOSE )
  447.             prints( "File: " );
  448.         printname( name );
  449.         if( VERBOSE )
  450.             {
  451.             newline();
  452.             prints( returntext );
  453.             printh( (ULONG)ret );
  454.             }
  455.         endout();
  456.         }
  457.     goout();
  458.     return( ret );
  459. }
  460.  
  461.  
  462. /*****   Nuova routine Rename   *****/
  463. long __saveds __asm newrename( register __d1 char *oldname, register __d2 char *newname )
  464. {
  465.     long    ret;
  466.  
  467.     goin();
  468.     fresetvect( RENAMEV );
  469.     ret=Rename( oldname, newname );
  470.     fsetvect( RENAMEV );
  471.     if( canoutput() && (EVERYTIME || ret==DOSFALSE) )
  472.         {
  473.         initout( "Rename");
  474.         if( VERBOSE )
  475.             prints( "OldName: " );
  476.         printname( oldname );
  477.         if( VERBOSE )
  478.             {
  479.             newline();
  480.             prints( "NewName: " );
  481.             printname( newname );
  482.             newline();
  483.             prints( returntext );
  484.             printh( (ULONG)ret );
  485.             }
  486.         endout();
  487.         }
  488.     goout();
  489.     return( ret );
  490. }
  491.  
  492.  
  493. /*****   Nuova routine CreateDir   *****/
  494. BPTR __saveds __asm newcreatedir( register __d1 char *name )
  495. {
  496.     BPTR    ret;
  497.  
  498.     goin();
  499.     fresetvect( CREATEDIRV );
  500.     ret=CreateDir( name );
  501.     fsetvect( CREATEDIRV );
  502.     if( canoutput() && (EVERYTIME || ret==DOSFALSE) )
  503.         {
  504.         initout( "CreateDir");
  505.         if( VERBOSE )
  506.             prints( "Directory: " );
  507.         printname( name );
  508.         if( VERBOSE )
  509.             {
  510.             newline();
  511.             prints( returntext );
  512.             printh( (ULONG)ret );
  513.             }
  514.         endout();
  515.         }
  516.     goout();
  517.     return( ret );
  518. }
  519.  
  520.  
  521. /*****   Nuova routine CurrentDir   *****/
  522. BPTR  __saveds __asm newcurrentdir( register __d1 BPTR lock )
  523. {
  524.     BPTR    ret;
  525.  
  526.     goin();
  527.     fresetvect( CURRENTDIRV );
  528.     ret=CurrentDir( lock );
  529.     fsetvect( CURRENTDIRV );
  530.     if( canoutput() && (EVERYTIME || ret==-1) )
  531.         {
  532.         initout( "CurrentDir");
  533.         if( VERBOSE )
  534.             prints( "NewLock: " );
  535.         printlock( lock );
  536.         if( VERBOSE )
  537.             {
  538.             newline();
  539.             prints( returntext );
  540.             printlock( ret );
  541.             }
  542.         endout();
  543.         }
  544.     goout();
  545.     return( ret );
  546. }
  547.  
  548.  
  549. /*****   Nuova routine ParentDir   *****/
  550. BPTR  __saveds __asm newparentdir( register __d1 BPTR lock )
  551. {
  552.     BPTR    ret;
  553.  
  554.     goin();
  555.     fresetvect( PARENTDIRV );
  556.     ret=ParentDir( lock );
  557.     fsetvect( PARENTDIRV );
  558.     if( canoutput() && (EVERYTIME || ret==-1) )
  559.         {
  560.         initout( "ParentDir");
  561.         if( VERBOSE )
  562.             prints( "Lock: " );
  563.         printlock( lock );
  564.         if( VERBOSE )
  565.             {
  566.             newline();
  567.             prints( returntext );
  568.             printlock( ret );
  569.             }
  570.         endout();
  571.         }
  572.     goout();
  573.     return( ret );
  574. }
  575.  
  576.  
  577. /*****   Nuova routine Seek   *****/
  578. long  __saveds __asm newseek( register __d1 BPTR file, register __d2 long position, register __d3 long mode )
  579. {
  580.     long    ret;
  581.  
  582.     goin();
  583.     fresetvect( SEEKV );
  584.     ret=Seek( file, position, mode );
  585.     fsetvect( SEEKV );
  586.     if( canoutput() && (EVERYTIME || ret==-1) )
  587.         {
  588.         initout( "Seek");
  589.         if( VERBOSE )
  590.             prints( "FileHandle: " );
  591.         printfh( file );
  592.         if( VERBOSE )
  593.             {
  594.             newline();
  595.             prints( "Position: " );
  596.             printd( position );
  597.             newline();
  598.             prints( "Mode: " );
  599.             prints( seekmodetext[ ABS(mode)>1 ? 0 : mode+2 ] );
  600.             printpd( mode );
  601.             newline();
  602.             prints( returntext );
  603.             printd( ret );
  604.             }
  605.         endout();
  606.         }
  607.     goout();
  608.     return( ret );
  609. }
  610.  
  611.  
  612. /*****   Nuova routine Execute   *****/
  613. long  __saveds __asm newexecute( register __d1 char *command, register __d2 BPTR input, register __d3 BPTR output )
  614. {
  615.     long    ret;
  616.  
  617.     goin();
  618.     status( "Entering Execute" );
  619.     fresetvect( EXECUTEV );
  620.     ret=Execute( command, input, output );
  621.     fsetvect( EXECUTEV );
  622.     if( canoutput() && (EVERYTIME || ret==DOSFALSE) )
  623.         {
  624.         initout( "Execute");
  625.         if( VERBOSE )
  626.             prints( "Command: " );
  627.         printname( command );
  628.         if( VERBOSE )
  629.             {
  630.             newline();
  631.             prints( "Input: " );
  632.             printfh( input );
  633.             newline();
  634.             prints( "Output: " );
  635.             printfh( output );
  636.             newline();
  637.             prints( returntext );
  638.             printh( (ULONG)ret );
  639.             }
  640.         endout();
  641.         }
  642.     goout();
  643.     return( ret );
  644. }
  645.  
  646.  
  647. /*****   Nuova routine LoadSeg   *****/
  648. BPTR __saveds __asm newloadseg( register __d1 char *name )
  649. {
  650.     BPTR    ret;
  651.  
  652.     goin();
  653.     fresetvect( LOADSEGV );
  654.     ret=LoadSeg( name );
  655.     fsetvect( LOADSEGV );
  656.     if( canoutput() && (EVERYTIME || ret==DOSFALSE) )
  657.         {
  658.         initout( "LoadSeg");
  659.         if( VERBOSE )
  660.             prints( "Name: " );
  661.         printname( name );
  662.         if( VERBOSE )
  663.             {
  664.             newline();
  665.             prints( returntext );
  666.             printh( (ULONG)ret );
  667.             }
  668.         endout();
  669.         }
  670.     goout();
  671.     return( ret );
  672. }
  673.  
  674.  
  675. /*****   Nuova routine UnLoadSeg   *****/
  676. void  __saveds __asm newunloadseg( register __d1 BPTR segment )
  677. {
  678.     goin();
  679.     fresetvect( UNLOADSEGV );
  680.     UnLoadSeg( segment );
  681.     fsetvect( UNLOADSEGV );
  682.     if( canoutput() && (EVERYTIME) )
  683.         {
  684.         initout( "UnLoadSeg");
  685.         if( VERBOSE )
  686.             prints( "Segment: " );
  687.         printh( (ULONG)segment );
  688.         endout();
  689.         }
  690.     goout();
  691.     return;
  692. }
  693.  
  694.  
  695. /*****   Nuova routine CreateProc   *****/
  696. struct MsgPort * __saveds __asm newcreateproc( register __d1 char *name, register __d2 long pri, register __d3 BPTR segment, register __d4 long stacksize )
  697. {
  698.     struct MsgPort    *ret;
  699.  
  700.     goin();
  701.     fresetvect( CREATEPROCV );
  702.     ret=CreateProc( name, pri, segment, stacksize);
  703.     fsetvect( CREATEPROCV );
  704.     if( canoutput() && (EVERYTIME || ret==DOSFALSE) )
  705.         {
  706.         initout( "CreateProc");
  707.         if( VERBOSE )
  708.             prints( "Name: " );
  709.         printname( name );
  710.         if( VERBOSE )
  711.             {
  712.             newline();
  713.             prints( "Priority: " );
  714.             printd( pri );
  715.             newline();
  716.             prints( "Segment: " );
  717.             printh( (ULONG)segment );
  718.             newline();
  719.             prints( "StackSize: " );
  720.             printd( stacksize );
  721.             newline();
  722.             prints( returntext );
  723.             printh( (ULONG)ret );
  724.             }
  725.         endout();
  726.         }
  727.     goout();
  728.     return( ret );
  729. }
  730.  
  731.  
  732. /*****   Nuova routine Exit   *****/
  733. void __saveds __asm newexit( register __d1 long returncode )
  734. {
  735.     struct IntuiMessage    *msg;
  736.  
  737.     goin();
  738.     if( canoutput() && (EVERYTIME || returncode) )
  739.         {
  740.         initout( "Exit");
  741.         if( VERBOSE )
  742.             prints( "ReturnCode: " );
  743.         printd( returncode );
  744.         endout();
  745.         }
  746.     fresetvect( EXITV );
  747.         /*   Facciamo in modo di far eseguire fsetvect( EXITV ) a SPY   */
  748.     if( (msg=AllocMem( sizeof(struct IntuiMessage), MEMF_CLEAR | MEMF_PUBLIC ))==NULL )
  749.         status( "INTERNAL ERROR #20" );
  750.         /*   Class==NULL   */
  751.     SetTaskPri( FindTask(NULL), SPYPRIORITY+1 );        /*   Assicuriamoci di non essere interrotti   */
  752.     PutMsg( window->UserPort, (struct Message *)msg );
  753.     goout();
  754.     Exit( returncode );
  755. }
  756.  
  757. /*****   Nuova routine IoErr   *****/
  758. long __saveds __asm newioerr( void )
  759. {
  760.     long    ret;
  761.  
  762.     goin();
  763.     fresetvect( IOERRV );
  764.     ret=IoErr();
  765.     fsetvect( IOERRV );
  766.     if( canoutput() && (EVERYTIME) )
  767.         {
  768.         initout( "IoErr");
  769.         if( VERBOSE )
  770.             prints( returntext );
  771.         printd( ret );
  772.         endout();
  773.         }
  774.     goout();
  775.     return( ret );
  776. }
  777.  
  778. /*****   Inizio routines EXEC   *****/
  779.  
  780. /*****   Nuova routine AllocMem   *****/
  781. void * __saveds __asm newallocmem( register __d0 long size, register __d1 long requirements )
  782. {
  783.     void    *ret;
  784.  
  785.     goin();
  786.     fresetvect( ALLOCMEMV );
  787.     ret=AllocMem( size, requirements );
  788.     if( canoutput() && (ret==NULL) )        /*   Solo se fallisce!   */
  789.         {
  790.         initout( "AllocMem");
  791.         if( VERBOSE )
  792.             prints( "Size: " );
  793.         printd( size );
  794.         if( VERBOSE )
  795.             {
  796.             newline();
  797.             prints( "Requirements: " );
  798.             printd( requirements );
  799.             newline();
  800.             prints( returntext );
  801.             printh( (ULONG)ret );
  802.             }
  803.         endout();
  804.         }
  805.     fsetvect( ALLOCMEMV );        /*   Qui per evitare chiamate a spirale infinita   */
  806.     goout();
  807.     return( ret );
  808. }
  809.  
  810.  
  811. /*****   Nuova routine OpenDevice   *****/
  812. long __saveds __asm newopendevice( register __a0 char *name, register __d0 long unit, register __a1 struct IORequest *iorequest, register __d1 long flags )
  813. {
  814.     long    ret;
  815.  
  816.     goin();
  817.     fresetvect( OPENDEVICEV );
  818.     ret=OpenDevice( name, unit, iorequest, flags );
  819.     fsetvect( OPENDEVICEV );
  820.     if( canoutput() && (EVERYTIME || ret!=NULL) )
  821.         {
  822.         initout( "OpenDevice");
  823.         if( VERBOSE )
  824.             prints( "Device: " );
  825.         printname( name );
  826.         if( VERBOSE )
  827.             {
  828.             newline();
  829.             prints( "Unit: " );
  830.             printd( unit );
  831.             newline();
  832.             prints( "IORequest: " );
  833.             printh( (ULONG)iorequest );
  834.             newline();
  835.             prints( "Flags: " );
  836.             printd( flags );
  837.             newline();
  838.             prints( returntext );
  839.             printh( (ULONG)ret );
  840.             }
  841.         endout();
  842.         }
  843.     goout();
  844.     return( ret );
  845. }
  846.  
  847.  
  848. /*****   Nuova routine CloseDevice   *****/
  849. void __saveds __asm newclosedevice( register __a1 struct IORequest *iorequest )
  850. {
  851.     UBYTE    devname[TEMPLEN];
  852.  
  853.     goin();
  854.     COPYTEMP( devname, iorequest->io_Device->dd_Library.lib_Node.ln_Name );
  855.     fresetvect( CLOSEDEVICEV );
  856.     CloseDevice( iorequest );
  857.     fsetvect( CLOSEDEVICEV );
  858.     if( canoutput() && (EVERYTIME) )
  859.         {
  860.         initout( "CloseDevice");
  861.         if( VERBOSE )
  862.             prints( "IORequest: " );
  863.         printh( (ULONG)iorequest );
  864.         printpname( devname );
  865.         endout();
  866.         }
  867.     goout();
  868.     return;
  869. }
  870.  
  871.  
  872. /*****   Nuova routine AddDevice   *****/
  873. void __saveds __asm newadddevice( register __a1 struct Device *device )
  874. {
  875.     goin();
  876.     fresetvect( ADDDEVICEV );
  877.     AddDevice( device );
  878.     fsetvect( ADDDEVICEV );
  879.     if( canoutput() && (EVERYTIME) )
  880.         {
  881.         initout( "AddDevice");
  882.         if( VERBOSE )
  883.             prints( "Device: " );
  884.         printh( (ULONG)device );
  885.         printpname( device->dd_Library.lib_Node.ln_Name );
  886.         endout();
  887.         }
  888.     goout();
  889.     return;
  890. }
  891.  
  892.  
  893. /*****   Nuova routine OpenLibrary   *****/
  894. struct Library * __saveds __asm newopenlibrary( register __a1 char *name, register __d0 long version )
  895. {
  896.     struct Library    *ret;
  897.  
  898.     goin();
  899.     fresetvect( OPENLIBRARYV );
  900.     ret=OpenLibrary( name, version );
  901.     fsetvect( OPENLIBRARYV );
  902.     if( canoutput() && (EVERYTIME || ret==NULL) )
  903.         {
  904.         initout( "OpenLibrary");
  905.         if( VERBOSE )
  906.             prints( "Library: " );
  907.         printname( name );
  908.         if( VERBOSE )
  909.             {
  910.             newline();
  911.             prints( "Version: " );
  912.             printd( version );
  913.             newline();
  914.             prints( returntext );
  915.             printh( (ULONG)ret );
  916.             }
  917.         endout();
  918.         }
  919.     goout();
  920.     return( ret );
  921. }
  922.  
  923.  
  924. /*****   Nuova routine OldOpenLibrary   *****/
  925. struct Library * __saveds __asm newoldopenlibrary( register __a1 char *name )
  926. {
  927.     struct Library    *ret;
  928.  
  929.     goin();
  930.     fresetvect( OLDOPENLIBRARYV );
  931.     ret=OldOpenLibrary( name );
  932.     fsetvect( OLDOPENLIBRARYV );
  933.     if( canoutput() && (EVERYTIME || ret==NULL) )
  934.         {
  935.         initout( "OldOpenLibrary");
  936.         if( VERBOSE )
  937.             prints( "Library: " );
  938.         printname( name );
  939.         if( VERBOSE )
  940.             {
  941.             newline();
  942.             prints( returntext );
  943.             printh( (ULONG)ret );
  944.             }
  945.         endout();
  946.         }
  947.     goout();
  948.     return( ret );
  949. }
  950.  
  951.  
  952. /*****   Nuova routine CloseLibrary   *****/
  953. void __saveds __asm newcloselibrary( register __a1 struct Library *library )
  954. {
  955.     UBYTE    libname[TEMPLEN];
  956.  
  957.     goin();
  958.     COPYTEMP( libname, library->lib_Node.ln_Name );
  959.     fresetvect( CLOSELIBRARYV );
  960.     CloseLibrary( library );
  961.     fsetvect( CLOSELIBRARYV );
  962.     if( canoutput() && (EVERYTIME) )
  963.         {
  964.         initout( "CloseLibrary");
  965.         if( VERBOSE )
  966.             prints( "Library: " );
  967.         printh( (ULONG)library );
  968.         printpname( libname );
  969.         endout();
  970.         }
  971.     goout();
  972.     return;
  973. }
  974.  
  975.  
  976. /*****   Nuova routine AddLibrary   *****/
  977. void __saveds __asm newaddlibrary( register __a1 struct Library *library )
  978. {
  979.     goin();
  980.     fresetvect( ADDLIBRARYV );
  981.     AddLibrary( library );
  982.     fsetvect( ADDLIBRARYV );
  983.     if( canoutput() && (EVERYTIME) )
  984.         {
  985.         initout( "AddLibrary");
  986.         if( VERBOSE )
  987.             prints( "Library: " );
  988.         printh( (ULONG)library );
  989.         printpname( library->lib_Node.ln_Name );
  990.         endout();
  991.         }
  992.     goout();
  993.     return;
  994. }
  995.  
  996.  
  997. /*****   Nuova routine OpenResource   ****/
  998. struct Resource * __saveds __asm newopenresource( register __a1 char *name )
  999. {
  1000.     struct    Resource    *ret;
  1001.  
  1002.     goin();
  1003.     fresetvect( OPENRESOURCEV );
  1004.     ret=OpenResource( name );
  1005.     fsetvect( OPENRESOURCEV );
  1006.     if( canoutput() && (EVERYTIME || ret==NULL) )
  1007.         {
  1008.         initout( "OpenResource");
  1009.         if( VERBOSE )
  1010.             prints( "Resource: " );
  1011.         printname( name );
  1012.         if( VERBOSE )
  1013.             {
  1014.             newline();
  1015.             prints( returntext );
  1016.             printh( (ULONG)ret );
  1017.             }
  1018.         endout();
  1019.         }
  1020.     goout();
  1021.     return( ret );
  1022. }
  1023.  
  1024.  
  1025. /*****   Nuova routine AddResource   *****/
  1026. void __saveds __asm newaddresource( register __a1 struct Resource *resource )
  1027. {
  1028.     goin();
  1029.     fresetvect( ADDRESOURCEV );
  1030.     AddResource( resource );
  1031.     fsetvect( ADDRESOURCEV );
  1032.     if( canoutput() && (EVERYTIME) )
  1033.         {
  1034.         initout( "AddResource");
  1035.         if( VERBOSE )
  1036.             prints( "Resource: " );
  1037.         printh( (ULONG)resource );
  1038.         printpname( ((struct Node *)resource)->ln_Name );
  1039.         endout();
  1040.         }
  1041.     goout();
  1042.     return;
  1043. }
  1044.  
  1045.  
  1046. /*****   Nuova routine FindPort   ****/
  1047. struct MsgPort * __saveds __asm newfindport( register __a1 char *name )
  1048. {
  1049.     struct    MsgPort    *ret;
  1050.  
  1051.     goin();
  1052.     fresetvect( FINDPORTV );
  1053.     ret=FindPort( name );
  1054.     fsetvect( FINDPORTV );
  1055.     if( canoutput() && (EVERYTIME || ret==NULL) )
  1056.         {
  1057.         initout( "FindPort");
  1058.         if( VERBOSE )
  1059.             prints( "PortName: " );
  1060.         printname( name );
  1061.         if( VERBOSE )
  1062.             {
  1063.             newline();
  1064.             prints( returntext );
  1065.             printh( (ULONG)ret );
  1066.             }
  1067.         endout();
  1068.         }
  1069.     goout();
  1070.     return( ret );
  1071. }
  1072.  
  1073.  
  1074. /*****   Nuova routine AddPort   *****/
  1075. void __saveds __asm newaddport( register __a1 struct MsgPort *msgport )
  1076. {
  1077.     goin();
  1078.     fresetvect( ADDPORTV );
  1079.     AddPort( msgport );
  1080.     fsetvect( ADDPORTV );
  1081.     if( canoutput() && (EVERYTIME) )
  1082.         {
  1083.         initout( "AddPort");
  1084.         if( VERBOSE )
  1085.             prints( "MsgPort: " );
  1086.         printh( (ULONG)msgport );
  1087.         printpname( msgport->mp_Node.ln_Name );
  1088.         if( strcmp( msgport->mp_Node.ln_Name, "IDCMP" )==0 )
  1089.             cannotwait=TRUE;
  1090.         endout();
  1091.         }
  1092.     goout();
  1093.     return;
  1094. }
  1095.  
  1096.  
  1097. /*****   Nuova routine FindSemaphore   ****/
  1098. struct SignalSemaphore * __saveds __asm newfindsemaphore( register __a0 char *name )
  1099. {
  1100.     struct    SignalSemaphore    *ret;
  1101.  
  1102.     goin();
  1103.     fresetvect( FINDSEMAPHOREV );
  1104.     ret=FindSemaphore( name );
  1105.     fsetvect( FINDSEMAPHOREV );
  1106.     if( canoutput() && (EVERYTIME || ret==NULL) )
  1107.         {
  1108.         initout( "FindSemaphore");
  1109.         if( VERBOSE )
  1110.             prints( "SemaphoreName: " );
  1111.         printname( name );
  1112.         if( VERBOSE )
  1113.             {
  1114.             newline();
  1115.             prints( returntext );
  1116.             printh( (ULONG)ret );
  1117.             }
  1118.         endout();
  1119.         }
  1120.     goout();
  1121.     return( ret );
  1122. }
  1123.  
  1124.  
  1125. /*****   Nuova routine AddSemaphore   *****/
  1126. void __saveds __asm newaddsemaphore( register __a0 struct SignalSemaphore *ss )
  1127. {
  1128.     goin();
  1129.     fresetvect( ADDSEMAPHOREV );
  1130.     AddSemaphore( ss );
  1131.     fsetvect( ADDSEMAPHOREV );
  1132.     if( canoutput() && (EVERYTIME) )
  1133.         {
  1134.         initout( "AddSemaphore");
  1135.         if( VERBOSE )
  1136.             prints( "SignalSemaphore: " );
  1137.         printh( (ULONG)ss );
  1138.         printpname( ss->ss_Link.ln_Name );
  1139.         endout();
  1140.         }
  1141.     goout();
  1142.     return;
  1143. }
  1144.  
  1145.  
  1146. /*****   Nuova routine FindName   ****/
  1147. struct Node * __saveds __asm newfindname( register __a0 struct List *list, register __a1 char *name )
  1148. {
  1149.     struct    Node    *ret;
  1150.  
  1151.     goin();
  1152.     fresetvect( FINDNAMEV );
  1153.     ret=FindName( list, name );
  1154.     fsetvect( FINDNAMEV );
  1155.     if( canoutput() && (EVERYTIME || ret==NULL) )
  1156.         {
  1157.         initout( "FindName" );
  1158.         if( VERBOSE )
  1159.             prints( "Name: " );
  1160.         printname( name );
  1161.         if( VERBOSE )
  1162.             {
  1163.             newline();
  1164.             prints( "List: " );
  1165.             printh( (ULONG)list );        /*   Occorre stampare type   */
  1166.             newline();
  1167.             prints( returntext );
  1168.             printh( (ULONG)ret );
  1169.             }
  1170.         endout();
  1171.         }
  1172.     goout();
  1173.     return( ret );
  1174. }
  1175.  
  1176.  
  1177. /**********   Fine delle nuove routines  **********/
  1178.