| 912 | } |
| 913 | |
| 914 | int |
| 915 | HttpBodySet::init(char *set, char *dir) |
| 916 | { |
| 917 | int fd, lineno, lines_added = 0; |
| 918 | char info_path[MAXPATHLEN]; |
| 919 | |
| 920 | char buffer[1024], name[1025], value[1024]; |
| 921 | |
| 922 | ink_filepath_make(info_path, sizeof(info_path), dir, ".body_factory_info"); |
| 923 | fd = open(info_path, O_RDONLY); |
| 924 | if (fd < 0) { |
| 925 | return -1; |
| 926 | } |
| 927 | |
| 928 | this->set_name = ats_strdup(set); |
| 929 | this->table_of_pages.reset(new TemplateTable); |
| 930 | |
| 931 | lineno = 0; |
| 932 | |
| 933 | while (true) { |
| 934 | char *name_s, *name_e, *value_s, *value_e, *hash; |
| 935 | |
| 936 | ++lineno; |
| 937 | int bytes = ink_file_fd_readline(fd, sizeof(buffer), buffer); |
| 938 | if (bytes <= 0) { |
| 939 | break; |
| 940 | } |
| 941 | |
| 942 | /////////////////////////////////////////////// |
| 943 | // chop anything on and after first '#' sign // |
| 944 | /////////////////////////////////////////////// |
| 945 | |
| 946 | hash = index(buffer, '#'); |
| 947 | if (hash) { |
| 948 | *hash = '\0'; |
| 949 | |
| 950 | //////////////////////////////// |
| 951 | // find start and end of name // |
| 952 | //////////////////////////////// |
| 953 | } |
| 954 | name_s = buffer; |
| 955 | while (*name_s && ParseRules::is_wslfcr(*name_s)) { |
| 956 | ++name_s; |
| 957 | } |
| 958 | |
| 959 | name_e = name_s; |
| 960 | while (*name_e && ParseRules::is_http_field_name(*name_e)) { |
| 961 | ++name_e; |
| 962 | } |
| 963 | |
| 964 | if (name_s == name_e) { |
| 965 | continue; // blank line |
| 966 | } |
| 967 | |
| 968 | ///////////////////////////////// |
| 969 | // find start and end of value // |
| 970 | ///////////////////////////////// |
| 971 |
no test coverage detected