Delimiter $
Use'Db _ im '$
Drop Procedure If Exists'P _ bi_parasip '$
Create Definer = 'Root' @ 'localhost' Procedure 'P _ bi_parasip '(
In Pi_ipstr Varchar ( 50 ),
Out po_int1 Int ,
Out po_int2 Int ,
Out po_int3 Int ,
Out po_int4 Int ,
Out po_ret Int
)
Begin
Declare V_strtempVarchar ( 50 );
Declare V_pos Int ;
Declare V_sub Varchar ( 10 );
Declare V_tail Varchar ( 50 );
Declare V_val Int ;
Set V_pos = 0 ;
Set Po_ret = 1 ;
Set V_strtemp = Trim (pi_ipstr );
P: Begin
/* 192.168.1.1 */
Set V_pos = Instr (v_strtemp, ' . ' );
If (V_pos > 0 And Length (v_strtemp) > V_pos) Then
Set V_sub = Substring (V_strtemp, 1 , V_pos - 1 );
Set V_tail = Substring (V_strtemp, v_pos + 1 );
Set V_val = V_sub + 0 ;
If (V_sub Regexp ' ^ [0-9] * $ ' ) = 0 ) Then
Set Po_ret =- 1 ;
Leave P;
Else
Set Po_int1 = V_val;
End If ;
Else
Set Po_ret =- 1 ;
Leave P;
End If ;
/* 168.1.1 */
Set V_pos = Instr (v_tail, ' . ' );
If (V_pos > 0 And Length (v_tail) > V_pos) Then
Set V_sub = Substring (V_tail, 1 , V_pos- 1 );
Set V_tail = Substring (V_tail, v_pos + 1 );
Set V_val = V_sub + 0 ;
If (V_sub Regexp ' ^ [0-9] * $ ' ) = 0 ) Then
Set Po_ret =- 1 ;
Leave P;
Else
Set Po_int2 = V_val;
End If ;
Else
Set Po_ret=- 1 ;
Leave P;
End If ;
/* 1.1 */
Set V_pos = Instr (v_tail,' . ' );
If (V_pos > 0 And Length (v_tail) > V_pos) Then
Set V_sub = Substring (V_tail, 1 , V_pos - 1 );
Set V_tail = Substring (V_tail, v_pos + 1 );
Set V_val = V_sub+ 0 ;
If (V_sub Regexp ' ^ [0-9] * $ ' ) = 0 ) Then
Set Po_ret =- 1 ;
Leave P;
Else
Set Po_int3 = V_val;
End If ;
Else
Set Po_ret =- 1 ;
Leave P;
End If ;
Set V_val = V_tail + 0 ;
If (V_tail Regexp ' ^ [0-9] * $ ' ) = 0 ) Then
Set Po_ret =- 1 ;
Leave P;
Else
Set Po_int4 = V_val;
End If ;
Set Po_ret = 1 ;
End P;
End $
Delimiter;