ÿþUnicode. {SO-NeÁTJSèR
/***************************************************************************
* *
* Explicit Distribution Declaration *
* This program is not welcomed to be modified or used by, or, if *
* possible, redistributed to people who discriminate against people *
* based solely on race, gender or sexual orientation. *
* *
***************************************************************************/
/***************************************************************************
Copyright 2010 Allen Tse
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
***************************************************************************/
EZ Comm is an easy TCP/UDP communication tool displaying everything it
receives and sending everything you input. Only graphical interface
supported so far. If source code is downloaded and you want to build the
application yourself, Ultimate++ is needed.
The interface is split into two parts, local and remote. If no local
address is input, all interfaces are tried. If no local port is input,
a valid one is automatically chosen. If listening is requested, remote
address and port are not needed to be provided. When an action is requested
without necessary information, such as address or port, corresponding
input fields will be marked out.
If an address frequently sends data to another address within a period, it
may be flooding or attacking. When anti-flood is enabled, the length of this
period and the number of messages that triggers this function can both be
configured. The flooding party will be disconnected and its address will be
added to blacklist, so that within some time (the length of this period can
be configured, too) it will still be blocked.
Logging can be enabled. A log file is an XML file, versioned 1.0. The root
node is Document. The first child node's name is EZ_Comm and the file's
type, program's version and link are the node's attributes. Type can be
log (described in this paragraph), bat (automatic mode guide file, described
in the next paragraph) or cfg (not supported yet). Information is added as
other nodes and system's time will be their attributes.
Three modes are supported, keyboard, file and automatic mode. Automatic
mode is under construction.
In keyboard mode, what user input is sent directly in ASCII.
In file mode, user chooses a file to send. An ASCII 1 is the first byte in
the outgoing buffer. Then comes the file name, packet number and file content
length, all in separate angle brackets. And after that, the file's content is
appended. When a file is received in this mode, user is prompted to save it or
discard it. Only after a former incoming file is dealt with will another file
be prompted.
In automatic mode, a batch file is needed so that this program can work on
its own. Refer to log file format for general information. The EZ_Comm node
can have an optional attribute to save log file. Its name is log and its value
is the file's name. The link attribute is optional.
All nodes after the first action node (refer to the text below), including
the first action node, can have attribute bookmark, whose value should be
unique across the file, to mark a position in the procedure. The name
ezcomm.start is reserved which marks the first action node.
Other nodes with the names in the table below are processed. These nodes
are referred to as action nodes. The first action node must be on the same
level as EZ_Comm node. If and only if an action's result is successful (refer
to if description in the table below), its sub-nodes will be processed. Note
that though some attribute values are ignored, they must be provided according
to XML format.
+----------------------------------------------------------------------------+
| node name | attribute or BODY | result (or variable RESULT) |
|------------+-------------------------------+-------------------------------|
| compute | *get - variable name. That | A variable name followed by |
| | variable's value will be | a number, string, boolean, |
| | used as an operand. | or another variable name, |
| | *number - variable name when | can set the left operand. |
| | setting an number. | Converting an number to or |
| | *string - variable name when | from a string is allowed. |
| | setting a string. | RTTP_RGHT - succeeded |
| | *boolean - variable name when | RTTP_MNER - data types |
| | setting a boolean. | mismatch |
| | *operator - one of operators, | RTTP_CRER - incomplete |
| | +, -, *, / for integers. One | attributes |
| | of operators, append, find, | Variable VALUE stores final |
| | length, remove for strings. | result when not setting a |
| | (Attributes below cannot be | variable. The results of |
| | operands.) | find and length are numbers. |
| | *time - to get current time | remove sets no result. |
| | | Variable VALUE stores current |
| | *tick - to get current system | date and time. |
| | tick | Variable VALUE stores current |
| | | system tick. |
|------------+-------------------------------+-------------------------------|
| if | *get, integer, string, or | Booleans are checked against |
| | boolean - same as in compute | TRUE. Numbers are checked |
| | *operator - one of operators, | against non-zero. Refer to |
| | <, >, <=, >= for integers | comments after this table for |
| | (default is equality test) | strings. |
| | *operator - ~=, to compare | If no operators provided, |
| | strings, case insensitive | last RESULT will be used. |
| | (default is case sensitive) | If result is TRUE, sub-nodes |
| | | are processed. Otherwise |
| | | not. no RESULT is set. |
|------------+-------------------------------+-------------------------------|
| else | (Same as if) | (Same as if, except that the |
| | | result is checked against |
| | | FALSE.) |
|------------+-------------------------------+-------------------------------|
| flow | *loop - number of loops that | (No result. Sub-nodes should |
| | the sub-nodes will be | be the procedures to loop |
| | processed. | in the case of loop. Other |
| | *goto - bookmark to go to. | Other usages neglect |
| | (Default is to go out of | sub-nodes.) |
| | current loop.) | |
|------------+-------------------------------+-------------------------------|
| interact | *procedure - command line to | Variable VALUE stores the |
| | envoke. Values or get can | command's return value. |
| | be after this to append | |
| | parameters. | |
| | *get, integer, string, or | |
| | boolean - to append | |
| | characters to the command | |
| | line. Multiple settings | |
| | supported. | |
| | (Attributes below cannot be | |
| | used with procedure. And the | |
| | ones except wait cannot be | |
| | used with the ones except | |
| | wait, among following | |
| | attributes.) | |
| | *file - file name if a file | RTTP_RGHT - data or file |
| | is anticipated (EZ Comm | received. If a file is |
| | format). Blank will save | received, variable FILE |
| | original file name under | stores its name. Otherwise, |
| | running directory. | variable DATA stores data. |
| | *data - if some data is | RTTP_CRER - failed such as |
| | anticipated. Value ignored. | insufficient memory |
| | *auto - if a file or some | |
| | data is anticipated, decided | |
| | according to EZ Comm format, | |
| | i.e., ASCII 1 as first byte. | |
| | Value ignored. | |
| | *wait - in seconds. if | RTTP_NOER - timeout |
| | negative, this timing will | |
| | not be stopped by an | |
| | incoming packet. Attributes | |
| | after this are neglected. | |
|------------+-------------------------------+-------------------------------|
| log | *get or string - to append | |
| | characters to logging as | |
| | text, if logging is enabled. | |
| | *raw - if the characters need | |
| | to be stored as CDATA. | |
| | *BODY - more text logging. | |
|------------+-------------------------------+-------------------------------|
| listen | *laddress - local address | RTTP_RGHT - succeeded |
| | *lport - local port | RTTP_NOER - already listening |
| | *method = TCP or UDP(default) | RTTP_MNER - failed such as |
| | connected - bookmark to go to | binding failed |
| | when a client connected | RTTP_CRER - failed such as |
| | disconnected - bookmark to go | insufficient memory |
| | to when disconnected | |
|------------+-------------------------------+-------------------------------|
| connect | (same as listen, plus) | (same as listen, plus) |
| | raddress - remote address | If succeeded, variable |
| | rport - remote port | SESSION stores session ID. |
|------------+-------------------------------+-------------------------------|
| send | *raddress - remote address | RTTP_RGHT - succeeded |
| | for UDP | RTTP_MNER - if failed such no |
| | *rport - remote port for UDP | corresponding session ID |
| | session - session ID for TCP | RTTP_CRER - failed such as |
| | *file - file name if a file | insufficient memory |
| | is to be sent | |
| | *BODY(default is zero length) | |
| | - text if it is to be sent | |
|------------+-------------------------------+-------------------------------|
| disconnect | *session - session ID for TCP | RTTP_RGHT - succeeded |
| | (default is all sessions) | RTTP_MNER - if failed such as |
| | | no corresponding session ID |
+----------------------------------------------------------------------------+
* = optional.
Once connected, it cannot listen or connect before disconnection.
All incoming connection requests and packet are discarded if not mentioned
to receive in interact.
Numbers are stored in the type of double.
Booleans are either TRUE or FALSE.
Normal strings are checked against non-empty. The returned values RTTP_RGHT,
RTTP_NOER, RTTP_MNER, RTTP_CRER, are special strings. Their values can be
checked with numbers, equaling to 4 to 1, respectively. And the former two can
be regarded as boolean TRUE, while the latter two as FALSE, when being
checked. Operators append and find needs both left and right operands to be
strings. The right operand is appended to the left or searched within the left
respectively. Operand remove needs left operand to be a string and
right operand to be a number, which indicates the number of characters to be
removed from the string's beginning and negative numbers mean the removal
occurs at its end. Operand length needs left operand to be a string and has
no right operand.
Allen
Oct. 25, 2010
/***************************************************************************
* *
* fnxÑS^ðXf *
* ,gz^
N"kÎù[ºN gÍyÏe0'`+Rb'`ÖSTgkÆvºNëXîO9e0O(uÿNYg *
* ïSývÝ_N
N[TvQ Od0 *
* *
***************************************************************************/
/***************************************************************************
HrCg 2010 Allen Tse
,geöNåNthe Apache License, Version 2.0ÿåNN{ðycCg ÿcCgÿåNN-NeûÑ
v^^[¹eûÑÿÅNOÂSÿhINåNñeSe:NÆQ ÿ0
¨`
NýYåN
Nu[cCgv¹e_O(ueöN0
¨`ïSåNïSåNÎNåNN0W@W_0RcCgv÷bÿ
http://www.apache.org/licenses/LICENSE-2.0
d^Qf1uNgbLÕl_bbTavÿåNcCgÑS^voöNúWN ,gb__ ÿàeº
>f_b_ÿý¡l gûNUOb__vÝOÁbagöN0cCg-NsQNyr[ív¸ïSTP6Rÿ
æÁcCgSe0
***************************************************************************/
fáO/fN*N{USvTCP/UDPáOå]wQ0[ïSåN>f:y6e0RvT¨`eQv^ÑSve,g0
°s(WØêS/ecþVb_Lub0YgN}nxêñ]ÑÿRO(uUltimate++0
LubR:N,g0WTù[ïz$NèR0Yg
NQ,g0W0W@WÿRÑ~[@b g0W@WÿYg
NQ
,g0WïzãSÿRê¨R ébN*NïS(uv0S_Bl Ñv,T öeÿ
NÅ_kXQÜïzIPTïzãS0(W«
BlÛLÐg*N¨R\O*gÐcOÅ_áOo`ÿY0W@WbïzãSöeÿù[^veQFhO«h:yúQeg0
YgN*N0W@W(WNµköeô
QA~Tù[¹eÑSpencÿR gïSý/fQÜ~;eûQ0S_Sb_
2bk;eûQRýöeÿYöeô
Q6e0RY\mo`ÿ/fïSåNMnv0(W«;eûQöeÿOe_N
Ù*N0W@WváOÿN\vQ>eeQÑ
TUSÿ(WNµköeôÿÙ*Nöeôíw_N/fïSMv ÿ
Q
ÍN6qO\=
[0
Allen
NË%NË%t^ASgNASNåe