dec_tail.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. if (srclen-- == 0) {
  2. ret = 1;
  3. break;
  4. }
  5. if ((q = neon64_base64_table_dec[*c++]) >= 254) {
  6. st.eof = 1;
  7. // Treat character '=' as invalid for byte 0:
  8. break;
  9. }
  10. st.carry = q << 2;
  11. st.bytes++;
  12. case 1: if (srclen-- == 0) {
  13. ret = 1;
  14. break;
  15. }
  16. if ((q = neon64_base64_table_dec[*c++]) >= 254) {
  17. st.eof = 1;
  18. // Treat character '=' as invalid for byte 1:
  19. break;
  20. }
  21. *o++ = st.carry | (q >> 4);
  22. st.carry = q << 4;
  23. st.bytes++;
  24. outl++;
  25. case 2: if (srclen-- == 0) {
  26. ret = 1;
  27. break;
  28. }
  29. if ((q = neon64_base64_table_dec[*c++]) >= 254) {
  30. st.eof = 1;
  31. // When q == 254, the input char is '='. Return 1 and EOF.
  32. // Technically, should check if next byte is also '=', but never mind.
  33. // When q == 255, the input char is invalid. Return 0 and EOF.
  34. ret = (q == 254) ? 1 : 0;
  35. break;
  36. }
  37. *o++ = st.carry | (q >> 2);
  38. st.carry = q << 6;
  39. st.bytes++;
  40. outl++;
  41. case 3: if (srclen-- == 0) {
  42. ret = 1;
  43. break;
  44. }
  45. if ((q = neon64_base64_table_dec[*c++]) >= 254) {
  46. st.eof = 1;
  47. // When q == 254, the input char is '='. Return 1 and EOF.
  48. // When q == 255, the input char is invalid. Return 0 and EOF.
  49. ret = (q == 254) ? 1 : 0;
  50. break;
  51. }
  52. *o++ = st.carry | q;
  53. st.carry = 0;
  54. st.bytes = 0;
  55. outl++;
  56. }
  57. }
  58. state->eof = st.eof;
  59. state->bytes = st.bytes;
  60. state->carry = st.carry;
  61. *outlen = outl;
  62. return ret;