2024-10-19 16:05:49 +02:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* utilities header
|
|
|
|
*
|
|
|
|
* This file is part of Gem-graph.
|
|
|
|
*
|
|
|
|
* @cond LICENSE
|
|
|
|
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
|
|
|
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
|
|
|
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
* Software Foundation, either version 3 of the License, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* @endcond
|
|
|
|
*/
|
2024-08-23 23:30:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <gtk-4.0/gtk/gtk.h>
|
|
|
|
|
2024-08-26 22:11:51 +02:00
|
|
|
#include "../include/fsm.h"
|
2024-08-23 23:30:39 +02:00
|
|
|
|
2024-08-25 22:03:16 +02:00
|
|
|
char *util_read_file (char *filename);
|
2024-09-22 22:47:52 +02:00
|
|
|
// Programmers using the strcat function can easily be recognized as lazy and reckless.
|
|
|
|
// (quoted from: The GNU C Library (glibc) manual - 5.5 Concatenating Strings)
|
2024-10-05 18:47:32 +02:00
|
|
|
char *util_concat (const char *str, ...);
|
2024-08-23 23:30:39 +02:00
|
|
|
|
2024-10-14 15:52:00 +02:00
|
|
|
|
2024-10-22 23:58:04 +02:00
|
|
|
/** phantom documentation */
|
2024-10-14 15:52:00 +02:00
|
|
|
|
|
|
|
typedef struct pile {
|
|
|
|
int value; /**< value phantom documentation */
|
|
|
|
struct pile *prev; /**< *prev phantom documentation */
|
|
|
|
} pile; // structure d'un élément
|
2024-08-26 07:26:53 +02:00
|
|
|
|
2024-08-26 16:03:07 +02:00
|
|
|
void util_pile_clear (pile **); // vide toute la pile
|
|
|
|
void util_pile_view (pile *); // affiche la pile en commençant par le sommet
|
|
|
|
int util_pile_push (pile **, int); // ajoute une valeur sur la pile
|
|
|
|
int util_pile_pop (pile **); // retire la dernière valeur empilée
|
|
|
|
int util_pile_length (pile *p); // renvoie le nombre d'éléments de la pile
|
2024-08-23 23:30:39 +02:00
|
|
|
|
2024-08-25 22:03:16 +02:00
|
|
|
//------------------------------------------------------------------------------
|
2024-08-24 10:52:28 +02:00
|
|
|
|
2024-10-14 15:52:00 +02:00
|
|
|
|
2024-10-22 23:58:04 +02:00
|
|
|
/** simplest element of a double-chained list */
|
2024-10-14 15:52:00 +02:00
|
|
|
typedef struct elem {
|
|
|
|
int value; /**< *value phantom documentation */
|
|
|
|
struct elem *prev; /**< *prev phantom documentation */
|
|
|
|
struct elem *next; /**< *next phantom documentation */
|
|
|
|
} elem;
|
|
|
|
|
|
|
|
|
2024-10-22 23:58:04 +02:00
|
|
|
/** required to init the empty list */
|
2024-10-14 15:52:00 +02:00
|
|
|
typedef struct {
|
|
|
|
elem *first; /**< *first phantom documentation */
|
|
|
|
elem *last; /**< *last phantom documentation */
|
2024-10-22 23:58:04 +02:00
|
|
|
} dblist;
|
|
|
|
|
2024-08-26 16:03:07 +02:00
|
|
|
void util_list_2x2_init (dblist *l); // initialisation
|
|
|
|
void util_list_2x2_clear (dblist *l); // vide toute la liste
|
|
|
|
void util_list_2x2_view (dblist l); // affiche les valeurs de toute la liste
|
|
|
|
int util_list_2x2_push_back (dblist *l, int val); // ajoute une valeur en fin de liste
|
|
|
|
int util_list_2x2_push_front (dblist *l, int val); // ajoute une valeur en début de liste
|
|
|
|
int util_list_2x2_pop_back (dblist *l); // retire une valeur en fin de liste
|
|
|
|
int util_list_2x2_pop_front (dblist *l); // retire une valeur en début de liste
|
|
|
|
int util_list_2x2_length (dblist l); // renvoie le nombre d'éléments de la liste
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2024-10-14 15:52:00 +02:00
|
|
|
|
2024-10-22 23:58:04 +02:00
|
|
|
/** phantom documentation */
|
2024-10-14 15:52:00 +02:00
|
|
|
typedef struct slist {
|
|
|
|
int value; /**< value phantom documentation */
|
|
|
|
struct slist *suiv; /**< *suiv phantom documentation */
|
|
|
|
} slist ;
|
|
|
|
|
2024-08-26 16:03:07 +02:00
|
|
|
void util_sorted_list_clear (slist **sl); // vide toute la liste
|
|
|
|
void util_sorted_list_view (slist *sl); // affiche toute la liste
|
|
|
|
int util_sorted_list_insert (slist **sl, int val); // insertion d'un élément selon son rang
|
|
|
|
int util_sorted_list_pop (slist **sl); // retire la dernière valeur de la liste
|
|
|
|
int util_sorted_list_length (slist *sl); // renvoie le nombre d'éléments de la liste
|
2024-08-24 10:52:28 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2024-08-27 15:07:16 +02:00
|
|
|
void util_trigger_test(); // def: util/tests.c calls: ...
|
2024-10-05 18:47:32 +02:00
|
|
|
void util_test_pile(); // called in fsm/measure.c
|
|
|
|
void util_test_double_list(); // " "
|
|
|
|
void util_test_sorted_list(); // " "
|
2024-08-25 11:35:43 +02:00
|
|
|
|
2024-09-10 13:25:47 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
long util_gl_get_stack(void *container_widget);
|
|
|
|
bool util_gl_init_stack(void *container_widget, GError *error_buffer);
|
|
|
|
bool util_gl_shutdown_stack(void *container_widget, GError *error_buffer);
|
|
|
|
void util_gl_clean_stack_index(void);
|
|
|
|
bool util_gl_render_stack(GtkWidget *container_widget);
|
|
|
|
bool util_gl_update_axis(GtkWidget *container_widget, int axis, int value);
|
|
|
|
void util_gl_shutdown_all_stacks(void);
|
|
|
|
GtkWidget *create_axis_slider(int axis);
|
2024-10-22 23:58:04 +02:00
|
|
|
// long util_gl_is_util_ready(void *container_widget);
|
2024-09-10 13:25:47 +02:00
|
|
|
|