mirror of
git://git.psyced.org/git/psyclpc
synced 2024-08-15 03:20:16 +00:00
pkg-psyc: pass a struct to walk_mapping
This commit is contained in:
parent
a770a42eac
commit
efc8ca4075
3 changed files with 20 additions and 19 deletions
|
@ -45,8 +45,9 @@
|
|||
# include <psyc/parse.h>
|
||||
# include <psyc/render.h>
|
||||
|
||||
static inline void
|
||||
fill_header_from_mapping (svalue_t *key, svalue_t *val, psycHeader *header, psycModifierFlag flag) {
|
||||
void
|
||||
fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
|
||||
psyc_modifier_t *m = extra;
|
||||
char *name, *value;
|
||||
size_t namelen, valuelen;
|
||||
|
||||
|
@ -59,18 +60,8 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, psycHeader *header, psyc
|
|||
value = get_txt(val->u.str);
|
||||
valuelen = mstrsize(val->u.str);
|
||||
|
||||
header->modifiers[header->lines++] = psyc_newModifier2(C_GLYPH_OPERATOR_SET,
|
||||
name, namelen, value, valuelen, flag);
|
||||
}
|
||||
|
||||
void
|
||||
fill_routing_header_from_mapping (svalue_t *key, svalue_t *val, void *header) {
|
||||
fill_header_from_mapping(key, val, header, PSYC_MODIFIER_ROUTING);
|
||||
}
|
||||
|
||||
void
|
||||
fill_entity_header_from_mapping (svalue_t *key, svalue_t *val, void *header) {
|
||||
fill_header_from_mapping(key, val, header, PSYC_MODIFIER_CHECK_LENGTH);
|
||||
m->header->modifiers[m->header->lines++] =
|
||||
psyc_newModifier2(m->oper, name, namelen, value, valuelen, m->flag);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
@ -103,11 +94,14 @@ f_psyc_render(svalue_t *sp) {
|
|||
headers[i].modifiers = malloc(sizeof(psycModifier) * MAP_SIZE(map));
|
||||
if (!headers[i].modifiers) errorf("Out of memory in psyc_render for header.\n");
|
||||
|
||||
//if (i == PACKET_ROUTING)
|
||||
if (i == 0)
|
||||
walk_mapping(map, &fill_routing_header_from_mapping, &headers[i]);
|
||||
if (i == PACKET_ROUTING)
|
||||
walk_mapping(map, &fill_header_from_mapping,
|
||||
&(psyc_modifier_t) {&headers[i], C_GLYPH_OPERATOR_SET,
|
||||
PSYC_MODIFIER_ROUTING});
|
||||
else
|
||||
walk_mapping(map, &fill_entity_header_from_mapping, &headers[i]);
|
||||
walk_mapping(map, &fill_header_from_mapping,
|
||||
&(psyc_modifier_t) {&headers[i], C_GLYPH_OPERATOR_SET,
|
||||
PSYC_MODIFIER_CHECK_LENGTH});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* or int* where necessary.
|
||||
*/
|
||||
|
||||
# include <psyc/packet.h>
|
||||
# include <psyc/parse.h>
|
||||
|
||||
# include "array.h"
|
||||
|
@ -29,6 +30,12 @@ typedef struct psyc_state_s {
|
|||
size_t remaining_len;
|
||||
} psyc_state_t;
|
||||
|
||||
typedef struct psyc_modifier_s {
|
||||
psycHeader *header;
|
||||
char oper;
|
||||
psycModifierFlag flag;
|
||||
} psyc_modifier_t;
|
||||
|
||||
static inline void
|
||||
psyc_free_state (psyc_state_t *ps) {
|
||||
if (!ps)
|
||||
|
|
|
@ -17,7 +17,7 @@ version_longtype="stable"
|
|||
# A timestamp, to be used by bumpversion and other scripts.
|
||||
# It can be used, for example, to 'touch' this file on every build, thus
|
||||
# forcing revision control systems to add it on every checkin automatically.
|
||||
version_stamp="Thu May 12 13:50:02 CEST 2011"
|
||||
version_stamp="Thu May 12 16:37:59 CEST 2011"
|
||||
|
||||
# Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x
|
||||
version_major=4
|
||||
|
|
Loading…
Reference in a new issue