2022-09-19 12:39:02 +02:00
|
|
|
/* Copyright (c) 2021 Barcelona Supercomputing Center (BSC)
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later */
|
2021-10-26 18:42:41 +02:00
|
|
|
|
2021-08-03 20:47:02 +02:00
|
|
|
#ifndef OVNI_PCF_H
|
|
|
|
#define OVNI_PCF_H
|
|
|
|
|
2022-05-31 20:39:57 +02:00
|
|
|
#include "uthash.h"
|
2022-09-29 15:34:44 +02:00
|
|
|
#include <stdio.h>
|
2021-08-03 20:47:02 +02:00
|
|
|
|
2022-05-31 20:39:57 +02:00
|
|
|
#define MAX_PCF_LABEL 512
|
|
|
|
|
|
|
|
struct pcf_value;
|
|
|
|
struct pcf_type;
|
|
|
|
|
|
|
|
struct pcf_value {
|
|
|
|
int value;
|
|
|
|
char label[MAX_PCF_LABEL];
|
|
|
|
|
|
|
|
UT_hash_handle hh;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pcf_type {
|
|
|
|
int id;
|
|
|
|
char label[MAX_PCF_LABEL];
|
|
|
|
|
|
|
|
int nvalues;
|
|
|
|
struct pcf_value *values;
|
|
|
|
|
|
|
|
UT_hash_handle hh;
|
|
|
|
};
|
|
|
|
|
2023-02-01 16:10:58 +01:00
|
|
|
struct pcf {
|
2022-05-31 20:39:57 +02:00
|
|
|
FILE *f;
|
|
|
|
int pcf_ntypes;
|
|
|
|
struct pcf_type *types;
|
|
|
|
};
|
|
|
|
|
2022-09-01 17:02:02 +02:00
|
|
|
/* Only used to generate tables */
|
|
|
|
struct pcf_value_label {
|
|
|
|
int value;
|
|
|
|
char *label;
|
|
|
|
};
|
|
|
|
|
2023-02-01 18:18:58 +01:00
|
|
|
int pcf_open(struct pcf *pcf, char *path);
|
|
|
|
int pcf_close(struct pcf *pcf);
|
2022-05-31 20:39:57 +02:00
|
|
|
|
2023-02-01 16:10:58 +01:00
|
|
|
struct pcf_type *pcf_find_type(struct pcf *pcf, int type_id);
|
2023-02-01 18:18:58 +01:00
|
|
|
struct pcf_type *pcf_add_type(struct pcf *pcf, int type_id, const char *label);
|
|
|
|
struct pcf_value *pcf_add_value(struct pcf_type *type, int value, const char *label);
|
2022-06-02 15:28:04 +02:00
|
|
|
struct pcf_value *pcf_find_value(struct pcf_type *type, int value);
|
|
|
|
|
2021-08-03 20:47:02 +02:00
|
|
|
#endif /* OVNI_PCF_H */
|