home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PWAECJ15.ZIP / JOIN.PPS < prev    next >
Text File  |  1995-04-09  |  13KB  |  395 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; Conference Join v1.5
  3. ; 1.2 Written by Drew [PWA] / 1.5 Revised by Nemesis
  4. ; Source last updated 04-09-95
  5. ;
  6. ; Written in PPL 3.0 for PCBoard 15.2+ only.
  7. ;
  8. ; Description: Generates a "menu" of conferences a user can join.  If a user
  9. ; does not have access to a conference, that conference never shows up in the
  10. ; list. :)
  11. ;
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13. ; procedure & function declarations
  14. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  15. declare procedure Initialize()
  16. declare procedure Lightbar()
  17. declare procedure PrintConfs()
  18. declare procedure ShowHeader()
  19. declare function BuildConfInfo(int i, word recsize) integer
  20. declare procedure PrintLineForConf(int i, string shortname, int offset)
  21. declare procedure ShowFooter()
  22. declare procedure RestoreOldConf()
  23.  
  24. *$USEFUNCS
  25.  
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27. ; global variables
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. string cnames@        ; cnames.@@@
  30. string cnamesa        ; cnames.add
  31. string pattern        ; line to print for conferences
  32. string lbprompt       ; prompt to print for lightbar options
  33. string hilightcolor   ; color code to use for lightbar
  34. integer cur            ; current conference being printed by PrintConf
  35. integer startline     ; Y position of first conference on screen
  36. integer numtoprint    ; max numb of conf's to print per screen
  37. integer oldconf       ; stores user's conf num prior to running this ppe
  38. integer printed       ; stores number of lines printed on current page
  39. word recordsize
  40.  
  41.  
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  43. ; main body of program
  44. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  45. begin
  46.     Initialize()
  47.     PrintConfs()
  48.     RestoreOldConf()
  49. end
  50.  
  51.  
  52.  
  53. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  54. ; restores to the user's previous conference before running this ppe
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56. procedure RestoreOldConf()
  57.     lastin oldconf
  58. endproc
  59.  
  60.  
  61. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  62. ; Lightbar for Conference Selection
  63. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  64. procedure Lightbar()
  65.     string response,saveline
  66.     string Shortname
  67.     int optnum
  68.     int TempCur
  69.     int Reqlev
  70.     boolean PubConf
  71.     boolean done
  72.  
  73.     print lbprompt
  74.     optnum = 1
  75.     done = false
  76.     while (!done) do
  77.  
  78.        saveline = scrtext(1,optnum+startline,79,true)
  79.        ansipos 1,optnum + Startline
  80.        print hilightcolor+scrtext(1,optnum+startline,79,false)+"@X01"
  81.        ansipos 1,optnum + Startline
  82.        response = ""
  83.        
  84.        while (!done) do
  85.           response = upper(inkey())
  86.           select case (response)
  87.              case "9","3","S","X","8","2","A","Z","Q","M",CHR(13),"UP","DOWN","PGUP","PGDN"
  88.                 done=true
  89.           end select
  90.        end while
  91.        done = false
  92.  
  93.        select case (response)
  94.           case "A","UP","8"
  95.              ansipos 1,optnum + startline
  96.              print saveline
  97.              optnum = optnum - 1
  98.              if (optnum = 0) optnum = printed
  99.           case "Z","DOWN","2"
  100.              ansipos 1,optnum + startline
  101.              print saveline
  102.              optnum = optnum + 1
  103.              if (optnum = printed + 1) then
  104.                if (printed = numtoprint) done = true
  105.                optnum=1
  106.              endif
  107.           case "PGDN","3","X"
  108.             done = true
  109.             ansipos 1 , printed + startline + 1
  110.           case "PGUP","9","S"
  111.             TempCur = S2I(Left(scrtext(1,1+startline,79,false),4),10) - 1
  112.             Printed = 0
  113.             While ((TempCur > -1) & (Printed < NumtoPrint)) do
  114.              Fseek 1, Recordsize * TempCur + 2, Seek_Set
  115.              fread 1, shortname, 14
  116.              if (strip(shortname, " ") != "") then
  117.              fread 1, pubconf, 1
  118.              if (pubconf = TRUE) then
  119.                fseek 1, 5, seek_cur
  120.                fread 1, reqlev, 2
  121.                if (u_sec >= reqlev) then
  122.                 Printed = Printed + 1
  123.                end if
  124.              end if
  125.              end if
  126.              TempCur = TempCur - 1
  127.             end while
  128.             Cur = TempCur
  129.             Done = true
  130.           case "M"
  131.              RestoreOldConf()
  132.              ansipos 1, u_pagelen
  133.              stop
  134.           case "Q", "ESCAPE"
  135.               RestoreOldConf()
  136.               ansipos 1, u_pagelen
  137.               kbdstuff chr(13)
  138.               end
  139.           case chr(13)
  140.              if (optnum < printed + 1) then
  141.               kbdstuff Left(scrtext(1,optnum + startline,79,false),4)+chr(13)
  142.               ansipos 1, u_pagelen
  143.               stop
  144.              else
  145.               done = true
  146.              endif
  147.     end select
  148.  
  149.     end while
  150.  
  151. endproc
  152.  
  153.  
  154. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  155. ; Prints the conferences
  156. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  157. procedure PrintConfs()
  158.     int i
  159.  
  160.     getuser
  161.  
  162.     printed = 0
  163.     fopen 1, cnames@, o_rd, s_dn
  164.     fopen 2, cnamesa, o_rd, s_dn
  165.  
  166.     fread 1, recordsize, 2
  167.  
  168.     ShowHeader()
  169.     startline = gety() - 1
  170.     Cur = 0
  171.     While (Cur <= hiconfnum()) do
  172.         printed = printed + BuildConfInfo(Cur, recordsize)
  173.         if ((printed == numtoprint) | (Cur=hiconfnum())) then
  174.           ShowFooter()
  175.           LightBar()
  176.           printed = 0
  177.           ShowHeader()
  178.         endif
  179.         Cur = Cur + 1
  180.     end while
  181.  
  182.     fclose 1
  183.     fclose 2
  184. endproc
  185.  
  186.  
  187. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  188. ; checks whether or not to print the current conference.  returns 1 (true)
  189. ; if the conference is available to the user, 0 (false) if not.
  190. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  191. function BuildConfInfo(int confnum, word recordsize) integer
  192.     boolean pubconf
  193.     string shortname
  194.     int reqlev, offset
  195.  
  196.     fseek 1, recordsize * Cur+2, Seek_Set
  197.     fread 1, shortname, 14
  198.  
  199.     ; first check if the conference even has a name or not.  if it
  200.     ; has no name, then it doesn't exist
  201.     ;
  202.     if (strip(shortname, " ") != "") then
  203.         ; check if it's a public conference.  if so, then check sec lev;
  204.         ; otherwise it's private, so check if user is reg'ed in the conf
  205.         ;
  206.         fread 1, pubconf, 1
  207.         if (pubconf = TRUE) then
  208.             fseek 1, 5, seek_cur
  209.             fread 1, reqlev, 2
  210.  
  211.             ; check sec level
  212.             if (u_sec >= reqlev) then
  213.                 PrintLineForConf(confnum, shortname, 0)
  214.                 BuildConfInfo = 1
  215.             else
  216.                 fseek 1, recordsize - 22, seek_cur
  217.                 BuildConfInfo = 0
  218.             endif
  219.         else
  220.             if (confreg(confnum)) then
  221.                 PrintLineForConf(confnum, shortname, 7)
  222.                 BuildConfInfo = 1
  223.             else
  224.                 fseek 1, (recordsize - 14) - 1, seek_cur
  225.                 BuildConfInfo = 0
  226.             endif
  227.         endif
  228.     else
  229.         ; if we're here, then it's a "blank" conference, so skip to the
  230.         ; next conference.  (recordsize - 14) is the conf record size minus
  231.         ; the conf name (since we've already read the name).
  232.         ;
  233.         fseek 1, recordsize - 14, seek_cur
  234.         BuildConfInfo = 0
  235.     endif
  236. endfunc
  237.  
  238.  
  239. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  240. ; prints a line for the current conference.  "offset" here can be of two
  241. ; values: 0 or 7.  0 indicates we've already read the required security
  242. ; level of a conference, 7 indicates we haven't.  we jump forward this many
  243. ; bytes to start getting the other information (msgs, doors, etc)
  244. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  245. procedure PrintLineForConf(int confnum, string shortname, int offset)
  246.     string newpattern, tmpstr1
  247.  
  248.     lastin confnum
  249.     newpattern = pattern
  250.  
  251.     ; conference number
  252.     ;
  253.     newpattern = replacestr(newpattern, "%N%", string(confnum))
  254.  
  255.     ; gets the long name from cnamesa.  this is a somewhat retarded way to do
  256.     ; it since for long names, only characters after the 14th character are
  257.     ; stored in cnames.add.  the first 14 characters are from pcb 15.1, where
  258.     ; it's still stored in cnames.@@@.  hence, we pass in the first 14 chars
  259.     ; as a parameter since we read it already, then we grab whatever is left
  260.     ; from cnames.add and concatenate the two.  this "method" is from
  261.     ; cnfn.pps, clark dev's own ppe used on salt air.
  262.     ;
  263.     fseek 2, confnum * 256 + 208, SEEK_SET
  264.     fread 2, tmpstr1, 48
  265.     tmpstr1 = shortname + tmpstr1
  266.     newpattern = replacestr(newpattern, "%C%", string(tmpstr1))
  267.  
  268.     ; msgs file
  269.     ;
  270.     fseek 1, offset + 5, seek_cur
  271.     fread 1, tmpstr1, 32
  272.     if (tmpstr1 == "") then
  273.         newpattern = replacestr(newpattern, "%M%", "No")
  274.     else
  275.         newpattern = replacestr(newpattern, "%M%", "Yes")
  276.     endif
  277.  
  278.     ; doors.lst
  279.     ; 96 + 30 + 27 + 29 + 26 + 29 = 237
  280.     ;
  281.     fseek 1, 237, seek_cur
  282.     fread 1, tmpstr1, 33
  283.     if (tmpstr1 == "") then
  284.         newpattern = replacestr(newpattern, "%D%", "No")
  285.     else
  286.         newpattern = replacestr(newpattern, "%D%", "Yes")
  287.     endif
  288.  
  289.     ; blt.lst
  290.     ;
  291.     fseek 1, 29, seek_cur
  292.     fread 1, tmpstr1, 33
  293.     if (tmpstr1 == "") then
  294.         newpattern = replacestr(newpattern, "%B%", "No")
  295.     else
  296.         newpattern = replacestr(newpattern, "%B%", "Yes")
  297.     endif
  298.  
  299.     ; script.lst
  300.     ;
  301.     fseek 1, 29, seek_cur
  302.     fread 1, tmpstr1, 33
  303.     if (tmpstr1 == "") then
  304.         newpattern = replacestr(newpattern, "%S%", "No")
  305.     else
  306.         newpattern = replacestr(newpattern, "%S%", "Yes")
  307.     endif
  308.  
  309.     ; dir.lst for file directories existence
  310.     ;
  311.     fseek 1, 62, seek_cur
  312.     fread 1, tmpstr1, 33
  313.     if (tmpstr1 == "") then
  314.         newpattern = replacestr(newpattern, "%F%", "No")
  315.     else
  316.         newpattern = replacestr(newpattern, "%F%", "Yes")
  317.     endif
  318.  
  319.     ; high message number
  320.     ;
  321.     if (instr(newpattern, "%HM%")) then
  322.         newpattern = replacestr(newpattern, "%HM%", himsgnum())
  323.     endif
  324.  
  325.     ; last message number read
  326.     ;
  327.     if (instr(newpattern, "%LR%")) then
  328.         newpattern = replacestr(newpattern, "%LR%", u_lmr(confnum))
  329.     endif
  330.  
  331.     lastin oldconf
  332.     println newpattern
  333. endproc
  334.  
  335.  
  336.  
  337. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  338. ; shows the footer file
  339. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  340. procedure ShowFooter()
  341.     if (exist(ppepath() + "JOIN.BOT")) then
  342.         dispfile ppepath() + "JOIN.BOT", DEFS
  343.     endif
  344. endproc
  345.  
  346.  
  347. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  348. ; shows the header file
  349. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  350. procedure ShowHeader()
  351.     if (exist(ppepath() + "JOIN.TOP")) then
  352.         dispstr "%" + ppepath() + "JOIN.TOP"
  353.     endif
  354. endproc
  355.  
  356.  
  357.  
  358. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  359. ; initialize
  360. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  361. procedure Initialize()
  362.     if (exist(ppepath() + "JOIN.CFG")) then
  363.         cnames@ = readline(pcbdat(), 31) + ".@@@"
  364.         if (!exist(cnames@)) then
  365.             println cnames@ + " does not exist.  Bad path in PCBOARD.DAT"
  366.             end
  367.         endif
  368.  
  369.         cnamesa = readline(pcbdat(), 31) + ".ADD"
  370.         if (!exist(cnamesa)) then
  371.             println cnamesa + " does not exist.  Bad path in PCBOARD.DAT"
  372.             end
  373.         endif
  374.     else
  375.         println ppepath() + "JOIN.CFG does not exist!  Exiting."
  376.         end
  377.     endif
  378.  
  379.     numtoprint = s2i(readline(ppepath() + "JOIN.CFG", 1), 10)
  380.  
  381.     pattern = readline(ppepath() + "JOIN.CFG", 2)
  382.  
  383.     lbprompt = readline(ppepath() + "JOIN.CFG", 3)
  384.  
  385.     hilightcolor = readline(ppepath() + "JOIN.CFG", 4)
  386.  
  387.     fclose -1
  388.  
  389.     ; we need to store the user's conf num they were in prior to this ppe
  390.     ; since we use "lastin" to change the active conf num in order to find
  391.     ; out the number of msgs per conf.
  392.     ;
  393.     oldconf = curconf()
  394. endproc
  395.