home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 549b.lha / M2P_v1.0_sources / source.lzh / Args.def next >
Encoding:
Modula Definition  |  1991-08-10  |  3.3 KB  |  60 lines

  1. (*======================================================================*)
  2. (*                          Support routines                            *)
  3. (*======================================================================*)
  4. (*      Version: 1.00           Author : Dennis Brueni                  *)
  5. (*      Date   : 07-23-91       Changes: Original                       *)
  6. (*======================================================================*)
  7.  
  8. DEFINITION MODULE Args;
  9.  
  10. CONST MaxArg     = 127;
  11.       MaxArgSize = 511;
  12.  
  13. (*----------------------------------------------------------------------*)
  14. (* 'argc' indicates the number of arguments parsed so far. 'argv' is an *)
  15. (* array of pointers to strings. These strings are the actual           *)
  16. (* arguments. argv[0] points to the current program's filename.         *)
  17. (*----------------------------------------------------------------------*)
  18.  
  19. VAR argc : CARDINAL;
  20.     argv : ARRAY [0..MaxArg] OF POINTER TO ARRAY [0..MaxArgSize] OF CHAR;
  21.  
  22. (*----------------------------------------------------------------------*)
  23. (* ADDARGS    - This procedure will parse a string and add the args     *)
  24. (*              found in it to the 'argv' array, and increment 'argc'   *)
  25. (*              as appropriate.  A special charactoristic of this is    *)
  26. (*              that special charactors !,#,$,%,&,',(,),*,+,comma,- are *)
  27. (*              parsed out into separate one-charactor strings.  This   *)
  28. (*              simplifies the writing of parsers built on top of this  *)
  29. (*              module.                                                 *)
  30. (*            - As usual, Inter-argument spacing and tabs are removed.  *)
  31. (*            - If an argument is contained in double quotes, the       *)
  32. (*              quotes are stripped away.  A double quote may be placed *)
  33. (*              in an argument by using \"                              *)
  34. (*            - Storage for copies of the arguments is dynamically      *)
  35. (*              allocated.                                              *)
  36. (*                                                                      *)
  37. (* EXAMPLE      string = 'Wow!,this is "great""\""+2                    *)
  38. (*              argv[oldargc+0] = '                                     *)
  39. (*              argv[oldargc+1] = Wow                                   *)
  40. (*              argv[oldargc+2] = !                                     *)
  41. (*              argv[oldargc+3] = ,                                     *)
  42. (*              argv[oldargc+4] = this                                  *)
  43. (*              argv[oldargc+5] = is                                    *)
  44. (*              argv[oldargc+6] = great                                 *)
  45. (*              argv[oldargc+7] = "                                     *)
  46. (*              argv[oldargc+8] = +                                     *)
  47. (*              argv[oldargc+9] = 2                                     *)
  48. (*              argc = oldargc+10                                       *)
  49. (*----------------------------------------------------------------------*)
  50.  
  51. PROCEDURE AddArgs(string: ARRAY OF CHAR);
  52.  
  53. (*----------------------------------------------------------------------*)
  54. (* TERMPROC     Cleanup code (reply to WBMsg for Amiga).                *)
  55. (*----------------------------------------------------------------------*)
  56.  
  57. PROCEDURE TermProc;
  58.  
  59. END Args.
  60.