Beispiel #1
0
 unsafe int inp_peek(ref ud u)
 {
     if (u.inp_end == 0)
     {
         if (u.inp_buf != null)
         {
             if (u.inp_buf_index < u.inp_buf_size)
             {
                 return(u.inp_buf[u.inp_buf_index]);
             }
         }
         else if (u.inp_peek != UD_EOI)
         {
             return(u.inp_peek);
         }
         else
         {
             int c;
             if ((c = u.inp_hook(ref u)) != UD_EOI)
             {
                 u.inp_peek = c;
                 return(u.inp_peek);
             }
         }
     }
     u.inp_end      = 1;
     u.error        = 1;
     u.errorMessage = "byte expected, eoi received";
     return(0);
 }
Beispiel #2
0
        //#endif /* __UD_STANDALONE__ */


        /* =============================================================================
         * ud_input_skip
         *    Skip n input bytes.
         * ============================================================================
         */
        static unsafe void ud_input_skip(ref ud u, int n)
        {
            if (u.inp_end > 0)
            {
                return;
            }
            if (u.inp_buf == null)
            {
                while (n-- > 0)
                {
                    int c = u.inp_hook(ref u);
                    if (c == Decode.UD_EOI)
                    {
                        goto eoi;
                    }
                }
                return;
            }
            else
            {
                if (n > u.inp_buf_size ||
                    u.inp_buf_index > u.inp_buf_size - n)
                {
                    u.inp_buf_index = u.inp_buf_size;
                    goto eoi;
                }
                u.inp_buf_index += n;
                return;
            }
eoi:
            u.inp_end      = 1;
            u.error        = 1;
            u.errorMessage = "cannot skip, eoi received\b";
            return;
        }
Beispiel #3
0
 unsafe byte inp_next(ref ud u)
 {
     if (u.inp_end == 0)
     {
         if (u.inp_buf != null)
         {
             if (u.inp_buf_index < u.inp_buf_size)
             {
                 u.inp_ctr++;
                 return(u.inp_curr = u.inp_buf[u.inp_buf_index++]);
             }
         }
         else
         {
             int c = u.inp_peek;
             if ((c = u.inp_hook(ref u)) != UD_EOI)
             {
                 u.inp_peek = UD_EOI;
                 u.inp_curr = (byte)c;
                 u.inp_sess[u.inp_ctr++] = u.inp_curr;
                 return(u.inp_curr);
             }
         }
     }
     u.inp_end      = 1;
     u.error        = 1;
     u.errorMessage = "byte expected, eoi received\n";
     return(0);
 }
Beispiel #4
0
 //#endif /* __UD_STANDALONE__ */
 /* =============================================================================
  * ud_input_skip
  *    Skip n input bytes.
  * ============================================================================
  */
 static void ud_input_skip(ref ud u, int n)
 {
     if (u.inp_end > 0)
     {
         return;
     }
     if (u.inp_buf == null)
     {
         while (n-- > 0)
         {
             int c = u.inp_hook(ref u);
             if (c == Decode.UD_EOI)
             {
                 goto eoi;
             }
         }
         return;
     }
     else
     {
         if (n > u.inp_buf_size ||
             u.inp_buf_index > u.inp_buf_size - n)
         {
             u.inp_buf_index = u.inp_buf_size;
             goto eoi;
         }
         u.inp_buf_index += n;
         return;
     }
     eoi:
     u.inp_end = 1;
     u.error = 1;
     u.errorMessage = "cannot skip, eoi received\b";
     return;
 }
Beispiel #5
0
 unsafe int inp_peek(ref ud u)
 {
     if (u.inp_end == 0)
     {
         if (u.inp_buf != null)
         {
             if (u.inp_buf_index < u.inp_buf_size)
             {
                 return u.inp_buf[u.inp_buf_index];
             }
         }
         else if (u.inp_peek != UD_EOI)
         {
             return u.inp_peek;
         }
         else
         {
             int c;
             if ((c = u.inp_hook(ref u)) != UD_EOI)
             {
                 u.inp_peek = c;
                 return u.inp_peek;
             }
         }
     }
     u.inp_end = 1;
     u.error = 1;
     u.errorMessage = "byte expected, eoi received";
     return 0;
 }
Beispiel #6
0
 unsafe byte inp_next(ref ud u)
 {
     if (u.inp_end == 0)
     {
         if (u.inp_buf != null)
         {
             if (u.inp_buf_index < u.inp_buf_size)
             {
                 u.inp_ctr++;
                 return (u.inp_curr = u.inp_buf[u.inp_buf_index++]);
             }
         }
         else
         {
             int c = u.inp_peek;
             if ((c = u.inp_hook(ref u)) != UD_EOI)
             {
                 u.inp_peek = UD_EOI;
                 u.inp_curr = (byte)c;
                 u.inp_sess[u.inp_ctr++] = u.inp_curr;
                 return u.inp_curr;
             }
         }
     }
     u.inp_end = 1;
     u.error = 1;
     u.errorMessage = "byte expected, eoi received\n";
     return 0;
 }