Whitespace/readability fixes.

This commit is contained in:
Vlad Grigorescu 2014-08-06 11:02:18 -05:00
parent 49a2198dd5
commit 023661fb19

View file

@ -1,10 +1,12 @@
###
#
# All information is from the MySQL internals documentation at:
# <http://dev.mysql.com/doc/internals/en/connection-phase.html>
# <http://dev.mysql.com/doc/internals/en/client-server-protocol.html>
#
###
# Basic Types
type uint24le = record {
byte3 : uint8;
byte2 : uint8;
@ -49,12 +51,13 @@ type LengthEncodedString = record {
else
return 0;
}
};
%}
extern type to_int;
# Enums
enum command_consts {
COM_SLEEP = 0x00,
COM_QUIT = 0x01,
@ -106,12 +109,7 @@ enum Expected {
type NUL_String = RE/[^\0]*/;
type Header = record {
le_len: uint24le;
seq_id: uint8;
} &let {
len : uint32 = to_int()(le_len) + 4;
} &length=4;
# MySQL PDU
type MySQL_PDU(is_orig: bool) = record {
hdr : Header;
@ -120,18 +118,27 @@ type MySQL_PDU(is_orig: bool) = record {
true -> client_msg: Client_Message(state);
} &requires(state);
} &let {
state = $context.connection.get_state();
state : int = $context.connection.get_state();
} &length=hdr.len &byteorder=bigendian;
type Header = record {
le_len: uint24le;
seq_id: uint8;
} &let {
len : uint32 = to_int()(le_len) + 4;
} &length=4;
type Server_Message(seq_id: uint8) = case seq_id of {
0 -> initial_handshake: Initial_Handshake_Packet;
default -> command_response : Command_Response;
};
type Client_Message(state: int) = case state of {
CONNECTION_PHASE -> connection_phase: Handshake_Response_Packet;
COMMAND_PHASE -> command_phase : Command_Request_Packet;
};
type Server_Message(seq_id: uint8) = case seq_id of {
0 -> initial_handshake: Initial_Handshake_Packet;
default -> command_response : Command_Response;
};
# Handshake Request
type Initial_Handshake_Packet = record {
protocol_version: uint8;
@ -163,6 +170,8 @@ type Handshake_v9 = record {
scramble : NUL_String;
};
# Handshake Response
type Handshake_Response_Packet = case $context.connection.get_version() of {
10 -> v10_response : Handshake_Response_Packet_v10;
9 -> v9_response : Handshake_Response_Packet_v9;
@ -191,6 +200,8 @@ type Handshake_Response_Packet_v9 = record {
password : bytestring &restofdata;
};
# Command Request
type Command_Request_Packet = record {
command : uint8;
arg : bytestring &restofdata;
@ -198,6 +209,8 @@ type Command_Request_Packet = record {
update_expectation : bool = $context.connection.set_next_expected(EXPECT_COLUMN_COUNT);
};
# Command Response
type Command_Response = case $context.connection.get_expectation() of {
EXPECT_COLUMN_COUNT -> col_count : ColumnCount;
EXPECT_COLUMN_DEFINITION -> col_defs : ColumnDefinitions;
@ -298,6 +311,7 @@ type EOF_Packet = record {
status : uint16;
};
# State tracking
refine connection MySQL_Conn += {
%member{