version 1.6, 2000/11/27 09:57:10 |
version 1.9, 2003/06/02 10:25:56 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM: OpenXM/src/ox_toolkit/mathcap.c,v 1.5 2000/11/24 05:49:26 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_toolkit/mathcap.c,v 1.8 2003/05/19 06:57:38 ohara Exp $ */ |
|
|
/* This module includes functions for handling mathcap databases. */ |
/* This module includes functions for handling mathcap databases. */ |
|
|
Line 87 static table *new_table(int *src) |
|
Line 87 static table *new_table(int *src) |
|
int i; |
int i; |
while (src[len++] != 0) { |
while (src[len++] != 0) { |
} |
} |
new = malloc(sizeof(table)*len); |
new = MALLOC(sizeof(table)*len); |
for(i=0; i<len; i++) { |
for(i=0; i<len; i++) { |
table_init(new+i, src[i]); |
table_init(new+i, src[i]); |
} |
} |
return new; |
return new; |
} |
} |
|
|
/* 次の tag についてのキーを探す */ |
/* looking for an item of the tag */ |
static table *table_lookup(table *tbl, int tag) |
static table *table_lookup(table *tbl, int tag) |
{ |
{ |
while (tbl->tag != 0) { |
while (tbl->tag != 0) { |
Line 106 static table *table_lookup(table *tbl, int tag) |
|
Line 106 static table *table_lookup(table *tbl, int tag) |
|
return NULL; |
return NULL; |
} |
} |
|
|
/* tag に対する送信制御 */ |
/* controller about a cmo identified by the tag */ |
static void table_ctl(table *tbl, int tag, int flag) |
static void table_ctl(table *tbl, int tag, int flag) |
{ |
{ |
table *e = table_lookup(tbl, tag); |
table *e = table_lookup(tbl, tag); |
Line 115 static void table_ctl(table *tbl, int tag, int flag) |
|
Line 115 static void table_ctl(table *tbl, int tag, int flag) |
|
} |
} |
} |
} |
|
|
/* 全データに対する送信制御 */ |
/* controller about all CMObjects */ |
static void table_ctl_all(table *tbl, int flag) |
static void table_ctl_all(table *tbl, int flag) |
{ |
{ |
while (tbl->tag != 0) { |
while (tbl->tag != 0) { |
Line 124 static void table_ctl_all(table *tbl, int flag) |
|
Line 124 static void table_ctl_all(table *tbl, int flag) |
|
} |
} |
} |
} |
|
|
/* 送信許可されている tag のリストを得る */ |
/* getting the list of tags of all allowed objects */ |
static cmo_list *table_get_all(table *tbl) |
static cmo_list *table_get_all(table *tbl) |
{ |
{ |
cmo_list *list = new_cmo_list(); |
cmo_list *list = new_cmo_list(); |
Line 137 static cmo_list *table_get_all(table *tbl) |
|
Line 137 static cmo_list *table_get_all(table *tbl) |
|
return list; |
return list; |
} |
} |
|
|
/* 次の tag をもつ cmo or sm_cmd の送信を許可する */ |
/* giving a permssion to send objects identified by the tag. */ |
__inline__ |
__inline__ |
static void table_allow(table *tbl, int tag) |
static void table_allow(table *tbl, int tag) |
{ |
{ |
table_ctl(tbl, tag, MATHCAP_FLAG_ALLOW); |
table_ctl(tbl, tag, MATHCAP_FLAG_ALLOW); |
} |
} |
|
|
/* 次の tag をもつ cmo or sm_cmd の送信を不許可にする */ |
/* taking a permssion to send objects identified by the tag. */ |
__inline__ |
__inline__ |
static void table_deny(table *tbl, int tag) |
static void table_deny(table *tbl, int tag) |
{ |
{ |
Line 164 static void table_update(table *cmotbl, cmo_list* type |
|
Line 164 static void table_update(table *cmotbl, cmo_list* type |
|
} |
} |
} |
} |
|
|
/* 次の tag をもつ cmo or sm_cmd の送信が許可されているかを調べる */ |
/* getting a permission to send objects identified by the tag. */ |
static int table_allowQ_tag(table *tbl, int tag) |
static int table_allowQ_tag(table *tbl, int tag) |
{ |
{ |
while (tbl->tag != 0 && tbl->tag != tag) { |
while (tbl->tag != 0 && tbl->tag != tag) { |
Line 203 static int table_allowQ_cmo_mathcap(table *cmotbl, cmo |
|
Line 203 static int table_allowQ_cmo_mathcap(table *cmotbl, cmo |
|
&& table_allowQ_cmo(cmotbl, ob->ob); |
&& table_allowQ_cmo(cmotbl, ob->ob); |
} |
} |
|
|
/* 次の cmo の送信が許可されているかを調べる */ |
/* getting a permission to send the following object. */ |
static int table_allowQ_cmo(table *cmotbl, cmo *ob) |
static int table_allowQ_cmo(table *cmotbl, cmo *ob) |
{ |
{ |
int tag = ob->tag; |
int tag = ob->tag; |
Line 223 static int table_allowQ_cmo(table *cmotbl, cmo *ob) |
|
Line 223 static int table_allowQ_cmo(table *cmotbl, cmo *ob) |
|
} |
} |
} |
} |
|
|
/* システム情報を得る */ |
/* getting the System Information */ |
static cmo_list *sysinfo_get() |
static cmo_list *sysinfo_get() |
{ |
{ |
cmo_list *syslist = new_cmo_list(); |
cmo_list *syslist = new_cmo_list(); |
Line 236 static cmo_list *sysinfo_get() |
|
Line 236 static cmo_list *sysinfo_get() |
|
|
|
static char *new_string(char *s) |
static char *new_string(char *s) |
{ |
{ |
char *t = malloc(sizeof(s)+1); |
char *t = MALLOC(strlen(s)+1); |
strcpy(t, s); |
strcpy(t, s); |
return t; |
return t; |
} |
} |
Line 247 static int *new_int_array(int *array) |
|
Line 247 static int *new_int_array(int *array) |
|
int length = 0; |
int length = 0; |
while(array[length++] != 0) |
while(array[length++] != 0) |
; |
; |
new_array = malloc(sizeof(int)*length); |
new_array = MALLOC(sizeof(int)*length); |
return memcpy(new_array, array, sizeof(int)*length); |
return memcpy(new_array, array, sizeof(int)*length); |
} |
} |
|
|
Line 268 void mathcap_init(int ver, char *vstr, char *sysname, |
|
Line 268 void mathcap_init(int ver, char *vstr, char *sysname, |
|
|
|
mathcap *new_mathcap() |
mathcap *new_mathcap() |
{ |
{ |
mathcap *new = malloc(sizeof(mathcap)); |
mathcap *new = MALLOC(sizeof(mathcap)); |
new->cmotbl = new_table(sysinfo.cmo_tags); |
new->cmotbl = new_table(sysinfo.cmo_tags); |
new->smtbl = new_table(sysinfo.sm_cmds); |
new->smtbl = new_table(sysinfo.sm_cmds); |
return new; |
return new; |
} |
} |
|
|
/* データベースから cmo_mathcap を生成する */ |
/* generating a cmo_mathcap by a local database. */ |
cmo_mathcap* mathcap_get(mathcap *this) |
cmo_mathcap* mathcap_get(mathcap *this) |
{ |
{ |
cmo_list *mc = new_cmo_list(); |
cmo_list *mc = new_cmo_list(); |
Line 312 static cmo_list *cmo_mathcap_get_cmotypes(cmo_mathcap |
|
Line 312 static cmo_list *cmo_mathcap_get_cmotypes(cmo_mathcap |
|
return get_messagetypes(ob, OX_DATA); |
return get_messagetypes(ob, OX_DATA); |
} |
} |
|
|
/* 受信した mathcap データを反映させる */ |
/* The mathcap_update integrates received cmo_mathcap into the mathcap |
/* this == NULL のとき、はじめて mathcap* オブジェクトをせいせいする */ |
database. If this == NULL, then an instance of mathcap is generated. */ |
mathcap *mathcap_update(mathcap *this, cmo_mathcap *mc) |
mathcap *mathcap_update(mathcap *this, cmo_mathcap *mc) |
{ |
{ |
cmo_list *types; |
cmo_list *types; |
types = cmo_mathcap_get_cmotypes(mc); |
types = cmo_mathcap_get_cmotypes(mc); |
if (types != NULL) { |
if (types != NULL) { |
/* すべての cmo の送信を禁止 */ |
|
table_ctl_all(this->cmotbl, MATHCAP_FLAG_DENY); |
table_ctl_all(this->cmotbl, MATHCAP_FLAG_DENY); |
table_update(this->cmotbl, types); |
table_update(this->cmotbl, types); |
} |
} |