[openbeos] Re: SK: interacting modules

  • From: François Revol <revol@xxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Tue, 14 May 2002 23:26:40 +0200 (MEST)

that shouldn't be that hard...
something like

typedef struct bparam {
 struct bparam *next;
 char *name;
 uint32 type;
 int size;
 char data[0]; // for sizeof()
/* union {
  void* data_void;
  uint32 data_uint32;
  ///...
 } d;
*/
} bparam;

typedef struct bmessage {
uint32 what;
bparam *params;
} bmessage

status_t add_uint32(bmessage *m, char *name, uint32 i)
{
 bparam *p;
 p = (bparam *) malloc (sizeof(bparam) + sizeof(uint32) + strlen(name) + 1);
 p->next=NULL;
 p->size = sizeof(uint32);
 *((uint32 *)p->data) = i;
 // simplifies memory managment
 strcpy((((char *)p)+(sizeof(bparam) + sizeof(uint32))), name);
 p->name = (((char *)p)+(sizeof(bparam) + sizeof(uint32)));
}

status_t bmessage_flatten(bmessage *m, void *buffer, size_t *sz)
{
int size;
bparam *p;
 p = m
 // calc size
 while (p) {
  size += strlen(p->name) + 1;
  size += p->size + 1; // guess ?
  p = p->next;
 }
 size += 4; // magic number ...
 if (size > *sz)
  return B_NO_MEMORY; // maybe...
 // flatten...
 // someone knows the layout ?
}

En réponse à Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>:

> So what does that mean? I guess, that I can neither implement BQuery
> nor
> the node monitoring functions until there is a kernel that provides
> some
> functionality for that pupose. :-(
> 
> CU, Ingo
> 
> 
> 






Other related posts: