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/parse.h>
|
||||||
# include <psyc/render.h>
|
# include <psyc/render.h>
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
fill_header_from_mapping (svalue_t *key, svalue_t *val, psycHeader *header, psycModifierFlag flag) {
|
fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
|
||||||
|
psyc_modifier_t *m = extra;
|
||||||
char *name, *value;
|
char *name, *value;
|
||||||
size_t namelen, valuelen;
|
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);
|
value = get_txt(val->u.str);
|
||||||
valuelen = mstrsize(val->u.str);
|
valuelen = mstrsize(val->u.str);
|
||||||
|
|
||||||
header->modifiers[header->lines++] = psyc_newModifier2(C_GLYPH_OPERATOR_SET,
|
m->header->modifiers[m->header->lines++] =
|
||||||
name, namelen, value, valuelen, flag);
|
psyc_newModifier2(m->oper, name, namelen, value, valuelen, m->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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
@ -103,11 +94,14 @@ f_psyc_render(svalue_t *sp) {
|
||||||
headers[i].modifiers = malloc(sizeof(psycModifier) * MAP_SIZE(map));
|
headers[i].modifiers = malloc(sizeof(psycModifier) * MAP_SIZE(map));
|
||||||
if (!headers[i].modifiers) errorf("Out of memory in psyc_render for header.\n");
|
if (!headers[i].modifiers) errorf("Out of memory in psyc_render for header.\n");
|
||||||
|
|
||||||
//if (i == PACKET_ROUTING)
|
if (i == PACKET_ROUTING)
|
||||||
if (i == 0)
|
walk_mapping(map, &fill_header_from_mapping,
|
||||||
walk_mapping(map, &fill_routing_header_from_mapping, &headers[i]);
|
&(psyc_modifier_t) {&headers[i], C_GLYPH_OPERATOR_SET,
|
||||||
|
PSYC_MODIFIER_ROUTING});
|
||||||
else
|
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.
|
* or int* where necessary.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
# include <psyc/packet.h>
|
||||||
# include <psyc/parse.h>
|
# include <psyc/parse.h>
|
||||||
|
|
||||||
# include "array.h"
|
# include "array.h"
|
||||||
|
@ -29,6 +30,12 @@ typedef struct psyc_state_s {
|
||||||
size_t remaining_len;
|
size_t remaining_len;
|
||||||
} psyc_state_t;
|
} psyc_state_t;
|
||||||
|
|
||||||
|
typedef struct psyc_modifier_s {
|
||||||
|
psycHeader *header;
|
||||||
|
char oper;
|
||||||
|
psycModifierFlag flag;
|
||||||
|
} psyc_modifier_t;
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
psyc_free_state (psyc_state_t *ps) {
|
psyc_free_state (psyc_state_t *ps) {
|
||||||
if (!ps)
|
if (!ps)
|
||||||
|
|
|
@ -17,7 +17,7 @@ version_longtype="stable"
|
||||||
# A timestamp, to be used by bumpversion and other scripts.
|
# A timestamp, to be used by bumpversion and other scripts.
|
||||||
# It can be used, for example, to 'touch' this file on every build, thus
|
# 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.
|
# 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
|
# Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x
|
||||||
version_major=4
|
version_major=4
|
||||||
|
|
Loading…
Reference in a new issue