MCPcopy Create free account
hub / github.com/assaultcube/AC / parseupdatelist

Function parseupdatelist

source/src/tools.cpp:944–969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

942#endif
943
944void parseupdatelist(hashtable<const char *, int> &ht, char *buf, const char *prefix, const char *suffix)
945{
946 for(char *d = buf; *d; d++) if(!isalnum(*d) && !strchr("._-() /\n", *d)) *d = ' '; // allowed chars in media path strings (except ' ')
947 char *p, *l = buf, *m;
948 int rev, *revp, plen = prefix ? (int)strlen(prefix) : 0, slen = suffix ? (int)strlen(suffix) : 0;
949 do
950 {
951 if((p = strchr(l, '\n'))) *p = '\0'; // break into single lines
952 l += strspn(l, " "); // skip leading spaces
953 if((m = strchr(l, ' ')) && (rev = atoi(m + 1))) // string has a space and a number != 0 after it
954 {
955 *m = '\0';
956 if((!plen || !strncmp(l, prefix, plen)) && // prefix is either not required or present
957 (!slen || (m - l > slen && !strcmp(m - slen, suffix)))) // suffix is either not required or present
958 {
959 l += plen; // skip prefix
960 m[-slen] = '\0'; // cut suffix
961 revp = ht.access(l);
962 if(revp) *revp = rev;
963 else ht.access(newstring(l), rev);
964 }
965 }
966 l = p + 1;
967 }
968 while(p);
969}

Callers 1

pingpckserverFunction · 0.85

Calls 2

newstringFunction · 0.85
accessMethod · 0.80

Tested by

no test coverage detected