File: conv.mac

package info (click to toggle)
linpac 0.16pre3-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,328 kB
  • ctags: 2,582
  • sloc: cpp: 16,514; sh: 7,991; ansic: 4,061; makefile: 211; perl: 101
file content (178 lines) | stat: -rw-r--r-- 3,886 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
:macro Convers
echo
echo Convers server LinPac %V
echo Login %C at %T
echo
if %(exist STN_NICKNAME) = 1
  echo Hello %STN_NICKNAME, welcome to the conference !
else
  echo Hellp %N, welcome to the conference !
endif
echo Type /H for help
echo

;;*********************** INICIALIZACE ************************
set CONVERS "LP_CONVERS"  ;;For recognition channels in convers
set LOGTIME %T            ;;Login time
set CALL %C               ;;Callsign
if "%N" = "%U"            ;;Get user's name
  set NAME "???"
else
  set NAME "%N"
endif
set LAST "%<"
set OUT1 ""
set OUT2 ""
set OUT3 ""
set OUT4 ""
set OUT5 ""
set OUT6 ""
set OUT7 ""
set OUT8 ""
set MSG1 ""
set MSG2 ""
set MSG3 ""
set MSG4 ""
set MSG5 ""
set MSG6 ""
set MSG7 ""
set MSG8 ""

set LAST "*** Enters the conference at %T ***"
conv @SENDALL

label MAIN

  flush

  ;;**** CHECK MESSAGES FROM OTHER CHANNELS ****
  set i 1
  label TESTOUT
    if "%OUT%i" <> ""      ;;Comething to send ?
      echo <%C@%i>         ;; YES - print callsign 
      echo %OUT%i          ;;       print message
      set OUT%i ""         ;;       clear buffer
      flush
    endif
    if "%MSG%i" <> ""      ;;The same for personal messages
      echo *%C@%i*
      echo %MSG%i
      set MSG%i ""
      flush
    endif
    set i %[%i+1]
  if (%i <= 8) goto TESTOUT  ;;Repeat for all channels

  set LAST "%<"              ;;Some new entry ?

if ("%LAST" = "") goto MAIN

  ;;SOME USER ENTRY
  if ("%(strleft 1 "%LAST")" = "/") goto COMMAND ;;Begins with slash - it's command

  conv @SENDALL ;;Not a command - send to all as text
goto MAIN

;;**** SEND THE STRING TO ALL STATIONS ****
label SENDALL
  set I 1
  label SENDING
    if "%CONVERS@%I" = "LP_CONVERS"    ;;If the channel is in conference
      if %I <> %K                      ;; (and it's not our channel)
        set@%I OUT%K "%LAST"           ;;Send the text
      endif
    endif
    set I %[%I+1]
  if (%I <= 8) goto SENDING
return


;; **** COMMAND RECOGNITION ****
label COMMAND
set CMD "%(Upcase %LAST)"
if (%CMD = /Q) goto KONEC
if (%CMD = /H) goto HELP
if (%CMD = /W) goto WHO
if (%CMD = /U) goto WHO
if (%(strleft 4 "%CMD") = "/MSG") goto MSGS
echo *** Unknown command.
goto MAIN


;; ************************ COMMAND /H  **************************
label HELP
echo *** Available commands
echo   /H           -  this help
echo   /MSG <call>  -  send personal message
echo   /Q           -  logout
echo   /W nebo /U   -  list users
echo ***
goto MAIN


;; ************************ COMMAND /MSG *************************
label MSGS

;; REMOVE '/MSG'
set I %(strpos " " "%LAST")
if (%I = 0) goto MSGERROR
set I %[%(strlen %LAST) - %I - 1]
set LAST "%(strr %I "%LAST")"

;; SPLIT THE MESSAGE AND CALLSIGN
set I %(strpos " " "%LAST")
if (%I = 0) goto MSGERROR
set MSGC "%(strleft %I "%LAST")"
set MSGC "%(upcase "%MSGC")"
set I %[%(strlen "%LAST") - %I - 1]
set LAST "%(strr %I %LAST)"

;; FIND THE CALLSIGN
set FND 0
set I 1
label CMSGS
  if %CALL@%I = %MSGC
    set@%I MSG%K "%LAST"
    set FND 1
  endif
  set I %[%I+1]
if (%I < 9) goto CMSGS
if %FND = 0
  echo *** No such user in the conference
endif
unset MSGC FND
goto MAIN

;; Chyba pri MSGS
label MSGERROR
echo *** You must enter the callsign and the message
goto MAIN


; ************************ COMMAND /W **********************
label WHO
echo *** List of users:
set I 1
label CWHO
  if "%CONVERS@%I" = "LP_CONVERS"
    echo %CALL@%I - %NAME@%I - connected since %LOGTIME@%I
  endif
  set I %[%I+1]
if (%I < 9) goto CWHO
echo ***
goto MAIN


; ************************ LOGOUT ***********************
label KONEC
set LAST "*** Leaves conference at %T ***"
echo Logout at %T.
if %(exist STN_NICKNAME) = 1
  echo Come again, %STN_NICKNAME !
else
  echo Come again, %N !
endif
conv @SENDALL
unset CONVERS LOGTIME CALL NAME I CMD
unset OUT1 OUT2 OUT3 OUT4 OUT5 OUT6 OUT7 OUT8
unset MSG1 MSG2 MSG3 MSG4 MSG5 MSG6 MSG7 MSG8