home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1999-10-06 | 57.7 KB | 1,622 lines
'T:HMIFORUM.EBS for CompuServe ' VA 4.01 release Declare Function ParseString(args As String, delim As String) As String Declare Function FileName$(fullpath As String) Declare Sub AddToMsgFile(SourceFileName as String) Declare Function QueueFile(service As String, sfilename As String, queueflags As Long) As Boolean Declare Function MyDate$ Declare Function StartMessageDownload(id As String, forum As String, sections As String, markunread As Boolean) As Integer Declare Sub SearchMessages(searchtype As Integer, searchstring As String, bodies As Boolean, rootsonly As Boolean, unreadonly As Boolean, lastdays As String) Declare Sub ReportSuccess(msg As String) Declare Function ForumName(ByVal forum As String) As String Declare Function FullErrorMessage() As String Declare Sub ReadNumber(id As String, forum As String, number As String) Declare Sub LogResult(result As String) Declare Sub RecordFileDownload(topic As String, fname As String) Declare Function UniqueFileName$() Declare Function FileUrl(fn As String) As String Declare Sub AsciiListHeldMessages(id As String, forum As String, sections As String) Declare Function ParseSectionList(ByVal sect As String, ByVal validsects As Long, _ ByRef count As Integer) As Long Declare Sub SaveMessage(hdr As FAPMSGHEADER, body As String) Declare Sub WriteLibraryMessage(forum As String, filedesc As FAPFILEDESCRIPTION, downloaded As String) Declare Function MakeDateString(s As HMITIMESTAMP) As String Declare Function GetFileType(i As Integer) As String Declare Function CheckCache(pagetype As String, npage As String, pversion As Long) As String Declare Sub UpdateCache(pagetype As String, npage As String, pversion As Long, newpage As String) Declare Function CompareDates(d1 As HMIDATE, d2 As HMIDATE) As Integer Declare Sub StartCapturing(pseudoforum As String, title As String, formatted As Boolean) Declare Sub FinishCapturing Declare Function SectionNumber(ByVal section As String) Declare Sub AsciiUserLog(id As String, forum As String) Declare Sub FinishMessageDownload(id As String) Declare Sub NewSearchLibrary(id As String, forum As String, catalog As String, _ ssections As String, filename As String, uploadby As String, _ age As String, accesscount As String, keywords As String, _ title As String, description As String, full As String, _ replace As String) Const BlockSize = 2048 Const IM_DELETE = 2048 ' Delete scratchpad file afterwards? Const IM_MARKUNREAD = 131072 Const fRECEIPT = 1 Const fPRIVATE = 2 Const fNOFORMAT = 4 Public InAscii As Boolean Public DownloadDir As String 'where downloads go Public WorkingPath As String 'added to speed up Fetch stuff online Public WhereAmI As String 'name of last forum/page etc Public Sysop As Boolean 'are we a sysop? Public Nisa As Boolean 'do we need to work round NISA "features" ? Public SetHighMessage As Boolean'True if you want a 'high;l' when leaving forum Public currentCAP As Integer Public FAPconfig As FAPCONFIG Public SectionMsgIds(32) As Integer, SectionLibIds(32) As Integer Public szMsgSection() As FAPSECTIONENTRY, szLibSection() As FAPSECTIONENTRY Public nummessages As Integer Public CurrentForum As String Dim LastDownMessages As String Dim capturefilename As String Dim messagefilename As String Dim sectionvector As Long, filterVector As Long Const ALL_HEADER_FIELDS% = &HFF3 Const FAP_FDC_FILE_TYPE% = &H4 Const FAP_FDC_FILE_SIZE% = &H8 Const FAP_FDC_ABSTRACT% = &H100 Const FAP_SFH_FILENAME% = 0 Const FAP_SFH_USER_ID% = FAP_SFH_FILENAME + 1 Const FAP_SFH_KEYWORD% = FAP_SFH_USER_ID + 1 Const FAP_SFH_ACCESS_COUNT% = FAP_SFH_KEYWORD + 1 Const FAP_SFH_DATE_RANGE% = FAP_SFH_ACCESS_COUNT + 1 Const FAP_SFH_LAST_ACCESS_RANGE% = FAP_SFH_DATE_RANGE + 1 Const FAP_SFH_FILE_ABSTRACT% = FAP_SFH_LAST_ACCESS_RANGE + 1 Const FAP_SFH_FILE_BODY% = FAP_SFH_FILE_ABSTRACT + 1 Const FAP_SFH_MATCH_NON_PUBLIC_ONLY% = FAP_SFH_FILE_BODY + 1 Const FAP_SFH_SIZE_RANGE% = FAP_SFH_MATCH_NON_PUBLIC_ONLY + 1 Const FAP_SFH_TITLE% = FAP_SFH_SIZE_RANGE + 1 Const DAP_AL_VOLATILE = &H02 Const DAP_AP_SESSION_ONLY = &H01 Const DAP_AP_VOLATILE = &H02 Const DAP_AP_EX_HAVE_TITLE% = &H0100 Const DAP_AP_HAVE_HEADER% = &H04 Const DAP_AP_HAVE_TRAILER% = &H08 Const HMI_DATA_SIZE% = 1024 Const HMI_STATE_FIRST% = 0 Const HMI_STATE_NEXT% = HMI_STATE_FIRST + 1 Const FAP_USF_HIGH_MSG% = &H2 Const FAP_USF_NAME% = &H4 Const FAP_USR_JOIN% = &H1 Const FAP_USR_PERMANENT% = &H2 Const FAP_WAITING_MSGS% = &H1 Const FAP_NEW_BULLETINS% = &H2 Const FAP_CONFERENCE_IN_PROGRESS% = &H4 Const FAP_NOT_A_MEMBER% = &H8 Const FAP_IS_SYSOP% = &H10 ' user is SYSOP in this Forum Const FAP_FREE_USER% = &H20 Const FAP_LOCKED_OUT% = &H40 Const FAP_TRANSACTION_BILLING% = &H80 Const FAP_ALLOW_MULTIPLE_SEARCH% = &H100 Const FAP_NISA_FORUM% = &H200 Const FAP_MSS_ALL_MSGS% = 0 Const FAP_MSS_WAITING_MSGS% = FAP_MSS_ALL_MSGS + 1 Const FAP_MSS_SUBJECT_TEXT% = FAP_MSS_WAITING_MSGS + 1 Const FAP_MSS_ORIGINATOR_NAME% = FAP_MSS_SUBJECT_TEXT + 1 Const FAP_MSS_RECIPIENT_NAME% = FAP_MSS_ORIGINATOR_NAME + 1 Const FAP_MSS_MSGS_WITHOUT_REPLIES% = FAP_MSS_RECIPIENT_NAME + 1 Const FAP_MSS_HELD_MSGS% = FAP_MSS_MSGS_WITHOUT_REPLIES + 1 Const FAP_MSS_PRIVATE_MSGS% = FAP_MSS_HELD_MSGS + 1 ' to the user Const FAP_MSS_MSGS_WITHOUT_SYSOP_REPLIES% = FAP_MSS_PRIVATE_MSGS + 1 Const FAP_MSS_MESSAGE_BODY% = FAP_MSS_MSGS_WITHOUT_SYSOP_REPLIES + 1 Const FAP_MSS_POSTING_DATE_RANGE% = FAP_MSS_MESSAGE_BODY + 1 Const FAP_MSS_EXPIRATION_DATE_RANGE% = FAP_MSS_POSTING_DATE_RANGE + 1 Const FAP_MSS_MESSAGES_HAS_BEEN_READ% = FAP_MSS_EXPIRATION_DATE_RANGE + 1 Const FAP_NO_MESSAGE_READ% = &H1 Const FAP_NO_MESSAGE_SEND% = &H2 Const FAP_NO_LIBRARY_READ% = &H4 Const FAP_NO_LIBRARY_SEND% = &H8 Const FAP_NO_CONFERENCE% = &H10 Const FAP_NO_PRIVATE_MSGS% = &H20 Const FAP_NO_MEMBERSHIP% = &H80 Const FAP_PRIVATE_FORUM% = &H100 Const FAP_RTC_CONFIG_SUPPORTED% = &H200 Const FAP_SEARCH_LIBRARY_ABSTRACTS% = &H400 ' Full text search of file abstrats allowed Const FAP_SEARCH_LIBRARY_FILES% = &H800 ' Search text file contents Const FAP_SEARCH_MESSAGE_BODIES% = &H1000 ' Searching message bodies allowed Const FAP_LIBRARY_ONLY_FORUM% = &H2000 Const FAP_PRIVATE_MESSAGE% = &H1 Const FAP_EXTENDED_MESSAGE% = &H80 Const FAP_MC_THREAD_ID% = &H1000 Const FAP_MC_THREADS% = &H8000 Const FAP_MSR_PSEUDO_ROOTS% = &H80 Sub RecordAlert(alert As DAPALERTPAGE) Dim nextpage As String On Error Resume Next CaptureLine alert.lpHeader CaptureLines alert.lpBody CaptureLine alert.lpTrailer End Sub Sub CaptureAlert(forum As String, page As String) Dim alert As DAPALERTPAGE Dim nextpage As String On Error Resume Next HMIGetAlert alert If (alert.cOptions And DAP_AL_VOLATILE) = 0 Then nextpage = CheckCache("Alerts", nextpage, 0) If nextpage > "" Then page = nextpage Exit Sub End If UpdateCache "Alerts", page, 0, alert.lpNextPage End If page = alert.lpNextPage If StrComp(Mid$(forum, 1, 4), "CIS:", 1)=0 Then StartCapturing Mid$(forum, 5)+"/Alerts", "Alert recieved going to " + page, False Else StartCapturing forum+"/Alerts", "Alert recieved going to " + page, False End If RecordAlert alert FinishCapturing End Sub Sub RecordArticleText(article As DAPARTICLEPAGE) Dim textbuf As String Dim state As Integer On Error Resume Next If article.wExtendedOptions And DAP_AP_EX_HAVE_TITLE Then CaptureLine article.lpTitle If article.cOptions And DAP_AP_HAVE_HEADER Then CaptureLine article.lpHeader If article.cOptions And DAP_AP_HAVE_TRAILER Then CaptureLine article.lpTrailer state = HMI_STATE_FIRST% Do While DAPArticleRead(state, page, 1, HMI_DATA_SIZE, textbuf) CaptureLines textbuf If textbuf = "" Then Exit Do state = HMI_STATE_NEXT% Loop End Sub Sub CaptureArticleText(nextpage As String) Dim article As DAPARTICLEPAGE On Error Resume Next HMIGetArticle article If (article.cOptions And (DAP_AP_SESSION_ONLY Or DAP_AP_VOLATILE)) = 0 Then nextpage = CheckCache("Articles", article.lpName, article.pvVersion) If nextpage > "" Then Exit Sub UpdateCache "Articles", article.lpName, article.pvVersion, article.lpNextPage End If nextpage = article.lpNextPage StartCapturing "Actions/Articles", Basic.Eoln$ + "Article recieved when going to " + page, False RecordArticleText article FinishCapturing End Sub Sub RecordBulletins(forum As String, getnews As Boolean, _ getothers As Boolean, getuserlog As Boolean) Dim bulletins As FAPBULLETINCONFIG Dim entry() as FAPBULLETINENTRY Dim i As Integer Dim textbuf As String ' We must be a member If FAPconfig.wAlerts And FAP_NOT_A_MEMBER% Then Exit Sub End If FAPGetBulletinConfig bulletins, entry() For i = 0 To UBound(entry) ' Are we interested in this one ? If ((getnews And (entry(i).lpTitle="News Flash" Or _ entry(i).lpTitle="Newsflash" Or _ entry(i).lpTitle="Aktuelles")) Or _ (getuserlog And entry(i).lpTitle="User Log") Or _ (getothers And entry(i).lpTitle<>"News Flash" And _ entry(i).lpTitle<>"User Log" And _ entry(i).lpTitle<>"Newsflash")) Then If entry(i).lpTitle="News Flash" Or _ entry(i).lpTitle="Aktuelles" Or _ entry(i).lpTitle="Newsflash" Then StartCapturing forum+"/Newsflash", "CompuServe", True Else If entry(i).lpTitle="User Log" Then StartCapturing forum+"/Sysop_Logs", "User_Log", True Else StartCapturing forum+"/Announcements", "CompuServe", True End If End If CaptureLine entry(i).lpTitle textbuf = FAPBulletinRead(HMI_STATE_FIRST%, entry(i).nId, 1, HMI_DATA_SIZE) While textbuf > "" CaptureLines textbuf textbuf = FAPBulletinRead(HMI_STATE_NEXT%, entry(i).nId, 1, HMI_DATA_SIZE) Wend FinishCapturing End If Next End Sub Sub SetHighMessageNumber() Dim b As Integer ' Don't set HMN if HMI error If Err = 1009 Then Err = 0 SetHighMessage = False End If If SetHighMessage Then If currentCAP = CAP_FORUM Then Terminal.Print "Updating the high message number to " & FAPconfig.dwNewestMsg & " in " & CurrentForum & Basic.Eoln$ b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_HIGH_MSG%, FAPconfig.dwNewestMsg, "") End If SetHighMessage = False End If End Sub 'T:CollectSections Sub CollectSections(forum As String) Dim sctMsg As FAPSECTIONS, sctLib As FAPSECTIONS Dim i As Integer Dim sNam As String Dim bMessages As Integer, bLibraries As Integer ' Initialise variables For i = 0 To 32 SectionMsgIds(i) = -1 SectionLibIds(i) = -1 Next ' We must be a member If FAPconfig.wAlerts And FAP_NOT_A_MEMBER% Then Exit Sub End If Terminal.Print "Collecting section information" + Basic.Eoln$ On Error Goto CollectMsgSections_error ' Get the msg section names for the forum from Compuserve FAPReadMsgSections sctMsg, szMsgSection() For i = 0 To UBound(szMsgSection) sectionMsgIds(szMsgSection(i).cId) = i ReplaceAnyInString szMsgSection(i).lpTitle, " /", "_" Next bMessages = True CollectMsgSections_resume: ' Get the lib section names for the forum from Compuserve On Error Goto CollectLibSections_error FAPReadLibSections sctLib, szLibSection() For i = 0 To UBound(szLibSection) sectionLibIds(szLibSection(i).cId) = i ReplaceAnyInString szLibSection(i).lpTitle, " /", "_" Next bLibraries = True CollectLibSections_resume: On Error Goto 0 Err = 0 ' Cope with ZNT:<forum> If InStr(forum, ":")<>0 Then sNam = Mid$(forum, InStr(forum, ":")+1, 8)+".nam" Else sNam = Mid$(forum, 1, 8)+".nam" End If ' Create the .NAM file DeleteFile Session.ServicePath+sNam Capture CAPTURE_ON, Session.ServicePath+sNam If InStr(forum, ":")<>0 Then CaptureLine "#forum " + Mid$(forum, InStr(forum, ":")+1) Else CaptureLine "#forum " + forum End If ' Write forum info If (FAPconfig.wAlerts And FAP_IS_SYSOP%)<>0 Then CaptureLine "SYSOP" If (FAPconfig.wAlerts And FAP_FREE_USER%)<>0 Then CaptureLine "Free Flag" If (FAPconfig.wAlerts And FAP_NISA_FORUM%)<>0 Then CaptureLine "NISA Forum" If (FAPconfig.wRestrictions And FAP_NO_PRIVATE_MSGS%)<>0 Then CaptureLine "Private Messages not allowed" Else CaptureLine "Private Messages are allowed" End If On Error Resume Next ' Get the message section names for the forum from Compuserve CaptureLine "Message Sections Available:" If bMessages Then For i = 0 To UBound(szMsgSection) CaptureLine Str(szMsgSection(i).cId)+" "+szMsgSection(i).lpTitle Next End If ' Get the library section names for the forum from Compuserve CaptureLine "Libraries Available:" If bLibraries Then For i = 0 To UBound(szLibSection) CaptureLine Str(szLibSection(i).cId)+" "+szLibSection(i).lpTitle Next End If ' Clear up Capture CAPTURE_OFF On Error Goto 0 Exit Sub CollectMsgSections_error: Resume CollectMsgSections_resume CollectLibSections_error: Resume CollectLibSections_resume End Sub ' Intelligently GO forum only Function HMIGotoForum(ByVal forum As String) As Boolean Dim filename As String, myerror As String, i As Integer Dim fname As String, preforum As String, tmp As String ' Sort out any switch between ascii/hmi If InAscii Then ResetForum InAscii = False End If ' Mangle the forum name a bit forum = ParseString(forum, "/") fname = forum If Instr(forum, ":")=0 Then forum = "cis:"+forum End If ' Use the lookup table to auto-convert menus to forums. ' eg. 'PCPLUS' -> 'PCPFORUM' preforum = forum forum = LookupForum(preforum) ' If we're already here then do nothing If StrComp(WhereAmI, fname, 1)<>0 And StrComp(WhereAmI, forum, 1)<>0 _ And StrComp(WhereAmI, preforum, 1)<>0 Then SetHighMessageNumber If StrComp(WhereAmI, "cis:mail", 1)<>0 Then If WhereAmI<>"" Then Terminal.Print "Leaving " & WhereAmI & Basic.Eoln$ & Basic.Eoln$ End If End If Terminal.Print Basic.Eoln$+"Go " & forum & Basic.Eoln$ & Basic.Eoln$ On Error Goto GoForum_error HMIGotoForum = False If Not DoHMIGoToPage(forum, -1, CAP_FORUM) Then If currentCAP <> CAP_ERROR Then myerror = "Not a forum" goto GoForum_error End If HMIGetFAPConfig FAPconfig Sysop = ((FAPconfig.wAlerts And FAP_IS_SYSOP%) <> 0) Nisa = ((FAPconfig.wAlerts And FAP_NISA_FORUM%) <> 0) Terminal.Print "Welcome to " & FAPconfig.lpForumName & " Forum" & Basic.Eoln$ Terminal.Print "Hello, " & FAPconfig.lpUserName If Sysop Then Terminal.Print " (Sysop)" If (FAPconfig.wAlerts And FAP_FREE_USER%)<>0 Then Terminal.Print " (Free)" Terminal.Print Basic.Eoln$ If Nisa Then Terminal.Print "This is a NISA forum" & Basic.Eoln$ If FAPconfig.tsLastAccess.cYear>0 Then Terminal.Print "Last visit: " & MakeDateString(FAPconfig.tsLastAccess) & Basic.Eoln$ Else Terminal.Print "Last visit: Never" & Basic.Eoln$ End If Terminal.Print "Forum messages: " & FAPconfig.dwMsgNoBase & " to " & FAPconfig.dwNewestMsg & Basic.Eoln$ Terminal.Print "Last message you've read: " & FAPconfig.dwLastMsgRead & Basic.Eoln$ If FAPconfig.wAlerts And FAP_WAITING_MSGS% Then Terminal.Print Basic.Eoln$ & "You have waiting message(s)" & Basic.Eoln$ End If Terminal.Print Basic.Eoln$ If FAPconfig.wAlerts And FAP_LOCKED_OUT% Then myerror = "User locked out" goto GoForum_error End If If FAPconfig.wAlerts And FAP_NEW_BULLETINS% Then Terminal.Print "Collecting updated Newsflash" + Basic.Eoln$ RecordBulletins fname, True, False, False End If Terminal.Status "HMIGotoForum: "+fname On Error Goto 0 ' It all worked If Instr(fname, ":")=0 Then WhereAmI = "cis:"+fname Else WhereAmI = fname End If CollectSections WhereAmI End If LastFailure = "" HMIGotoForum = True Exit Function GoForum_error: On Error Goto 0 If myerror = "" Then myerror = FullErrorMessage Terminal.Print "Error: " & myerror & Basic.Eoln$ LogResult "HMIGotoForum : "+forum+" : Failed Error : "+myerror LastFailure = forum SetHighMessage = False ' If it was a PTE and HMI packet size was 2k then reduce to 1k and inform ' the user. If InStr(myerror, "1285:Protocol transport error", 1)<>0 And _ ReadIni$(Session.IniSection, "HMI Packet Size", Session.IniFilename)="2048" Then WriteIni Session.IniSection, "HMI Packet Size", "1024", Session.IniFilename LogResult "_NOTE_Reducing_HMI_packet_size_for_improved_connection_reliability_" End If End Function 'T:SetHigh (subroutine) (CompuServe) ' Set high message number Sub SetHigh(id As String, forum As String, num As String) Dim hmn As Long, b As Integer If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to set high message number in "+forum Exit Sub End If hmn = Val(num) If hmn < 0 Then hmn = FAPconfig.dwNewestMsg+hmn If hmn = 0 Then hmn = FAPconfig.dwNewestMsg ' Set high number Terminal.Print "Setting the high message number to" & Str(hmn) & Basic.Eoln$ b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_HIGH_MSG%, hmn, "") If id<>"" Then If b=0 Then ReportSuccess id & " : Failed to Set High Message Number to #" & hmn & " in " & forum Else ReportSuccess id & " : Set High Message Number to #" & hmn & " in " & forum HMIGetFAPConfig FAPconfig End If Else HMIGetFAPConfig FAPconfig End If End Sub Function CheckTopicBeforePosting(id As String, topic As String, _ section As Integer, subject As String, checksection As Boolean) As Boolean Dim i As Integer If Not HMIGotoForum(topic) Then LogResult id + " : Failed : Unable to post message." Exit Function End If If FAPconfig.wRestrictions And FAP_NO_MESSAGE_SEND% Then LogResult id + " : Failed : Posting not allowed in forum " & topic Exit Function End If ' Truncate subject to 24 chars and make it valid If Len(subject) > 24 Then subject = Left$(subject, 24) For i = 1 To Len(subject) If InStr(";""", Mid(subject, i, 1)) Then Mid(subject, i, 1) = " " Next section = Val(SectionNumber(topic)) If checksection Then If (FAPconfig.svMsgSections And (2 ^ section)) = 0 Then LogResult id + " : Failed : Unknown section " & topic Exit Function End If End If CheckTopicBeforePosting = True End Function 'T:Say (subroutine) (CompuServe) Sub Say(id As String, topic As String, pfrom As String, pto As String, flags As Integer, subject As String, filename As String) Dim hdr As FAPMSGHEADER, body As String Dim section As Integer, cOptions As Integer Dim username As String, userid As String, lastname As String Dim noformat As Integer, b As Integer ' Is it usenet? If Mid(topic, 1, 7)="usenet." Then UsenetPost id, topic, filename Exit Sub End If If Not CheckTopicBeforePosting(id, topic, section, subject, True) Then Exit Sub End If If (flags And fPRIVATE) <> 0 Then Terminal.Print "Posting private message to " + pto + " Subj: " + subject + Basic.Eoln$ Else Terminal.Print "Posting message to " + pto + " Subj: " + subject + Basic.Eoln$ End If AnalyseName pto, username, userid If StrComp(userid, "all", 1)=0 Or _ StrComp(userid, "sysop", 1)=0 Or _ StrComp(userid, "*sysop", 1)=0 Then username = userid userid = "" userid=userid ElseIf Not IsNumeric(Mid$(userid, 1, 1)) Then username = username + " " + userid userid = "" End If ' What posting flags ? If flags And fNOFORMAT Then noformat = 1 If (flags And fPRIVATE) <> 0 Then If (FAPconfig.wRestrictions And FAP_NO_PRIVATE_MSGS%) = 0 Then cOptions = FAP_PRIVATE_MESSAGE% Else MailTo id, pto, 0, subject, filename SendMail id Exit Sub End If End If ' What's our name If pfrom <> "" Then On Error Resume Next lastname = FAPconfig.lpUserName b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, pfrom) On Error Goto 0 End If ' Get body text body = ReadMessageFile(filename, noformat) On Error Goto Say_error On Error Resume Next 'NB Bug in CCT230B always gives error here FAPSendMsg hdr, section, subject, username, userid, cOptions, body ' Change back to old name If lastname <> "" Then On Error Resume Next b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, lastname) On Error Goto 0 End If If hdr.dwMsgNo = 0 Then LogResult id + " : Failed : Posting Compose to " & topic Else ReportSuccess id & " : Posted Compose to " & pto & " in " & topic & " As #" & hdr.dwMsgNo HMIGetFAPConfig FAPconfig End If Exit Sub Say_error: LogResult id + " : Failed : Posting Compose to " & topic & " - Error:" & FullErrorMessage End Sub 'T:UnjoinedSay (subroutine) (CompuServe) Sub UnjoinedSay(id As String, topic As String, pto As String, subject As String, filename As String) Say id, topic, "", pto, 0, subject, filename End Sub 'T:Comment (subroutine) (CompuServe) Sub Comment(id As String, topic As String, pfrom As String, pto As String, message As String, flags As Integer, subject As String, filename As String) Dim hdr As FAPMSGHEADER, body As String Dim section As Integer, cOptions As Integer Dim username As String, userid As String, lastname As String Dim msgno As Long, threadid As Long Dim noformat As Integer ' Is it usenet? If Mid(topic, 1, 7)="usenet." Then UsenetPost id, topic, filename Exit Sub End If If Not CheckTopicBeforePosting(id, topic, section, subject, False) Then Exit Sub End If If (flags And fPRIVATE) <> 0 Then Terminal.Print "Replying privately to message #"+message+" Subj: "+subject+Basic.Eoln$ Else Terminal.Print "Replying to message #"+message+" Subj: "+subject+Basic.Eoln$ End If ' What posting flags ? If flags And fNOFORMAT Then noformat = 1 If (flags And fPRIVATE) <> 0 Then If (FAPconfig.wRestrictions And FAP_NO_PRIVATE_MSGS%) = 0 Then cOptions = FAP_PRIVATE_MESSAGE% Else MailTo id, pto, 0, "Re: "+subject, filename SendMail id Exit Sub End If End If ' What's our name If pfrom <> "" Then On Error Resume Next lastname = FAPconfig.lpUserName b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, pfrom) On Error Goto 0 End If ' Collect message text ready to send to CIS body = ReadMessageFile(filename, noformat) On Error Resume Next msgno = Val(message) FAPReadMsgHeader hdr, msgno, FAP_MC_THREAD_ID% threadid = hdr.dwThreadID If threadid <> 0 Then FAPSendReply hdr, msgno, threadid, cOptions, body Else hdr.dwMsgNo = 0 End If If hdr.dwMsgNo = 0 Then AnalyseName pto, username, userid FAPSendMsg hdr, section, "#"+message+"-"+subject, username, userid, cOptions, body If hdr.dwMsgNo = 0 Then LogResult id + " : Failed : Posting Reply to " & message & " in " & topic & " - error: " & FullErrorMessage() ' Change back to old name If lastname <> "" Then On Error Resume Next b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, lastname) On Error Goto 0 End If Exit Sub End If End If ReportSuccess id & " : Posted Reply to " & message & " in " & topic & " As #" & hdr.dwMsgNo ' Change back to old name If lastname <> "" Then On Error Resume Next b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, lastname) On Error Goto 0 End If HMIGetFAPConfig FAPconfig Exit Sub End Sub 'T:DownMessages (subroutine) (CompuServe) ' Download full message text Sub DownMessages(id As String, forum As String, sections As String) Dim hdr As FAPMSGHEADER, sect As Long Dim txt As String, body As String, t As String Dim count As Integer, i As Integer, newmsgs As Long sections = Trim$(LTrim$(sections)) If StartMessageDownload(id, forum, sections, False) Then On Error Goto DownMessages_error sect = ParseSectionList(sections, FAPconfig.svMsgSections, count) If count > 0 Then Dim lpStartWith(0 To count-1) As FAPSTARTWITH 'Fill in the FAPSTARTWITH structures for each section count = 0 For i = 0 To 24 sl = 2^i If (sect And (2^i))<>0 Then lpStartWith(count).cSectionID = i lpStartWith(count).dwMsgNo = FAPconfig.dwLastMsgRead count = count + 1 End If Next 'Ask HMI for all new messages after the start FAPReadNewMsgs ALL_HEADER_FIELDS, lpStartWith() 'Now read the actual messages Do hdr.dwMsgNo = 0 FAPReadSingleNewMsgHdr hdr If hdr.dwMsgNo = 0 Then Exit Do 'Finished body = "" Do txt = "" ' possible memory leak txt = FAPReadNewMessageBody(hdr) body = body + txt Loop While txt > "" SaveMessage hdr, body newmsgs = newmsgs + 1 Loop End If Terminal.Print "Collected " & newmsgs & " new message(s)" & Basic.Eoln$ If count>0 Then SetHighMessage = True End If FinishMessageDownload id Exit Sub DownMessages_error: LogResult "Error:" & FullErrorMessage & " collecting messages from " & forum CaptureLine "Error:" & FullErrorMessage FinishMessageDownload id End Sub 'T:DownHeaders (subroutine) (CompuServe) Sub DownHeaders(id As String, forum As String, sections As String) If StartMessageDownload(id, forum, sections, False) Then SearchMessages FAP_MSS_ALL_MSGS%, "", False, False, True, "" If Len(Trim$(LTrim$(sections)))>0 Then SetHighMessage = True End If FinishMessageDownload id End Sub 'T:DownRoots (subroutine) (CompuServe) Sub DownRoots(id As String, forum As String, sections As String) If StartMessageDownload(id, forum, sections, False) Then SearchMessages FAP_MSS_ALL_MSGS%, "", False, True, True, "" If Len(Trim$(LTrim$(sections)))>0 Then SetHighMessage = True End If FinishMessageDownload id End Sub 'T:SearchForMessages (subroutine) (CompuServe) Sub SearchForMessages(id As String, forum As String, sections As String, lastdays As String, searchtype As String, searchstring As String) Dim hmn As Long If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to collect messages from " + forum Exit Sub End If If searchtype="9" And Nisa=False Then LogResult id + " : Failed : Cannot search message body in non-NISA forum " + forum Exit Sub End If hmn = FAPconfig.dwLastMsgRead If StartMessageDownload(id, forum, sections, True) Then If lastdays="u" Then Terminal.Print "Searching for unread messages " Else Terminal.Print "Searching for messages " End If If searchtype="2" Then Terminal.Print "with subject: '" If searchtype="3" Then Terminal.Print "from: '" If searchtype="4" Then Terminal.Print "to: '" If searchtype="9" Then Terminal.Print "containing: '" Terminal.Print searchstring+"'"+Basic.Eoln$ If lastdays="u" Then SearchMessages Val(searchtype), searchstring, True, False, True, "" Else SearchMessages Val(searchtype), searchstring, True, False, False, lastdays End If End If FinishMessageDownload id ' Correct Compuserve's invalid assumption about HMN after remote search b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_HIGH_MSG%, hmn, "") End Sub 'T:ListHeldMessages (subroutine) (CompuServe) Sub ListHeldMessages(id As String, forum As String, sections As String) Dim term(0 To 0) As FAPSEARCHTERM Dim summary() As FAPMSGSUMMARY Dim msgno() As Long Dim hdr As FAPMSGHEADER Dim i As Integer, count as Integer Dim nmsgs As Integer Dim cComponents As Integer Dim dwStart As Long Dim section As String If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to collect messages from " + forum Exit Sub End If If Nisa Then sectionvector = ParseSectionList(sections, FAPconfig.svMsgSections, count) StartCapturing forum+"/Sysop_Logs", "Held_Messages", False CaptureLine "Messages on Hold" CaptureLine "" Terminal.Status "Collecting Held List ... Please Wait" term(0).cType = FAP_MSS_HELD_MSGS% dwStart = FAPconfig.dwMsgNoBase On Error Goto ListHeldMessages_end FAPMsgSearch summary(), msgno(), HMI_STATE_FIRST%, 1, 20, _ sectionvector, dwStart, cComponents, term() While True nmsgs = UBound(msgno) On Error Goto ListHeldMessages_error For i = 0 To UBound(msgno) hdr.dwMsgNo = 0 FAPReadMsgHeader hdr, msgno(i), ALL_HEADER_FIELDS If hdr.dwMsgNo = 0 Then Exit For If SectionMsgIds(hdr.cSectionId) >= 0 Then section = szMsgSection(SectionMsgIds(hdr.cSectionId)).lpTitle Else section = "Unknown" End If CaptureText "VA:Cis:" & forum & "/S" & hdr.cSectionId CaptureLine "_" & section & "#" & hdr.dwMsgNo Next On Error Goto ListHeldMessages_end ' following will error if nothing else left FAPMsgSearch summary(), msgno(), HMI_STATE_NEXT%, 1, 20, _ sectionvector, dwStart, cComponents, term() Wend ListHeldMessages_end: FinishCapturing ReportSuccess id & " : Held Message List for forum " & forum & " collected" Exit Sub ListHeldMessages_error: LogResult "SearchMessages: Error:" & FullErrorMessage Else AsciiListHeldMessages id, forum, sections End If End Sub Sub FetchMessageThread(id As String, forum As String, number As String, thr As Boolean) Dim i As Integer, b As Integer, done As Integer Dim tmp As String, body As String, txt As String Dim hdr As FAPMSGHEADER, msgno() As Long, lasthmn As Long If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to read messages from " + forum Exit Sub End If lasthmn = FAPconfig.dwLastMsgRead CurrentForum = ParseString(forum, "/") ' Unique name for capture file messagefilename = UniqueFileName$() Capture CAPTURE_ON, messagefilename CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=yes"+Basic.Eoln$ On Error Goto ReadMessageThread_error ' Read the message/thread Redim msgno(0 To 0) msgno(0) = number If thr Then FAPReadMessageHeaders ALL_HEADER_FIELDS+FAP_MC_THREADS%, msgno() Else FAPReadMessageHeaders ALL_HEADER_FIELDS, msgno() End If done = False Do FAPReadSingleMsgHdr hdr If hdr.dwMsgNo = 0 Then Exit Do Terminal.Print "Reading message/thread #" & LTrim(Str(hdr.dwMsgNo)) & " " & hdr.lpSubject & Basic.Eoln$ body = "" Do txt = FAPReadMessageBody(hdr) body = body + txt Loop While txt > "" SaveMessage hdr, body done = True Loop If done = False And thr = False Then Terminal.Print "% Unable to read message #" & number & " from " & WhereAmI & Basic.Eoln$ End If Capture CAPTURE_OFF If done Then If id<>"" Then ReportSuccess id & " : Collected message/thread #" & number & " from " & WhereAmI b = QueueFile(Session.Service, messagefilename, IM_DELETE) Else If id<>"" Then ReportSuccess id & " : Didn't collect message/thread #" & number & " from " & WhereAmI DeleteFile messagefilename End If i = HMIResync(CAP_FORUM) ' Need to set HMN because CIS messes it up b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_HIGH_MSG%, lasthmn, "") Exit Sub ReadMessageThread_error: LogResult "Error:" & FullErrorMessage & " collecting message/thread from " & forum CaptureLine "Error:" & FullErrorMessage i = HMIResync(CAP_FORUM) sectionvector = 0 End Sub Sub FetchThread(id As String, forum As String, number As String) FetchMessageThread id, forum, number, True End Sub Function StartMessageDownload(id As String, forum As String, _ sections As String, markunread As Boolean) As Integer Dim i As Integer, j As Integer, count As Integer Dim tmp As String, t As String Dim tmpVector As Long, fromyou As Boolean nummessages = -1 StartMessageDownload = False If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to collect messages from " + forum Exit Function End If CurrentForum = forum ' Unique name for capture file Capture CAPTURE_ON, WorkingPath + "mswfetch.tmp" CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=no"+Basic.Eoln$ Terminal.CaptureStatus CAPTURE_ON nummessages = 0 On Error Goto StartMessageDownload_error ' Which sections ? fromyou = InStr(sections, "y", 1)<>0 ReplaceAllInString sections, " y", "" sectionvector = ParseSectionList(sections, FAPconfig.svMsgSections, count) ' Messages from/to you If LastDownMessages<>WhereAmI Then filterVector = sectionvector ' Used to filter out waiting messages tmpVector = sectionvector sectionvector = &HFFFFFFFF If FAPconfig.wAlerts And FAP_WAITING_MSGS% Then Terminal.Print "Collecting waiting messages" & Basic.Eoln$ SearchMessages FAP_MSS_WAITING_MSGS%, "", True, False, False, "" If nummessages=1 Then Terminal.Print "Collected 1 waiting message" & Basic.Eoln$ Else Terminal.Print "Collected " & nummessages & " waiting messages" & Basic.Eoln$ End If nummessages = 0 End If ' Read messages from you? If fromyou Then Terminal.Print "Collecting messages from you" & Basic.Eoln$ SearchMessages FAP_MSS_ORIGINATOR_NAME%, Session.LoginName, True, False, True, "" End If sectionvector = tmpVector End If ' Start capture Capture CAPTURE_OFF messagefilename = UniqueFileName$() Capture CAPTURE_ON, messagefilename If markunread Then CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=yes"+Basic.Eoln$ Else CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=no"+Basic.Eoln$ End If ' Store the last forum we read messages from so that we don't ' do more than one reading waiting per forum. LastDownMessages = WhereAmI If Not markunread Then If sectionvector=FAPconfig.svMsgSections Then Terminal.Print "Collecting messages from all sections" + Basic.Eoln$ Else Terminal.Print "Collecting messages from sections " + Trim$(sections) + Basic.Eoln$ End If End If StartMessageDownload = True Exit Function StartMessageDownload_error: LogResult "Error:" & FullErrorMessage & " collecting messages from " & forum CaptureLine "Error:" & FullErrorMessage sectionvector = 0 If nummessages > 0 Then StartMessageDownload = True End Function Sub FinishMessageDownload(id As String) Capture CAPTURE_OFF Terminal.CaptureStatus CAPTURE_OFF If nummessages = -1 Then Exit Sub If nummessages = 1 Then ReportSuccess id & " : Collected " & nummessages & " message from " & WhereAmI Else ReportSuccess id & " : Collected " & nummessages & " messages from " & WhereAmI End If If nummessages > 0 Then ' Add to import queue b = QueueFile(Session.Service, messagefilename, IM_DELETE) Else DeleteFile messagefilename End If End Sub Sub SearchMessages (searchtype As Integer, searchstring As String, bodies As Boolean, rootsonly As Boolean, unreadonly As Boolean, lastdays As String) Dim term(0 To 0) As FAPSEARCHTERM Dim summary() As FAPMSGSUMMARY Dim msgno() As Long Dim hdr As FAPMSGHEADER Dim i As Integer, txt As String, body As String Dim nmsgs As Integer Dim d As Date, tsTime As HMITIMESTAMP Dim cComponents As Integer Dim dwStart As Long ' Nothing to do so don't bother trying If unreadonly And FAPconfig.dwNewestMsg=FAPconfig.dwLastMsgRead Then Exit Sub End If term(0).cType = searchtype If searchstring<>"" Then term(0).lpPattern = searchstring If rootsonly Then cComponents = FAP_MSR_PSEUDO_ROOTS% If lastdays<>"" Then d = Date() - Val(lastdays) tsTime.cDay = Day(d) tsTime.cMonth = Month(d) tsTime.cYear = Year(d)-1970 dwStart = FAPSearchDate(&H00FFFFFF, tsTime) Else If unreadonly Then dwStart = FAPconfig.dwLastMsgRead Else dwStart = FAPconfig.dwMsgNoBase End If End If On Error Goto SearchMessages_end FAPMsgSearch summary(), msgno(), HMI_STATE_FIRST%, 1, 1000, _ sectionvector, dwStart, cComponents, term() While True nmsgs = UBound(msgno) On Error Goto SearchMessages_error If bodies Then FAPReadMessageHeaders ALL_HEADER_FIELDS, msgno() Do FAPReadSingleMsgHdr hdr If hdr.dwMsgNo = 0 Then Exit Do dwStart = hdr.dwMsgNo body = "" Do txt = "" ' possible memory leak txt = FAPReadMessageBody(hdr) body = body + txt Loop While txt > "" SaveMessage hdr, body ' Don't import waiting messages if the message is ' collected by DownMessages() 'If searchtype<>FAP_MSS_WAITING_MSGS% Or _ ' ((2^hdr.cSectionId) And filterVector)=0 Then ' SaveMessage hdr, body 'Else ' nummessages = nummessages + 1 ' Terminal.Print "(Filtering out message #" & hdr.dwMsgNo & " - importing once only)" & Basic.Eoln$ 'End If Loop Else For i = 0 To UBound(msgno) hdr.dwMsgNo = 0 FAPReadMsgHeader hdr, msgno(i), ALL_HEADER_FIELDS If hdr.dwMsgNo = 0 Then Exit For SaveMessage hdr, "*** Header Only ***" & Chr$(10) Next End If On Error Goto SearchMessages_end ' following will error if nothing else left FAPMsgSearch summary(), msgno(), HMI_STATE_NEXT%, 1, 1000, _ sectionvector, dwStart, cComponents, term() Wend SearchMessages_end: filterVector = 0 Exit Sub SearchMessages_error: LogResult "SearchMessages: Error:" & FullErrorMessage filterVector = 0 End Sub 'T:DeleteMessage (subroutine) (CompuServe) Sub DeleteMessage(id As String, forum As String, dummy As String, number As String) If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to delete messages in " + forum Exit Sub End If Terminal.Print "Deleting message #" + number + Basic.Eoln$ ' Delete the message On Error Goto DeleteMessage_error If FAPDeleteMsg_(number)<>0 Then ReportSuccess id & " : Deleted message #" & number & " from " & forum End If Exit Sub DeleteMessage_error: ReportSuccess id & " : Unable to delete message #" & number & " from " & forum End Sub 'T:ReadNumber (subroutine) (CompuServe) Sub ReadNumber(id As String, forum As String, number As String) FetchMessageThread id, forum, number, False End Sub 'T:NewJoinForum (subroutine) (CompuServe) Sub NewJoinForum(id As String, forum As String, handle As String, ndays As String, sect As String) Dim b As Integer, hmn As Long Dim tsTime As HMITIMESTAMP, d As Date Dim a As Boolean If Not HMIGotoForum(forum) Then LogResult "Unable to join "+forum Exit Sub End If Terminal.Print "Joining forum"+Basic.Eoln$ On Error Goto JoinForum_error ' Set user name If ((FAPconfig.wAlerts And FAP_NOT_A_MEMBER%) <> 0) Then b = FAPSetUserProfile(FAP_USR_PERMANENT%+FAP_USR_JOIN%, FAP_USF_NAME%, 0, handle) FAPconfig.wAlerts = FAPconfig.wAlerts - FAP_NOT_A_MEMBER% Else On Error Resume Next b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_NAME%, 0, handle) End If ' Get list of sections/libraries CollectSections forum If (FAPconfig.wAlerts And FAP_NEW_BULLETINS)=0 Then Newsflash "", forum End If Announcements "", forum ' Set HMN back nnn days If ndays <> "" Then d = Date() - Val(ndays) tsTime.cDay = Day(d) tsTime.cMonth = Month(d) tsTime.cYear = Year(d)-1970 hmn = FAPSearchDate(FAPconfig.svMsgSections, tsTime) If hmn > 0 Then SetHigh "", forum, LTrim$(Str(hmn)) ElseIf FAPconfig.dwLastMsgRead < FAPconfig.dwMsgNoBase Then SetHigh "", forum, LTrim$(Str(FAPconfig.dwMsgNoBase)) End If ReportSuccess id & " : Joined " & forum & " successfully" DownMessages id, forum, sect Exit Sub JoinForum_error: LogResult id + " : Failed : Unable to join " + forum + " - error:" + FullErrorMessage End Sub 'T:NewDownloadFile (subroutine) (CompuServe) Sub NewDownloadFile(id As String, forum As String, filename As String, pubavail As Boolean) Dim section As Integer, sections As Long, ftype As Integer, i As Integer Dim catalog As Long, filesize As Long, l As Long Dim tforum As String, s As String, count As Long Dim b As Integer, fname As String, pterm(0 to 0) As FAPSEARCHTERM Dim fdesc() As FAPFILEDESCRIPTION, fterm(0 to 1) As FAPSEARCHTERM tforum = forum If Not HMIGotoForum(tforum) Then LogResult "Unable to download file "+filename+" from "+forum Exit Sub End If ' Extract the section number section = Val(SectionNumber(forum)) sections = 2 ^ section If (FAPconfig.svLibSections And sections) = 0 Then LogResult id + " : Failed : Unknown library section " & forum Exit Sub End If ' Scan library for the file On Error Goto NotFound_error If pubavail Then Terminal.Print "Downloading file " + filename + Basic.Eoln$ pterm(0).cType = FAP_SFH_FILENAME pterm(0).lpPattern = filename FAPSearchFile fdesc(), HMI_STATE_FIRST%, 1, 1, sections, _ FAP_FDC_FILE_TYPE% + FAP_FDC_FILE_SIZE%, pterm() Else Terminal.Print "Downloading unreleased file " + filename + Basic.Eoln$ fterm(0).cType = FAP_SFH_FILENAME fterm(0).lpPattern = filename fterm(1).cType = FAP_SFH_MATCH_NON_PUBLIC_ONLY FAPSearchFile fdesc(), HMI_STATE_FIRST%, 1, 1, sections, _ FAP_FDC_FILE_TYPE% + FAP_FDC_FILE_SIZE%, fterm() End If catalog = fdesc(0).dwCatalogNo filesize = fdesc(0).dwFileSize ftype = fdesc(0).nFileType If filesize = 0 Then Terminal.Print "File not found." + Basic.Eoln$ LogResult "Unable to find "+filename+" in library "+forum Exit Sub End If On Error Goto DownloadFile_error Terminal.TransferStatus False, filename, 0, filesize ' Open file to write to If FileExists(DownloadDir+filename) Then count = FileLen(DownloadDir+filename) ' Resume file download Else count = 0 End If Open DownloadDir+filename For Binary Access Write Shared As #1 If count>0 Then Terminal.Print "Resuming file download at " & count & Basic.Eoln$ Seek #1, count+1 End If s = FAPReceiveFileOffset(HMI_STATE_FIRST%, catalog, ftype, 0, i, count+1) Do While s > "" Put #1, , s count = count + i Terminal.TransferStatus False, filename, count, filesize s = FAPReceiveFileOffset(HMI_STATE_NEXT%, catalog, ftype, 0, i, count+1) Loop If count < filesize Then Terminal.TransferStatus False, filename, count, count LogResult id & " : Possible incomplete download of "+filename+" from "+forum LogResult id & " : Reported size " & filesize & " actual size " & count End If Close #1 Terminal.TransferStatus ' Write comment to catalog entry and import into messagebase tforum = ParseString(tforum, "/")+"/L"+LTrim(Str(section)) RecordFileDownload tforum, LTrim$(Str$(catalog)) If SectionLibIds(section) >= 0 Then tforum = tforum +"_" + szLibSection(SectionLibIds(section)).lpTitle Else tforum = tforum + "_Unknown" End If If pubavail Then ReportSuccess id & " : Downloaded "+FileUrl(DownloadDir+filename)+" from forum "+forum NewSearchLibrary "", tforum, LTrim$(Str(catalog)), "", DownloadDir+filename, _ "", "", "", "", "", "", "y", "n" Else ReportSuccess id & " : Downloaded unreleased "+FileUrl(DownloadDir+filename)+" from forum "+forum End If Exit Sub NotFound_error: LogResult "Unable to find "+filename+" in library "+forum Exit Sub DownloadFile_error: Close #1 Terminal.TransferStatus LogResult id & " : Failed to download "+filename+" from "+forum+" error : " + FullErrorMessage() End Sub 'T:DownloadFile (subroutine) (CompuServe) Sub DownloadFile(id As String, forum As String, filename As String) NewDownloadFile id, forum, filename, True End Sub 'T:DownloadFileFinder (subroutine) (CompuServe) Sub DownloadFileFinder(id As String, forum As String, filename As String, handle As String) If Not HMIGotoForum(forum) Then LogResult "Unable to download file "+filename+" from "+forum Exit Sub End If ' Check to see if we need to join the forum If ((FAPconfig.wAlerts And FAP_NOT_A_MEMBER%) <> 0) Then JoinForum "", forum, handle, "" End If ' Download the file NewDownloadFile id, forum, filename, True End Sub Sub NextSearchTerm(ByRef searchterm() As FAPSEARCHTERM, ByRef i As Integer, sfh As Integer, pat As String) If pat="" Then Exit Sub ReDim Preserve searchterm(0 To i) searchterm(i).cType = sfh searchterm(i).lpPattern = pat i = i + 1 End Sub 'T:NewSearchLibrary (subroutine) (CompuServe) Sub NewSearchLibrary(id As String, forum As String, catalog As String, _ ssections As String, filename As String, uploadby As String, _ age As String, accesscount As String, keywords As String, _ title As String, description As String, full As String, _ replace As String) Dim fname As String, i As Integer, t As Long Dim section As Integer, tforum As String, count As Long Dim filedesc() As FAPFILEDESCRIPTION, tmpdesc As FAPFILEDESCRIPTION Dim searchterm() As FAPSEARCHTERM, errmsg As String Dim searchflags As Long, catno As Long, ok As Boolean tforum = forum catno = Val(catalog) If Not HMIGotoForum(tforum) Then LogResult "Unable to refresh library list from "+forum Exit Sub End If tforum = ParseString(tforum, "/") ' Set which bits of info we want searchflags = &H6FF If UCase(full)="Y" Then searchflags = searchflags + FAP_FDC_ABSTRACT% If UCase(replace)="Y" Then replace = "yes" Else replace = "no" End If ok = True ' Scan library for the files fname = UniqueFilename$() count = 0 Capture CAPTURE_ON, fname CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=yes;deleteexisting="+replace+Basic.Eoln$ If catno > 0 Then Terminal.Print "Collecting library #" + LTrim$(Str(catno)) + Basic.Eoln$ ' We know which catalog we want - get it On Error Goto EndOfLibrary_error i = FAPReadFileDescription(catno, searchflags, tmpdesc) If tmpdesc.lpFilename <> "" Then tmpdesc.dwCatalogNo = catno WriteLibraryMessage tforum, tmpdesc, filename count = 1 End If Else Terminal.Print "Collecting libraries from sections " + LTrim$(ssections) + Basic.Eoln$ If filename="" Then filename = "*.*" ' Set search terms i = 0 NextSearchTerm searchterm(), i, FAP_SFH_FILENAME%, filename NextSearchTerm searchterm(), i, FAP_SFH_USER_ID%, uploadby NextSearchTerm searchterm(), i, FAP_SFH_TITLE%, title NextSearchTerm searchterm(), i, FAP_SFH_DATE_RANGE%, age NextSearchTerm searchterm(), i, FAP_SFH_ACCESS_COUNT%, accesscount NextSearchTerm searchterm(), i, FAP_SFH_KEYWORD%, keywords NextSearchTerm searchterm(), i, FAP_SFH_FILE_ABSTRACT%, description ' Select sections to search sectionvector = ParseSectionList(ssections, FAPconfig.svLibSections, i) t = 1 For i = 0 to 24 If sectionvector And t Then SetLastUpdated tforum & "/L" & i t = t + t Next Terminal.CaptureStatus CAPTURE_ON On Error Goto EndOfLibrary_error FAPSearchFile filedesc(), HMI_STATE_FIRST%, 1, 4, sectionvector, searchflags, searchterm() Do While filedesc(0).dwCatalogNo > 0 For i = 0 To UBound(filedesc) If filedesc(i).dwCatalogNo > 0 Then count = count + 1 Terminal.CaptureStatus count, "Receiving Library Message" WriteLibraryMessage tforum, filedesc(i), "" End If Next FAPSearchFile filedesc(), HMI_STATE_NEXT%, 1, 4, sectionvector, searchflags, searchterm() Loop Terminal.Print "Collected "+LTrim$(Str(count))+" library entries" + Basic.Eoln$ End If EndOfLibrary_ok: On Error Goto 0 Terminal.CaptureStatus CAPTURE_OFF Capture CAPTURE_OFF ' Add to import queue If count > 0 Then b = QueueFile(Session.Service, fname, IM_DELETE Or IM_MARKUNREAD) Else DeleteFile fname End If If ok And id<>"" Then ReportSuccess id & " : Downloaded library list(s) for " & forum & " " & LTrim$(ssections) Exit Sub EndOfLibrary_error: If Err<>9 Then errmsg = FullErrorMessage() If InStr(errmsg, "No library sections specified in request")>0 Then LogResult "Error while downloading library from "+forum+" - no valid library section(s) selected" Else LogResult "Error while downloading library from "+forum+" error : " + errmsg End If ok = False End If Resume EndOfLibrary_ok End Sub 'T:SearchLibrary (subroutine) (CompuServe) Sub SearchLibrary(id As String, forum As String, catalog As String, _ ssections As String, filename As String, uploadby As String, _ age As String, accesscount As String, keywords As String, _ title As String, description As String, full As String) NewSearchLibrary id, forum, catalog, ssections, filename, uploadby, _ age, accesscount, keywords, title, description, _ full, "n" End Sub Function CheckLibraryBeforePosting(id As String, topic As String, section As Integer) As Boolean Dim i As Integer If Not HMIGotoForum(topic) Then LogResult id + " : Failed : Unable to upload file." Exit Function End If If FAPconfig.wRestrictions And FAP_NO_LIBRARY_SEND Then LogResult id + " : Failed : Uploading not allowed in forum " & topic Exit Function End If section = Val(SectionNumber(topic)) If (FAPconfig.svLibSections And (2 ^ section)) = 0 Then LogResult id + " : Failed : Unknown section " & topic Exit Function End If CheckLibraryBeforePosting = True End Function 'T:UploadFile (subroutine) (CompuServe) Sub UploadFile(id As String, forum As String, filename As String, _ ftype As String, keywords As String, title As String, _ msgfile As String) Dim path As String, sname As String, body As String, nState As Integer Dim section As Integer, SourceFileNum as Integer, SourceFileAt as Long Dim SourceFileLen as Long, TheData as String, BytesToRead as Long Dim i As Integer, iType As Integer If Not CheckLibraryBeforePosting(id, forum, section) Then Exit Sub End If Terminal.Print "Uploading file " + filename + Basic.Eoln$ ' Does the file exist ? If Not FileExists(filename) Then LogResult "File doesn't exist" Exit Sub End If SourceFileLen = FileLen(filename) If SourceFileLen <= 0 Then LogResult "Can't upload file" Exit Sub End If SplitPath filename, path, sname iType = Val(ftype) ' Overwrite and reset file download counts If FAPSendFileInfo(section, SourceFileLen, iType, 3, sname, title, keywords)=0 Then LogResult "Failed sending file info" Exit Sub End If ' Send the abstract body = ReadMessageFile(msgfile, 0) If FAPSendFileAbstract(body, 3, "", Session.LoginName)=0 Then LogResult "Failed sending file abstract" Exit Sub End If ' Send the file On Error Goto UploadFile_error BytesToRead = SourceFileLen SourceFileNum = FreeFile() Open filename for Binary Access Read Shared as #SourceFileNum SourceFileAt = 1 'read point TheData = String$(BlockSize, " ") nState = 0 ' Operate on blocks of BlockSize at a time Do While BytesToRead > BlockSize Terminal.TransferStatus True, filename, SourceFileAt-1, SourceFileLen Get #SourceFileNum, SourceFileAt, TheData i = FAPSendFileData(iType, TheData, nState) BytesToRead = BytesToRead - BlockSize SourceFileAt = SourceFileAt + BlockSize nState = 1 Loop ' Now do the last block of less than BlockSize If BytesToRead > 0 then TheData = String$(BytesToRead, " ") Get #SourceFileNum, SourceFileAt, TheData i = FAPSendFileData(iType, TheData, nState) End If Terminal.TransferStatus True, filename, SourceFileLen, SourceFileLen i = FAPSendFileData(iType, "", nState) Close #SourceFileNum Terminal.TransferStatus ReportSuccess id & " : " & filename & " was uploaded to " & forum Exit Sub UploadFile_error: Terminal.TransferStatus LogResult "Error in UploadFile : " + FullErrorMessage() Close #SourceFileNum Exit Sub End Sub Sub UpdateLibrary(id As String, forum As String, sdate As String) Dim sect As String sect = SectionNumber(forum) forum = ParseString(forum, "/") SearchLibrary id, forum, "", sect, "", "", sdate, "", "", "", "", "y" End Sub 'T:UserLog (subroutine) (CompuServe) Sub UserLog(id As String, forum As String) If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to collect user log from "+forum Exit Sub End If If Not Nisa Then AsciiUserLog id, forum Exit Sub End If Terminal.Print "Collecting forum user log ... Please wait"+Basic.Eoln$ RecordBulletins forum, False, False, True If id<>"" Then ReportSuccess id & " : User log collected from " & forum End Sub 'T:RecordSectionInformation (subroutine) (CompuServe) Sub RecordSectionInformation(forum As String) Dim i As Integer, buf As String StartCapturing forum+"/Announcements", "CompuServe", True CaptureLine "Sections" If (FAPconfig.wAlerts And FAP_IS_SYSOP%)<>0 Then CaptureLine "SYSOP" If (FAPconfig.wAlerts And FAP_FREE_USER%)<>0 Then CaptureLine "Free Flag" If (FAPconfig.wAlerts And FAP_NISA_FORUM%)<>0 Then CaptureLine "NISA Forum" If (FAPconfig.wRestrictions And FAP_NO_PRIVATE_MSGS%)<>0 Then CaptureLine "Private Messages not allowed" Else CaptureLine "Private Messages are allowed" End If CaptureLine "" On Error Resume Next ' Get the message section names for the forum from Compuserve CaptureLine "Message Sections Available:" For i = 0 To UBound(szMsgSection) buf = Str(szMsgSection(i).cId)+" "+szMsgSection(i).lpTitle ReplaceAnyInString buf, "_", " " CaptureLine buf Next CaptureLine "" ' Get the library section names for the forum from Compuserve CaptureLine "Libraries Available:" For i = 0 To UBound(szLibSection) buf = Str(szLibSection(i).cId)+" "+szLibSection(i).lpTitle ReplaceAnyInString buf, "_", " " CaptureLine buf Next FinishCapturing End Sub