Well that wasn't the right structure for it, at least on the box I'm
running on, but I did go trace through the stdio.h on the machine I'm at
and found the reference I was looking for, which was a little bitty
thing and hard to spot :D
__BEGIN_NAMESPACE_STD
/* The opaque type of streams. This is the definition used elsewhere.
*/
typedef struct _IO_FILE FILE;
__END_NAMESPACE_STD
with that little piece of information I went to google and searched for
_IO_FILE, and came up w/ a hit that had the structure I was looking for,
which apparently is this:
struct _IO_FILE {
int _flags;
char* _IO_read_ptr;
char* _IO_read_end;
char* _IO_read_base;
char* _IO_write_base;
char* _IO_write_ptr;
char* _IO_write_end;
char* _IO_buf_base;
char* _IO_buf_end;
char *_IO_save_base;
char *_IO_backup_base;
char *_IO_save_end;
struct _IO_marker *_markers;
struct _IO_FILE *_chain;
int _fileno;
int _blksize;
__off_t _old_offset;
unsigned short _cur_column;
signed char _vtable_offset;
char _shortbuf[1];
_IO_lock_t *_lock;
__off64_t _offset;
int _unused2[16];
};
now, armed with this, I went into my code and made a quick little temp
function that I could run that would open a new file for writing, and
then print every one of those char * variables to me in the mud... they
were all null... so I tried writing 1 word to the file within the
function right before I output those values, and it crashed trying to
print _IO_buf_end, which apparently was not in a good location for being
printed :D... well at that point I didn't really know how to proceed, so
I figured I'd give it a real life test run, and I popped a line into
char *fread_word in db.c, and edited an area file to crash that way...
instead it segfaulted on me, and when I jumped back a few frames to
fread_word and printed the value of _IO_read_base, it was the entire
rest of the file, which it crashed trying to put into a %s and output to
the logs; most of the other fields displayed the same file location,
none display the file name... _IO_read_end displays the pointer to the
space in the file after the word was read... so with that not being a
good method to test with, I figured I'd at least try to salvage
something from this experience by seeing if it would let me do a %30s
kind of thing, to at least the general location within the file that the
crash occurred... that didn't work... I then moved my output line up to
where it returns the word that's been read... that crashed as well, as
it was trying to copy the entire contents of my social file (the first
file loaded) into a variable to be output to the logs :D anyway, I
thought I'd pass along what I'd gotten hung up on so far, in the hopes
that some gurus out there can figure something out to help with these
kinds of vague errors from area loading :)
wavewave
Richard Lindsey.
-----Original Message-----
From: Valnir [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 28, 2004 12:06 PM
To: [email protected]
Subject: Re: Quick question about FILE * variables...
I BELIEVE this is the proper structure for it.. so play if you want, but
let
us know if you make it work! :)
I BELIEVE this is the right structure. Be careful, but definitely let us
know if you make it work! :)
#ifndef _FILE_DEFINED
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;
#define _FILE_DEFINED
#endif
- Valnir
----- Original Message -----
From: "Richard Lindsey" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, July 28, 2004 12:23 PM
Subject: Quick question about FILE * variables...
Is there a field anywhere in that file structure that keeps track of the
file's name? In db.c where it's loading area data, it's got its various
functions like fread_string and fread_word, and if something's screwy
with the area file then they'll bug with something like "Word too long"
but not tell you which file or where in the file, and I'd like to be
able to log the file and the line and offset of what it was trying to
read when that happened (I just happen to be going to db.c right now and
the idea hit me, but I've no idea if that structure holds the filename
info)... so that's my question... I don't think it does, or else a lot
of coding examples I see on the internet, and probably the whole design
of those functions originally would have included that kind of info, but
there's no harm in asking :D Thanks in advance :)
Richard Lindsey.
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom