Files
openairinterface5g/common/utils/T/tracer/handler.c
T
Robert Schmidt 8107939f08 Change OAI license to CSSL v1.0 (and others)
- all RAN code, CI code, configuration files, dockerfiles, in CSSL v1.0
- all deployment code (openshift, charts, ancillary files like shell
  scripts), in MIT
- documentation in CC-BY-4.0
- exceptions might apply and are listed in NOTICE
- there is a new LICENSES folder with all licenses
- CONTRIBUTIONS.md has been updated accordingly

For automated changes based on OAI PL v1.1:

    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.{c,h,cpp}
    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.ts
    perl -i~ -0pe 's/<!--.*Licensed to the OpenAirInterface.*openairinterface.org\n.*-->/<!-- SPDX-License-Identifier: LicenseRef-CSSL-1.0 -->/s' **/*.xml

The rest (cmake, files with missing license, cmake) manually.
2026-03-27 16:36:37 +01:00

87 lines
1.8 KiB
C

/*
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
*/
#include "handler.h"
#include "event.h"
#include "database.h"
#include <stdlib.h>
#include <stdio.h>
typedef void (*handler_function)(void *p, event e);
struct handler_data {
handler_function f;
void *p;
unsigned long id;
};
struct handler_list {
struct handler_data *f;
int size;
int maxsize;
};
/* internal definition of an event handler */
struct _event_handler {
void *database;
struct handler_list *events;
unsigned long next_id;
};
void handle_event(event_handler *_h, event e)
{
struct _event_handler *h = _h;
int i;
for (i = 0; i < h->events[e.type].size; i++)
h->events[e.type].f[i].f(h->events[e.type].f[i].p, e);
}
event_handler *new_handler(void *database)
{
struct _event_handler *ret = calloc(1, sizeof(struct _event_handler));
if (ret == NULL) abort();
ret->database = database;
ret->events = calloc(number_of_ids(database), sizeof(struct handler_list));
if (ret->events == NULL) abort();
ret->next_id = 1;
return ret;
}
unsigned long register_handler_function(event_handler *_h, int event_id,
void (*f)(void *, event), void *p)
{
struct _event_handler *h = _h;
unsigned long ret = h->next_id;
struct handler_list *l;
h->next_id++;
if (h->next_id == 2UL * 1024 * 1024 * 1024)
{ printf("%s:%d: this is bad...\n", __FILE__, __LINE__); abort(); }
l = &h->events[event_id];
if (l->size == l->maxsize) {
l->maxsize += 16;
l->f = realloc(l->f, l->maxsize * sizeof(struct handler_data));
if (l->f == NULL) abort();
}
l->f[l->size].f = f;
l->f[l->size].p = p;
l->f[l->size].id = ret;
l->size++;
return ret;
}
void remove_handler_function(event_handler *h, int event_id,
unsigned long handler_id)
{
printf("%s:%d: TODO\n", __FILE__, __LINE__);
abort();
}