home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / System / ReqAttack / ReqReplacers / reqlog.e < prev    next >
Encoding:
Text File  |  2001-02-23  |  3.0 KB  |  73 lines

  1. /* Example request saver. This program is very simple and should probably be
  2.    made more OS compatible (I mean the ReadArgs() function).
  3.  
  4.    IMPORTANT: To protect ReqOFF againts going into infinitive loop (when your
  5.    requester replacer calls EasyRequestArgs() with same TITLE and/or TEXT
  6.    as the original requester) you should add a single space as a first byte
  7.    of title string, or simply change it to other title which will not qualify
  8.    to be patched by your program again and again and again...
  9.  
  10.    IMPORTANT: the easystruct you receive as 0x12345678 (the last argument)
  11.    contains the bodytext preprocessed by RawDoFmt. If you wan't to filter
  12.    the requester you should exit with 127 (ENDPROC REQATTACK_DISPLAYREQ/
  13.    RETURN REQATTACK_DISPLAYREQ). This will cause the requester to open as a
  14.    normal requester (not ReqOFF'ed).
  15.  
  16.    IN THIS CASE we don't exit with 127 because we wan't to filter the result!
  17. */
  18.  
  19. MODULE 'dos/dos','jaca/replacer','intuition/intuition'
  20.  
  21. DEF pos,newtitle:PTR TO LONG,exit=0,fh,file[101]:STRING
  22. DEF re:PTR TO replacerdata
  23.  
  24. PROC main()
  25.   IF StrCmp(arg,'"',1)                ->  the 1st arg is log file name
  26.     pos:=InStr(arg,'"',1)             ->  which has to be specified in
  27.     StrCopy(file,arg+1,pos-1)         ->  RAPrefsMUI
  28.   ELSE
  29.     pos:=InStr(arg,' ',1)
  30.     StrCopy(file,arg,pos)             ->  now the file variable contains
  31.   ENDIF                               ->  the file name (without quotas)
  32.  
  33.  
  34.   pos:=InStr(arg,'0x',0)              ->  replace all 0x with ' $'
  35.   arg[pos]:=$20;arg[pos+1]:=$24       ->  Val() needs hexadecimal numbers...
  36.   re:=Val(arg+pos,0)                  ->  (get the value)
  37.                                       ->  ...to be preceded by '$'
  38.  
  39.   IF newtitle:=New(StrLen(re.easystr.title)+2)->  title MUST be preceded by a space
  40.                                       ->  we do not want an infinitive loop!
  41.     StringF(newtitle,' \s',re.easystr.title)
  42.                                       ->  now call the requester...
  43.     exit:=EasyRequestArgs(0,[20,0,newtitle,re.easystr.textformat,re.easystr.gadgetformat],0,0)
  44.                                       ->  and add info to the log file...
  45.     IF fh:=Open(file,MODE_READWRITE)
  46.       Seek(fh,0,OFFSET_END)           ->  skip to EOF
  47.  
  48. /* Now we dont need the file name anymore, so we can use it to prepare
  49.    the text to write in log file... */
  50.  
  51.         MidStr(file,re.easystr.title,0,20);StringF(file,'TITLE:\s ',file);
  52.         Fputs(fh,file)                ->  write the title...
  53.  
  54.         MidStr(file,re.easystr.textformat,0,30);StringF(file,'TEXT:\s ',file);
  55.         removenextline();Fputs(fh,file)->  write the text...
  56.  
  57.         MidStr(file,re.easystr.gadgetformat,0,15);StringF(file,'BUTT:\s EXIT:\d\n',file,exit);
  58.         Fputs(fh,file)->  write the button info and exit #...
  59.  
  60.       Close(fh)
  61.     ENDIF
  62.   ENDIF
  63. ENDPROC exit
  64.  
  65. /* This procedure checks all bytes in string for $0a (next line) and replaces
  66.    it with $20 - space */
  67. PROC removenextline()
  68. DEF no
  69.   FOR no:=0 TO StrLen(file)
  70.     IF file[no]=$0a;file[no]:=$20;ENDIF
  71.   ENDFOR
  72. ENDPROC
  73.