コード例 #1
0
ファイル: analyze.cpp プロジェクト: snoworc/nsfanalyzer
_declspec ( dllexport ) STATUS ATOM_ListGetText (void *pList,
												 BOOL fPrefixDataType,
												 WORD EntryNumber,
												 char **retTextPointer,
												 WORD *retTextLength)
{
	return ListGetText(pList, fPrefixDataType, EntryNumber, retTextPointer, retTextLength);
}
コード例 #2
0
STATUS ExtractTextList (char *pBuffer, char *TextList)
{
    LIST    List;
    char   *ListEntry;  /* pointer to list entry */
    WORD    TextLen;    /* total length of string output to TextList */
    WORD    EntryLen;   /* length of one entry */
    STATUS  error;      /* return code from API calls */
    USHORT  i;          /* a counter */

    /* Initialize the total length of the list. */

    TextLen = 0;

    /* Clear the string that we'll fill up. */

    TextList[0] = '\0';

    /* Get the list header structure with the number of entries. */

    memcpy ((char*)(&List), pBuffer, sizeof(LIST));

    /* Loop over each entry of the list. */

    for (i=0; i<List.ListEntries; i++)
    {
        /* Get one entry from the list. */

        if (error = ListGetText (
                    pBuffer,
                    FALSE, /* DataType not prepended to list */
                    i,
                    &ListEntry,
                    &EntryLen))
        {
            return (ERR(error));
        }

        /*  Copy this entry to the string we are building and move the
            pointer that keeps track of how much we have in the string.
         */

        memcpy (TextList+TextLen, ListEntry, EntryLen);
        TextLen += EntryLen;

        /* Put a comma after the entry and advance the text length. */

        memcpy (TextList+TextLen, ",", 1);
        TextLen++;

    }   /* End of loop over list entries. */

    /* Put a null in place of the last comma */

    TextLen--;
    memcpy (TextList+TextLen, "\0", 1);

    return (NOERROR);
}
コード例 #3
0
STATUS LNPUBLIC print_file_summary_list (ITEM_TABLE *summary, void* szReturn)
{
	#define     MAX_ITEMS           30
	#define     MAX_TEXT_LEN        1000
	#define     DATATYPE_SIZE       sizeof(USHORT)
	#define     NAME_LENGTH_SIZE    sizeof(USHORT)
	#define     ITEM_LENGTH_SIZE    sizeof(USHORT)	
	#define     NUMERIC_SIZE        sizeof(FLOAT)
	#define     TIME_SIZE           ODSLength(_TIMEDATE)

	/* Local variables */
    BYTE       *summary_position;       /* current position in summary */
    ITEM_TABLE item_table;              /* header at start of summary */
    USHORT     item_count;              /* number of items in summary */
    USHORT     name_length[MAX_ITEMS];  /* length of each item name */
    USHORT     item_length[MAX_ITEMS];  /* length of each item */
    char       item_name[MAX_TEXT_LEN]; /* name of a summary item */
    USHORT     datatype;                /* type of item */
    char       item_text[MAX_TEXT_LEN]; /* text of a summary item */
    FLOAT      numeric_item;            /* a numeric item */
    TIMEDATE   time_item;               /* a time/date item */
    WORD       time_string_len;         /* length of ASCII time/date */
    STATUS     error;                   /* return code from API calls */
    USHORT     i;                       /* a counter */

    CStringList* lstText;
    lstText = (CStringList*)szReturn;

	/* Print a blank line to start this display. */
    printf ("\n");

	/* Get the header at the beginning of the summary buffer. */
    item_table = *summary;

	/* Keep track of where we are in the buffer. */
    summary_position = (BYTE *) summary;

	/* Get the number of items in the summary. */
    item_count = item_table.Items;

	/* Check boundary of the array */
	if (item_count > MAX_ITEMS)
	{
		printf("ERROR: Number of items has exceeded boundary of defined array.\n");
		return (0);
	}

	/* Advance the buffer pointer over the header. */
    summary_position += ODSLength(_ITEM_TABLE);

	/* Get the length of each item in the summary. */
    for (i=0; i < item_count; i++)
    {
        memcpy (&name_length[i], summary_position, NAME_LENGTH_SIZE);
        summary_position += NAME_LENGTH_SIZE;
        memcpy (&item_length[i], summary_position, ITEM_LENGTH_SIZE);
        summary_position += ITEM_LENGTH_SIZE;
    }

	/* Start a loop that extracts each item in the summary. */
    bool bNeedAdd = false;
    for (i=0; i < item_count; i++)
    {
		/* Print the name of the item. */
        memcpy (item_name, summary_position, name_length[i]);
        item_name[name_length[i]] = '\0';
        summary_position += name_length[i];

        printf ("%s:  ", item_name);
        if (0 == strcmp(item_name, "$TITLE"))
        {
            bNeedAdd = true;
        }

		/* Get the data type of this item. */
        memcpy (&datatype, summary_position, DATATYPE_SIZE);
        summary_position += DATATYPE_SIZE;

		/* Extract the item from the summary and put it in readable
		form. The way in which we extract the item depends on its type.
		This program handles TEXT, NUMBER, and TIME. */
        switch (datatype)
        {
			/* Extract a text item from the summary. */
			case TYPE_TEXT:
				memcpy (item_text, summary_position, item_length[i] - DATATYPE_SIZE);
				item_text[item_length[i] - DATATYPE_SIZE] = '\0';
				if (bNeedAdd)
				{
					lstText->AddTail(item_text);
					bNeedAdd = false;
				}
            break;

			/* Extract a number item from the summary. */
			case TYPE_NUMBER:
				memcpy (&numeric_item, summary_position, NUMERIC_SIZE);
				sprintf (item_text, "%g", numeric_item);
            break;

			/* Extract a time/date item from the summary. */
	        case TYPE_TIME:
	            memcpy (&time_item, summary_position, TIME_SIZE);
	            if (error = ConvertTIMEDATEToText (NULL,
                                               NULL,
                                               &time_item,
                                               item_text,
                                               MAXALPHATIMEDATE,
                                               &time_string_len))
				return (ERR(error));
	            item_text[time_string_len] = '\0';
            break;

			case TYPE_TEXT_LIST:
			{
				LIST      *pList;
				WORD      list_entry;
				char      *Buffer;
				WORD      text_size;

				memset (item_text,'\0', item_length[i] - DATATYPE_SIZE + 1);
				pList = (LIST *)summary_position;
				for (list_entry = 0; list_entry < pList->ListEntries; list_entry++)
				{
					ListGetText(pList, FALSE, list_entry, &Buffer, &text_size);
					strncat (item_text, Buffer, text_size);
				}
			}
			break;

			/* If the summary item is not one of the data types this program handles. */
			default:
            strcpy (item_text, "(Data type not handled)");
            break;
        }

		/* Print the item. */
        printf ("%s\n", item_text);

		/* Advance to next item in the summary. */
        summary_position += (item_length[i] - DATATYPE_SIZE);

		/* End of loop that is extracting each item in the summary. */
	}

	/* End of function */
    return (NOERROR);
}