Change fread_flag to me something that reads a string. Query the flag string
pass it to stread_string:
(will require modificationm, because 'str'/str_pos are global on my mud)
long stread_flag(char *str)
{
int number;
char c;
bool negative = FALSE;
do {
c = str[str_pos];
str_pos++;
}
while (isspace((int)c));
if (c == '-') {
negative = TRUE;
c = str[str_pos];
str_pos++;
}
number = 0;
if (!isdigit((int)c)) {
while (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) {
number += flag_convert(c);
c = str[str_pos];
str_pos++;
}
}
while (isdigit((int)c)) {
number = number * 10 + c - '0';
c = str[str_pos];
str_pos++;
}
if (c == '|')
number += stread_flag(str);
else if (c != ' ')
str_pos--;
if (negative)
return -1 * number;
return number;
}
>
>Firstly, fread_flag. Unfortunately, this function looks for a file to
>read from, and the idea behind moving everything to SQL is to
>get things
>AWAY from the file structure and into the db structure itself.
>Fwrite_flag tends to work for getting the flag TO the structure, but
>fread_flag won't read it back. For the most part, it's not hard to use
>flag_convert, as that's not depending on a file, but if there's more
>than one flag, then you're pretty much screwed. How can this be handled
>differently? Is there a way to strcpy the row, then split it up into
>individual letters, tossing THEM into flag convert?
>
>Secondly, the issue with escape sequences. For the MOST part, the
>following will work in order to insert mobs/rooms/objects into the
>database itself:
>
Here's an old exmaple I've used. it's pretty ugly, but works.
void convert_string(char *old_string)
{
/* you cannot pass a string constant to this function */
char *new_string;
int i,j=0;
int len;
if (strlen(old_string)<1) return;
new_string=malloc(strlen(old_string)*2);
len=strlen(ld_string);
for (i=0; i<len; i++) {
if (old_string[i]=='"'){
new_string[j]='\\';
j++;
}
else if (old_string[i]=='\\'){
new_string[j]='\\';
j++;
}
else if (old_string[i]=='\''){
new_string[j]='\\';
j++;
}
new_string[j]=old_string[i];
j++;
}
new_string[j]=0;
strcpy(old_string, new_string);
free(new_string);
}
>That's an example of how I've dealt with the socials for example (yeah,
>socials shouldn't have a tick in the name, but never can be too
>careful). The problem is that there's a FEW mobs/rooms/objects
>out there
>that have more than one tick in their description, and that trick will
>only work for the first one, so the rest don't even make it to the
>database.
>
>Sure, I've tried: mysql_escape_string(cleaned, argument,
>strlen(argument)); , but either that doesn't work, or I'm missing
>something in how to do it. In the above case, the example would be as
>follows:
>
>Name=str_dup(social_table[social].name);
>Mysql_escape_string(cleaned, name, strlen(name));
>If I'm not mistaken, that's how it SHOULD be set up right? At
>that, it's
>still missing most of the mobs/areas.
>
>I apologize if the thread seems a bit off topic, or even if I
>seem to be
>too much of a newbie in these matters. Fact of the matter is that I'm
>learning as I go (the best way to get experience from what I've found).
>I'm a quick student, but sometimes I run across things that kind of
>confuse me:).
>
>
>+----------------------------------------------------+
>+ TJW: Head Tech, designer: Dreamless Realms Mud +
>+ Mud : http://drealms.kyndig.com +
>+ Telnet: drealms.kyndig.com port 9275 +
>+ OLC Docs: http://olc.kyndig.com +
>+----------------------------------------------------+
>
>
>
>
>
>--
>ROM mailing list
>[email protected]
>http://www.rom.org/cgi-bin/mailman/listinfo/rom
>