Changeset 481
- Timestamp:
- 03/30/07 09:10:06 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/client-xs-20070328/Cache-Memcached-GetParserXS/GetParserXS.xs
r480 r481 99 99 int state, copy, new_p; 100 100 char *barekey; 101 101 102 102 if (DEBUG) 103 103 printf("get_buffer (nslen = %d)...\n", nslen); … … 109 109 110 110 if (DEBUG) { 111 char first_line[1000];112 int i;113 char *end;114 for (i = 0, end = buf; *end && *end != '\n' && i++ < 900; end++)115 ;116 end += 10;117 strncpy (first_line, buf, end - buf + 1);118 first_line[end - buf + 1] = '\0';119 printf("GOT buf (len=%d)\nFirst line: %s\n", len, first_line);111 char first_line[1000]; 112 int i; 113 char *end; 114 for (i = 0, end = buf; *end && *end != '\n' && i++ < 900; end++) 115 ; 116 end += 10; 117 strncpy (first_line, buf, end - buf + 1); 118 first_line[end - buf + 1] = '\0'; 119 printf("GOT buf (len=%d)\nFirst line: %s\n", len, first_line); 120 120 } 121 121 122 122 if ((c = *p++) == 'V') { 123 123 if (*p++ != 'A' || *p++ != 'L' || *p++ != 'U' || *p++ != 'E' || *p++ != ' ') { 124 if (DEBUG)125 puts ("ERROR: Illegal command beginning with V");126 goto recover_from_partial_line;127 } 128 124 if (DEBUG) 125 puts ("ERROR: Illegal command beginning with V"); 126 goto recover_from_partial_line; 127 } 128 129 129 // Parsing VALUE %s<key> %u<flags> %u<bytes> 130 130 131 131 for (key = p; *p++ > ' ';) 132 ;132 ; 133 133 key_len = p - key - 1; 134 134 if (*(p - 1) != ' ') { 135 if (DEBUG)136 printf ("ERROR: key not space-terminated: key %s, char %c\n", key, *(p - 1));137 goto recover_from_partial_line; 135 if (DEBUG) 136 printf ("ERROR: key not space-terminated: key %s, char %c\n", key, *(p - 1)); 137 goto recover_from_partial_line; 138 138 } 139 139 // Note that key just points into the buffer and is not null-terminated … … 144 144 145 145 for (flags = 0; (c = *p++ - '0') >= 0; flags = flags * 10 + c) 146 ;146 ; 147 147 if (c != (signed char)' ' - '0') { 148 if (DEBUG)149 puts ("ERROR: Flags not space terminated");150 goto recover_from_partial_line; 151 } 152 153 148 if (DEBUG) 149 puts ("ERROR: Flags not space terminated"); 150 goto recover_from_partial_line; 151 } 152 153 154 154 for (itemlen = 0; (c = *p++ - '0') >= 0; itemlen = itemlen * 10 + c) 155 ;155 ; 156 156 if (c != (signed char)'\r' - '0' || *p++ != '\n') { 157 if (DEBUG)158 puts ("ERROR: byte count not CRLF-terminated");159 goto recover_from_partial_line; 157 if (DEBUG) 158 puts ("ERROR: byte count not CRLF-terminated"); 159 goto recover_from_partial_line; 160 160 } 161 161 … … 170 170 171 171 if (DEBUG) { 172 char temp_key[256];173 strncpy (temp_key, key, key_len);174 temp_key[key_len] = '\0';172 char temp_key[256]; 173 strncpy (temp_key, key, key_len); 174 temp_key[key_len] = '\0'; 175 175 printf("key=[%s], state=%d, copy=%d\n", key, state, copy); 176 176 } 177 177 178 178 if (copy) { 179 *(key + key_len) = '\0';// Null-terminate the key in-buffer179 *(key + key_len) = '\0'; // Null-terminate the key in-buffer 180 180 hv_store(ret, barekey, barelen, newSVpv(buf + new_p, copy), 0); 181 181 buf[new_p + copy - 1] = '\0'; … … 221 221 222 222 else if (c == 'E') { 223 223 224 224 // Parsing END 225 225 226 226 if (*p++ == 'N' && *p++ == 'D' && *p++ == '\r' && *p == '\n') 227 return final_answer(self, 1);227 return final_answer(self, 1); 228 228 } 229 229 // Just fall through if after 'E' was not "ND\r\n" 230 230 231 else 232 ; // Unknown command: not 'E' or 'V' at [0]231 else 232 ; // Unknown command: not 'E' or 'V' at [0] 233 233 234 234 … … 304 304 } 305 305 306 MODULE = Cache::Memcached::GetParserXS PACKAGE = Cache::Memcached::GetParserXS306 MODULE = Cache::Memcached::GetParserXS PACKAGE = Cache::Memcached::GetParserXS 307 307 308 308 INCLUDE: const-xs.inc
