okay...i admit it..i have found a problem that i cannot solve. i have been working on it for 3 days solid. i need some help in a very bad way. i'm totally stumped. i've been through all my books, the unix manual...you name it, i have probably tried it. my index files are set to read and write all in all my world dirs...i have even rm'd them and remade them..no luck... here's what i got. i downloaded obuild(i even mailed sammy..he hasnt gotten back yet(2 days ago) but thats cool..he's probably really busy..) i am getting a crash from the zedit create. it adds lines to the index files after it creates the zones in memory...it does this by creating a temp file, checking the old index file line by line and copying/inserting each line appropriately in the new file, then it copies the new file over the old file..i will post some code and show the EXACT spot the mud is crashing. and put in some debugging statements output. if ANYBODY can help me, i will love you for life. debugging statements in the code will begin with ** The code is interspersed through 3 functions(1 large one, 1 medium one and one small one, i'll only post the relevant part of the large one..do_zedit..) i'm really really really sorry to post such a large letter to the list..but i'm at my wits end. here is my debugging output... 9343H 1162M 702V > zedit create 50 Mon Nov 25 23:11:34 :: entering addtoindex switch value is z Mon Nov 25 23:11:34 :: 50.zon Mon Nov 25 23:11:34 :: open file world/zon/index for read Mon Nov 25 23:11:34 :: open file world/zon/index.temp for write Mon Nov 25 23:11:34 :: entering get_line2 Mon Nov 25 23:11:34 :: getting line Mon Nov 25 23:11:34 :: iline=0 line=0.zon last=-1 zone=50 Mon Nov 25 23:11:34 :: wrote 0.zon Mon Nov 25 23:11:34 :: entering get_line2 Mon Nov 25 23:11:34 :: getting line Mon Nov 25 23:11:34 :: iline=22 line=22.zon last=0 zone=50 Mon Nov 25 23:11:34 :: wrote 22.zon Mon Nov 25 23:11:34 :: entering get_line2 Mon Nov 25 23:11:34 :: getting line Mon Nov 25 23:11:34 :: iline=27 line=27.zon last=22 zone=50 Mon Nov 25 23:11:34 :: wrote 27.zon Mon Nov 25 23:11:34 :: entering get_line2 Mon Nov 25 23:11:34 :: getting line Mon Nov 25 23:11:34 :: iline=30 line=30.zon last=27 zone=50 Mon Nov 25 23:11:34 :: wrote 30.zon Mon Nov 25 23:11:34 :: entering get_line2 Mon Nov 25 23:11:34 :: getting line Mon Nov 25 23:11:34 :: iline=40 line=40.zon last=30 zone=50 Mon Nov 25 23:11:34 :: wrote 40.zon Mon Nov 25 23:11:34 :: entering get_line2 Mon Nov 25 23:11:34 :: getting line Mon Nov 25 23:11:34 :: iline=186 line=186.zon last=40 zone=50 Mon Nov 25 23:11:34 :: just wrote 50.zon <hrt> 186.zon Mon Nov 25 23:11:34 :: entering get_line2 Mon Nov 25 23:11:34 :: getting line Mon Nov 25 23:11:34 :: closing all files..prepare to switch Mon Nov 25 23:11:34 :: switching file names... Mon Nov 25 23:11:34 :: complete index update... Mon Nov 25 23:11:34 :: entering addtoindex switch value is w Mon Nov 25 23:11:34 :: 50.wld Mon Nov 25 23:11:34 :: open file world/wld/index for read Mon Nov 25 23:11:34 :: open file world/wld/index.temp for write Mon Nov 25 23:11:34 :: entering get_line2 Mon Nov 25 23:11:34 :: getting line Connection closed by foreign host. [1] + Segmentation Fault(coredump)bin/circle & $ here is the relevant part of do_zedit.... ACMD(do_zedit) { int zone, i, zn; char field[MAX_INPUT_LENGTH], val_arg[MAX_INPUT_LENGTH]; char *fname; FILE *tempfile; half_chop(argument, field, val_arg); snip---> if(!add_to_index(zone, "zon")) { send_to_char("Error editing zone index\r\n", ch); return; ***it goes through the 'add_to index' func fine on this call...*** ***but i'll put it in now, for ease of following the code *** snip---> int add_to_index(int zone, char * type) { char *old_fname, *new_fname, line[256]; FILE *old_file, *new_file; char *prefix, entry[16]; int fdsign = FALSE, wrote = FALSE; int last = -1, iline; **sprintf(buf1, "entering addtoindex switch value is %c", *type); **log(buf1); switch(*type) { case 'z': prefix = ZON_PREFIX; break; case 'w': prefix = WLD_PREFIX; break; case 'o': prefix = OBJ_PREFIX; break; case 'm': prefix = MOB_PREFIX; break; case 's': prefix = SHP_PREFIX; break; default : return(FALSE); } sprintf(entry, "%i.%s", zone, type); /* line to be added to index*/ **log(entry); **this just logs the 50.zon in the output...** sprintf(buf1, "%s/index", prefix); /* path name to file ie world/mob/index$ old_fname = str_dup(buf1); sprintf(buf2, "%s/index.temp", prefix); new_fname = str_dup(buf2); if(!(old_file=fopen(old_fname, "r"))) return(FALSE); ** else{sprintf(buf,"open file %s for read",old_fname);log(buf);} if(!(new_file=fopen(new_fname, "w"))) {fclose(old_file);return(FALSE);} ** else{sprintf(buf, "open file %s for write", new_fname);log(buf);} do { if(!get_line2(old_file, line) && !wrote) { ** log("closing all files and exiting add_to_index with FALSE"); fclose(old_file); fclose(new_file); return(FALSE); } if(*line == '$') { fdsign = TRUE; if (!wrote) { if(fprintf(new_file, "%s\n$\n", entry) < 0) { ** log("didnt write entry to new file..."); break; } else { wrote = TRUE; ** log("wrote entry to end of new file"); } } fprintf(new_file, "$\n"); break; } iline = atoi(line); ** sprintf(buf1, "iline=%d line=%s last=%d zone=%d", iline, line,last,zone); ** log(buf1); if((last < zone) && (zone < iline)) { fprintf(new_file, "%s\n%s\n", entry, line); wrote = TRUE; ** sprintf(buf1, "just wrote %s <hrt> %s", entry, line); ** log(buf1); } else { fprintf(new_file, "%s\n", line); ** sprintf(buf1, "wrote %s", line); ** log(buf1); } last = iline; } while(!fdsign && !feof(old_file)); **log("closing all files..prepare to switch"); fclose(old_file); fclose(new_file); **log("switching file names..."); /* remove(old_fname);*/ rename(new_fname, old_fname); **log("complete index update..."); return(TRUE); } here is the problem function...which works with the calls from the zon section of the code, but not with the wld section..i'm totally friggin stumped... int get_line2(FILE * fl, char buf[]) { int lines = 0; log("entering get_line2"); if(!fl) return(0); log("getting line"); if(fgets(buf, 10, fl)) <<<-----right here is where the damn thing dies. lines++; buf[strlen(buf)-1] = '\0'; return(lines); } and finally the call to add_to_index for the wld part of the code... if(!add_to_index(zone, "wld")) { send_to_char("Error editing world index\r\n", ch); return; } send_to_char("Added zone to world index\r\n", ch); the only thing i can figure is that the file doesnt get open for reading..or the name gets switched along the way...which i'll be darned if i can find. -desperate and eating aspirin like candy.... -invincibill +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST