scan.h (1138B)
1 // Internal line scanner shared by the hdr detect/decode implementations. 2 // 3 // A key line looks like: 4 // 5 // [spaces/tabs] label [spaces/tabs] : [spaces/tabs] value [spaces/tabs] 6 // 7 // where label is public-key or private-key (case-insensitive). Matching is 8 // done against the length-bounded buffer, never assuming NUL-termination. 9 10 #ifndef __SUPERCOP_FMT_HDR_SCAN_H__ 11 #define __SUPERCOP_FMT_HDR_SCAN_H__ 12 13 #include <stddef.h> 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 // which: 1 = public-key, 2 = private-key 20 // Returns 1 and fills which/val/vallen when line holds a key label, 21 // 0 otherwise. val/vallen may point at an empty value; callers decide. 22 int hdr_match_label(const unsigned char *line, size_t linelen, int *which, 23 const unsigned char **val, size_t *vallen); 24 25 // Advance helpers for walking a length-bounded buffer line by line. 26 // Returns 1 while a line (without its '\n') is available. 27 int hdr_next_line(const unsigned char **pos, const unsigned char *end, 28 const unsigned char **line, size_t *linelen); 29 30 #ifdef __cplusplus 31 } // extern "C" 32 #endif 33 34 #endif // __SUPERCOP_FMT_HDR_SCAN_H__