1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

fixed modifier array

This commit is contained in:
tg(x) 2011-04-25 14:39:58 +02:00
parent 3afb723bf8
commit 14a62b568e
3 changed files with 12 additions and 12 deletions

View file

@ -124,8 +124,8 @@ typedef struct
typedef struct
{
size_t length;
PSYC_Modifier *ptr;
size_t lines;
PSYC_Modifier **modifiers;
} PSYC_ModifierArray;
/* intermediate struct for a PSYC packet */

View file

@ -71,12 +71,12 @@ inline PSYC_Packet PSYC_newPacket(PSYC_ModifierArray *routing,
}
// calculate routing header length
for (i = 0; i < routing->length; i++)
p.routingLength += PSYC_getModifierLength(&routing->ptr[i]);
for (i = 0; i < routing->lines; i++)
p.routingLength += PSYC_getModifierLength(routing->modifiers[i]);
// calculate entity header length
for (i = 0; i < entity->length; i++)
p.contentLength += PSYC_getModifierLength(&routing->ptr[i]);
for (i = 0; i < entity->lines; i++)
p.contentLength += PSYC_getModifierLength(routing->modifiers[i]);
// add length of method, data & delimiter
p.contentLength += method->length + 1 + data->length; // method \n data
@ -95,8 +95,8 @@ inline PSYC_Packet PSYC_newPacket2(PSYC_Modifier **routing, size_t routinglen,
const char *data, size_t datalen,
PSYC_PacketFlag flag)
{
PSYC_ModifierArray r = {routinglen, *routing};
PSYC_ModifierArray e = {entitylen, *entity};
PSYC_ModifierArray r = {routinglen, routing};
PSYC_ModifierArray e = {entitylen, entity};
PSYC_String m = {methodlen, method};
PSYC_String d = {datalen, data};

View file

@ -27,16 +27,16 @@ PSYC_RenderRC PSYC_render(PSYC_Packet *packet, char *buffer, size_t buflen)
if (packet->length > buflen)
return PSYC_RENDER_ERROR;
for (i = 0; i < packet->routing.length; i++)
cur += PSYC_renderModifier(&packet->routing.ptr[i], buffer + cur);
for (i = 0; i < packet->routing.lines; i++)
cur += PSYC_renderModifier(packet->routing.modifiers[i], buffer + cur);
if (packet->flag == PSYC_PACKET_NEED_LENGTH)
cur += sprintf(buffer + cur, "%ld", packet->contentLength);
memcpy(buffer + cur++, "\n", 1);
for (i = 0; i < packet->entity.length; i++)
cur += PSYC_renderModifier(&packet->entity.ptr[i], buffer + cur);
for (i = 0; i < packet->entity.lines; i++)
cur += PSYC_renderModifier(packet->entity.modifiers[i], buffer + cur);
memcpy(buffer + cur, PSYC_C2ARG(PSYC_PACKET_DELIMITER));