On Sat, 27 Jun 1998, James Turner wrote: >> void verify_function(int (vnum/rnum), char * write, int len) >> { >> int c = 0; >> *write = '\0'; >> >> if (...) >> c += snprintf(write + c, len - c, "...", ...); >> if (,,,) >> c += snprintf(write + c, len - c, ",,,", ,,,); >> >> ...etc... >> } > >Won't quite do it. A given verify function is called multiple times. >If you called it as > >verify_function(rnum, buf, MAX_STRING_LENGTH); > >ten times in a row, you might overflow. You'd have to use: > >verify_function(rnum, buf + strlen(buf), MAX_STRING_LENGTH - strlen(buf)); Ok, make the function an 'int' returning 'c'. c += verify_function(rnum, buf + c, MAX_STRING_LENGTH - c); With appropriate checks for 0 space left and such. -- George Greer, greerga@circlemud.org | Genius may have its limitations, but http://patches.van.ml.org/ | stupidity is not thus handicapped. http://www.van.ml.org/CircleMUD/ | -- Elbert Hubbard +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST