comparison src/scanner.cpp @ 244:ef97c7cd4a6e stable-6-0-27

const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
author Carl Byington <carl@five-ten-sg.com>
date Mon, 15 Aug 2011 21:08:11 -0700
parents c0d2e99c0a1d
children f92f24950bd3
comparison
equal deleted inserted replaced
243:b4bcc42c30ef 244:ef97c7cd4a6e
138 public: 138 public:
139 fsa(const char *myname_, state init, fsa *next1_, fsa *next2_, recorder *memory_); 139 fsa(const char *myname_, state init, fsa *next1_, fsa *next2_, recorder *memory_);
140 void push(u_char *buf, int len); 140 void push(u_char *buf, int len);
141 void pusher(); 141 void pusher();
142 void validhost(); 142 void validhost();
143 void error(char *err); 143 void error(const char *err);
144 }; 144 };
145 145
146 146
147 typedef state PARSE[end_state]; 147 typedef state PARSE[end_state];
148 148
1233 next1 = next1_; 1233 next1 = next1_;
1234 next2 = next2_; 1234 next2 = next2_;
1235 memory = memory_; 1235 memory = memory_;
1236 } 1236 }
1237 1237
1238 void fsa::error(char *err) { 1238 void fsa::error(const char *err) {
1239 count = 0; 1239 count = 0;
1240 st = init; 1240 st = init;
1241 if (err) memory->syslog(err); 1241 if (err) memory->syslog(err);
1242 } 1242 }
1243 1243
1251 // remove trailing periods 1251 // remove trailing periods
1252 while (count && (pending[count-1]== '.')) pending[--count] = '\0'; 1252 while (count && (pending[count-1]== '.')) pending[--count] = '\0';
1253 if (!count) return; // empty string 1253 if (!count) return; // empty string
1254 if (!strchr((const char *)pending, '@')) { 1254 if (!strchr((const char *)pending, '@')) {
1255 // not an email address or message id 1255 // not an email address or message id
1256 char *p1 = strchr((const char *)pending, '.'); 1256 const char *p1 = strchr((const char *)pending, '.');
1257 char *p2 = strrchr((const char *)pending, '.'); 1257 const char *p2 = strrchr((const char *)pending, '.');
1258 char *p3 = strstr((const char *)pending, ".."); 1258 const char *p3 = strstr((const char *)pending, "..");
1259 if (p1 && (p1 != (char*)pending) & !p3) { 1259 if (p1 && (p1 != (char*)pending) & !p3) {
1260 // have a period, so at least two components, and no empty components 1260 // have a period, so at least two components, and no empty components
1261 in_addr ip; 1261 in_addr ip;
1262 if (inet_aton((const char*)pending, &ip)) { 1262 if (inet_aton((const char*)pending, &ip)) {
1263 // have an ip address if at least two periods 1263 // have an ip address if at least two periods
1352 case u_reco: { 1352 case u_reco: {
1353 if (count > 11) { // need some minimal length host name after the protocol 1353 if (count > 11) { // need some minimal length host name after the protocol
1354 pending[--count] = '\0'; // null terminate host name by overwriting the terminator 1354 pending[--count] = '\0'; // null terminate host name by overwriting the terminator
1355 // must start with protocol 1355 // must start with protocol
1356 if (strncasecmp((const char *)pending, "http", 4) == 0) { 1356 if (strncasecmp((const char *)pending, "http", 4) == 0) {
1357 char *p = strrchr((const char *)pending, '/'); 1357 const char *p = strrchr((const char *)pending, '/');
1358 if (p) { 1358 if (p) {
1359 count = strlen(p+1); 1359 count = strlen(p+1);
1360 memmove(pending, p+1, count+1); 1360 memmove(pending, p+1, count+1);
1361 validhost(); 1361 validhost();
1362 } 1362 }