Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
717 B

  1. #include "fmt.h"
  2. #include "textcode.h"
  3. #include "haveinline.h"
  4. static inline int fromhex(char c) {
  5. if (c>='0' && c<='9') return c-'0';
  6. if (c>='A' && c<='F') return c-'A'+10;
  7. if (c>='a' && c<='f') return c-'a'+10;
  8. return -1;
  9. }
  10. unsigned int scan_quotedprintable(const char *src,char *dest,unsigned int *destlen) {
  11. register const unsigned char* s=(const unsigned char*) src;
  12. unsigned long written=0,i;
  13. for (i=0; s[i]; ++i) {
  14. if (s[i]=='=') {
  15. int j=fromhex(s[i+1]);
  16. if (j<0) break;
  17. dest[written]=j<<4;
  18. j=fromhex(s[i+2]);
  19. if (j<0) break;
  20. dest[written]|=j;
  21. i+=2;
  22. } else {
  23. dest[written]=s[i];
  24. }
  25. ++written;
  26. }
  27. *destlen=written;
  28. return i;
  29. }