A
aki
Hi ,
i have a function reportError whose functionality i want to enhance
for case when converToAscii fails .
reportError(char *errorFormatString,
unsigned char *GT1_p,
m GT1_length,
unsigned char *GT2_p,
m GT2_length))
{
char errorBuff[128];
/* Extra bytes required as we convert all symbols. */
char asciiGT1[GT_LEN * 2 ];
char asciiGT2[GT_LEN * 2 ];
if(!GT1_p ||
convertToAscii(GT1_p,
GT1_length,
SYMBOLS,
asciiGT1) != SUCCESS)
{
/* Something went wrong - truncate the output. */
asciiGT1[0] = '\0';
}
if(!GT2_p ||
convertToAscii(GT2_p,
GT2_length,
SYMBOLS,
asciiGT2) != SUCCESS)
{
/* Something went wrong - truncate the output. */
asciiGT2[0] = '\0';
}
sprintf(errorBuff,
errorFormatString,
asciiGT1, asciiGT2);
EXCEPTION(errorBuff, FAILURE);
}
During debugging i can see
reportError (errorFormatString=0x2aab9baeb010 "Failed to extract NDC
from GT %s to prefix %s", GT1_p=0x612b5e "Dy\003\t2\020ÿÿ\a",
GT1_length=8, GT2_p=0x7fff22148470 "I\231\020", GT2_length=9)
i cannot change the formatting of errorFormatString as it presently
print value of GT1, GT2 in string formats.
I have written the sane function with some changes as below:
for the error case .
reportError(char *errorFormatString,
unsigned char *GT1_p,
m GT1_length,
unsigned char *GT2_p,
m GT2_length))
{
char errorBuff[128];
/* Extra bytes required as we convert all symbols. */
char asciiGT1[GT_LEN * 2 ];
char asciiGT2[GT_LEN * 2 ];
int flag1=0;flag2=0;
if(!GT1_p ||
convertToAscii(GT1_p,
GT1_length,
SYMBOLS,
asciiGT1) != SUCCESS)
{
/* Something went wrong - truncate the output. */
asciiGT1[0] = '\0';
flag1=1;
}
if(!GT2_p ||
convertToAscii(GT2_p,
GT2_length,
SYMBOLS,
asciiGT2) != SUCCESS)
{
/* Something went wrong - truncate the output. */
asciiGT2[0] = '\0';
flag2=1;
}
if (flag1&& !flag2) //
{
sprintf(errorBuff,
errorFormatString,
GT1_p, asciiGT2);
}
else if (!flag1 && flag2)
{
sprintf(errorBuff,
errorFormatString,
asciiGT1, GT2_p);
}
else if (flag1&& flag2)
{
sprintf(errorBuff,
errorFormatString,
GT1_p, GT2_p); // here i amt getting the values of GT1_p ,
GT2_p in string format
.
else
sprintf(errorBuff,
errorFormatString,
asciiGT1, asciiGT2);
EXCEPTION(errorBuff, FAILURE);
}
But this time i am getting the exception in string format again.
as below shown
(gdb) p errorBuff
$4 = "Failed to extract CCNDC from GT Dy\003\t2\020ÿÿ\a to prefix I
\231\020\000x\203\024\"ÿ\177\000\000\000\000\000\000\000\000\000\0
00\000\000\000\000\000^+a
\000\000\000\000\000\002\000\000\000\000\000\000\000\b\032_
\000\000\000\000\000àµÁ\002\000\000\000\000\216\0
00\000\000\0000\003n\232«*\000"
I want to know is there any way , by which i can get the vallue of
GT1, GT2 in hexdecimal form ???
so that it look nice for a user.
Hope i am good enough for raising my problem!!!
thanks in advance
Aki
i have a function reportError whose functionality i want to enhance
for case when converToAscii fails .
reportError(char *errorFormatString,
unsigned char *GT1_p,
m GT1_length,
unsigned char *GT2_p,
m GT2_length))
{
char errorBuff[128];
/* Extra bytes required as we convert all symbols. */
char asciiGT1[GT_LEN * 2 ];
char asciiGT2[GT_LEN * 2 ];
if(!GT1_p ||
convertToAscii(GT1_p,
GT1_length,
SYMBOLS,
asciiGT1) != SUCCESS)
{
/* Something went wrong - truncate the output. */
asciiGT1[0] = '\0';
}
if(!GT2_p ||
convertToAscii(GT2_p,
GT2_length,
SYMBOLS,
asciiGT2) != SUCCESS)
{
/* Something went wrong - truncate the output. */
asciiGT2[0] = '\0';
}
sprintf(errorBuff,
errorFormatString,
asciiGT1, asciiGT2);
EXCEPTION(errorBuff, FAILURE);
}
During debugging i can see
reportError (errorFormatString=0x2aab9baeb010 "Failed to extract NDC
from GT %s to prefix %s", GT1_p=0x612b5e "Dy\003\t2\020ÿÿ\a",
GT1_length=8, GT2_p=0x7fff22148470 "I\231\020", GT2_length=9)
i cannot change the formatting of errorFormatString as it presently
print value of GT1, GT2 in string formats.
I have written the sane function with some changes as below:
for the error case .
reportError(char *errorFormatString,
unsigned char *GT1_p,
m GT1_length,
unsigned char *GT2_p,
m GT2_length))
{
char errorBuff[128];
/* Extra bytes required as we convert all symbols. */
char asciiGT1[GT_LEN * 2 ];
char asciiGT2[GT_LEN * 2 ];
int flag1=0;flag2=0;
if(!GT1_p ||
convertToAscii(GT1_p,
GT1_length,
SYMBOLS,
asciiGT1) != SUCCESS)
{
/* Something went wrong - truncate the output. */
asciiGT1[0] = '\0';
flag1=1;
}
if(!GT2_p ||
convertToAscii(GT2_p,
GT2_length,
SYMBOLS,
asciiGT2) != SUCCESS)
{
/* Something went wrong - truncate the output. */
asciiGT2[0] = '\0';
flag2=1;
}
if (flag1&& !flag2) //
{
sprintf(errorBuff,
errorFormatString,
GT1_p, asciiGT2);
}
else if (!flag1 && flag2)
{
sprintf(errorBuff,
errorFormatString,
asciiGT1, GT2_p);
}
else if (flag1&& flag2)
{
sprintf(errorBuff,
errorFormatString,
GT1_p, GT2_p); // here i amt getting the values of GT1_p ,
GT2_p in string format
.
else
sprintf(errorBuff,
errorFormatString,
asciiGT1, asciiGT2);
EXCEPTION(errorBuff, FAILURE);
}
But this time i am getting the exception in string format again.
as below shown
(gdb) p errorBuff
$4 = "Failed to extract CCNDC from GT Dy\003\t2\020ÿÿ\a to prefix I
\231\020\000x\203\024\"ÿ\177\000\000\000\000\000\000\000\000\000\0
00\000\000\000\000\000^+a
\000\000\000\000\000\002\000\000\000\000\000\000\000\b\032_
\000\000\000\000\000àµÁ\002\000\000\000\000\216\0
00\000\000\0000\003n\232«*\000"
I want to know is there any way , by which i can get the vallue of
GT1, GT2 in hexdecimal form ???
so that it look nice for a user.
Hope i am good enough for raising my problem!!!
thanks in advance
Aki