NOT YET PART OF SEAMONKEY:

* eliminated compiler warnings on Linux
* added extra error checking for file manipulation in SimpleTypeLib and xpt_dump
* removed erroneous comment from xpt_struct.h
This commit is contained in:
coop%netscape.com 1999-02-16 18:41:30 +00:00
parent 8561548e7c
commit 76bdfa96b3
8 changed files with 32 additions and 20 deletions

View File

@ -224,8 +224,6 @@ struct XPTTypeDescriptorPrefix {
#define XPT_TDP_IS_UNIQUE_POINTER(flags) (flags & XPT_TDP_UNIQUE_POINTER)
#define XPT_TDP_IS_REFERENCE(flags) (flags & XPT_TDP_REFERENCE)
/* XXX TD #defines should include required flag bits! */
/*
* The following enum maps mnemonic names to the different numeric values
* of XPTTypeDescriptor->tag.

View File

@ -57,14 +57,14 @@ CheckForRepeat(XPTCursor *cursor, void **addrp, XPTPool pool, int len,
((cursor)->state->data_offset && \
((cursor)->offset - 1 + (space) > (cursor)->state->data_offset)) \
? (DBG(("no space left in HEADER %d + %d > %d\n", (cursor)->offset, \
(space), (cursor)->state->data_offset)), PR_FALSE) \
(space), (cursor)->state->data_offset)) && PR_FALSE) \
: PR_TRUE) : \
/* if we're in the data area and we're about to exceed the allocation */ \
(CURS_POOL_OFFSET(cursor) + (space) > (cursor)->state->pool->allocated ? \
/* then grow if we're in ENCODE mode */ \
(ENCODING(cursor) ? GrowPool((cursor)->state->pool) \
(ENCODING(cursor) ? GrowPool((cursor)->state->pool) \
/* and fail if we're in DECODE mode */ \
: (DBG(("can't extend in DECODE")), PR_FALSE)) \
: (DBG(("can't extend in DECODE")) && PR_FALSE)) \
/* otherwise we're OK */ \
: PR_TRUE))

View File

@ -45,7 +45,7 @@ struct nsID iid = {
{0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}
};
XPTTypeDescriptor td_void = { TD_VOID };
XPTTypeDescriptor td_void = {};
int
main(int argc, char **argv)
@ -62,6 +62,8 @@ main(int argc, char **argv)
uint32 len, header_sz;
PRBool ok;
td_void.prefix.flags = TD_VOID;
if (argc != 2) {
fprintf(stderr, "Usage: %s <filename.xpt>\n"
@ -140,9 +142,14 @@ main(int argc, char **argv)
XPT_GetXDRData(state, XPT_DATA, &data, &len);
fwrite(data, len, 1, out);
fclose(out);
XPT_DestroyXDRState(state);
if (ferror(out) != 0 || fclose(out) != 0) {
fprintf(stderr, "\nError writing file: %s\n\n", argv[1]);
} else {
fprintf(stderr, "\nFile written: %s\n\n", argv[1]);
}
XPT_DestroyXDRState(state);
/* XXX DestroyHeader */
return 0;
}

View File

@ -139,6 +139,9 @@ main(int argc, char **argv)
if (flen > 0) {
fread(whole, flen, 1, in);
if (ferror(in) != 0 || fclose(in) != 0)
perror("FAILED: Unable to read typelib file.\n");
state = XPT_NewXDRState(XPT_DECODE, whole, flen);
if (!XPT_MakeCursor(state, XPT_HEADER, 0, cursor)) {
fprintf(stdout, "MakeCursor failed\n");
@ -158,8 +161,6 @@ main(int argc, char **argv)
free(whole);
}
fclose(in);
return 0;
}

View File

@ -224,8 +224,6 @@ struct XPTTypeDescriptorPrefix {
#define XPT_TDP_IS_UNIQUE_POINTER(flags) (flags & XPT_TDP_UNIQUE_POINTER)
#define XPT_TDP_IS_REFERENCE(flags) (flags & XPT_TDP_REFERENCE)
/* XXX TD #defines should include required flag bits! */
/*
* The following enum maps mnemonic names to the different numeric values
* of XPTTypeDescriptor->tag.

View File

@ -57,14 +57,14 @@ CheckForRepeat(XPTCursor *cursor, void **addrp, XPTPool pool, int len,
((cursor)->state->data_offset && \
((cursor)->offset - 1 + (space) > (cursor)->state->data_offset)) \
? (DBG(("no space left in HEADER %d + %d > %d\n", (cursor)->offset, \
(space), (cursor)->state->data_offset)), PR_FALSE) \
(space), (cursor)->state->data_offset)) && PR_FALSE) \
: PR_TRUE) : \
/* if we're in the data area and we're about to exceed the allocation */ \
(CURS_POOL_OFFSET(cursor) + (space) > (cursor)->state->pool->allocated ? \
/* then grow if we're in ENCODE mode */ \
(ENCODING(cursor) ? GrowPool((cursor)->state->pool) \
(ENCODING(cursor) ? GrowPool((cursor)->state->pool) \
/* and fail if we're in DECODE mode */ \
: (DBG(("can't extend in DECODE")), PR_FALSE)) \
: (DBG(("can't extend in DECODE")) && PR_FALSE)) \
/* otherwise we're OK */ \
: PR_TRUE))

View File

@ -45,7 +45,7 @@ struct nsID iid = {
{0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}
};
XPTTypeDescriptor td_void = { TD_VOID };
XPTTypeDescriptor td_void = {};
int
main(int argc, char **argv)
@ -62,6 +62,8 @@ main(int argc, char **argv)
uint32 len, header_sz;
PRBool ok;
td_void.prefix.flags = TD_VOID;
if (argc != 2) {
fprintf(stderr, "Usage: %s <filename.xpt>\n"
@ -140,9 +142,14 @@ main(int argc, char **argv)
XPT_GetXDRData(state, XPT_DATA, &data, &len);
fwrite(data, len, 1, out);
fclose(out);
XPT_DestroyXDRState(state);
if (ferror(out) != 0 || fclose(out) != 0) {
fprintf(stderr, "\nError writing file: %s\n\n", argv[1]);
} else {
fprintf(stderr, "\nFile written: %s\n\n", argv[1]);
}
XPT_DestroyXDRState(state);
/* XXX DestroyHeader */
return 0;
}

View File

@ -139,6 +139,9 @@ main(int argc, char **argv)
if (flen > 0) {
fread(whole, flen, 1, in);
if (ferror(in) != 0 || fclose(in) != 0)
perror("FAILED: Unable to read typelib file.\n");
state = XPT_NewXDRState(XPT_DECODE, whole, flen);
if (!XPT_MakeCursor(state, XPT_HEADER, 0, cursor)) {
fprintf(stdout, "MakeCursor failed\n");
@ -158,8 +161,6 @@ main(int argc, char **argv)
free(whole);
}
fclose(in);
return 0;
}