mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
fixed modifier array
This commit is contained in:
parent
3afb723bf8
commit
14a62b568e
3 changed files with 12 additions and 12 deletions
|
@ -124,8 +124,8 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
size_t length;
|
size_t lines;
|
||||||
PSYC_Modifier *ptr;
|
PSYC_Modifier **modifiers;
|
||||||
} PSYC_ModifierArray;
|
} PSYC_ModifierArray;
|
||||||
|
|
||||||
/* intermediate struct for a PSYC packet */
|
/* intermediate struct for a PSYC packet */
|
||||||
|
|
12
src/psyc.c
12
src/psyc.c
|
@ -71,12 +71,12 @@ inline PSYC_Packet PSYC_newPacket(PSYC_ModifierArray *routing,
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate routing header length
|
// calculate routing header length
|
||||||
for (i = 0; i < routing->length; i++)
|
for (i = 0; i < routing->lines; i++)
|
||||||
p.routingLength += PSYC_getModifierLength(&routing->ptr[i]);
|
p.routingLength += PSYC_getModifierLength(routing->modifiers[i]);
|
||||||
|
|
||||||
// calculate entity header length
|
// calculate entity header length
|
||||||
for (i = 0; i < entity->length; i++)
|
for (i = 0; i < entity->lines; i++)
|
||||||
p.contentLength += PSYC_getModifierLength(&routing->ptr[i]);
|
p.contentLength += PSYC_getModifierLength(routing->modifiers[i]);
|
||||||
|
|
||||||
// add length of method, data & delimiter
|
// add length of method, data & delimiter
|
||||||
p.contentLength += method->length + 1 + data->length; // method \n data
|
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,
|
const char *data, size_t datalen,
|
||||||
PSYC_PacketFlag flag)
|
PSYC_PacketFlag flag)
|
||||||
{
|
{
|
||||||
PSYC_ModifierArray r = {routinglen, *routing};
|
PSYC_ModifierArray r = {routinglen, routing};
|
||||||
PSYC_ModifierArray e = {entitylen, *entity};
|
PSYC_ModifierArray e = {entitylen, entity};
|
||||||
PSYC_String m = {methodlen, method};
|
PSYC_String m = {methodlen, method};
|
||||||
PSYC_String d = {datalen, data};
|
PSYC_String d = {datalen, data};
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,16 @@ PSYC_RenderRC PSYC_render(PSYC_Packet *packet, char *buffer, size_t buflen)
|
||||||
if (packet->length > buflen)
|
if (packet->length > buflen)
|
||||||
return PSYC_RENDER_ERROR;
|
return PSYC_RENDER_ERROR;
|
||||||
|
|
||||||
for (i = 0; i < packet->routing.length; i++)
|
for (i = 0; i < packet->routing.lines; i++)
|
||||||
cur += PSYC_renderModifier(&packet->routing.ptr[i], buffer + cur);
|
cur += PSYC_renderModifier(packet->routing.modifiers[i], buffer + cur);
|
||||||
|
|
||||||
if (packet->flag == PSYC_PACKET_NEED_LENGTH)
|
if (packet->flag == PSYC_PACKET_NEED_LENGTH)
|
||||||
cur += sprintf(buffer + cur, "%ld", packet->contentLength);
|
cur += sprintf(buffer + cur, "%ld", packet->contentLength);
|
||||||
|
|
||||||
memcpy(buffer + cur++, "\n", 1);
|
memcpy(buffer + cur++, "\n", 1);
|
||||||
|
|
||||||
for (i = 0; i < packet->entity.length; i++)
|
for (i = 0; i < packet->entity.lines; i++)
|
||||||
cur += PSYC_renderModifier(&packet->entity.ptr[i], buffer + cur);
|
cur += PSYC_renderModifier(packet->entity.modifiers[i], buffer + cur);
|
||||||
|
|
||||||
memcpy(buffer + cur, PSYC_C2ARG(PSYC_PACKET_DELIMITER));
|
memcpy(buffer + cur, PSYC_C2ARG(PSYC_PACKET_DELIMITER));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue