2024-09-10 12:58:18 +02:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Gem-graph client *
|
|
|
|
* Utilities header *
|
2024-08-23 23:30:39 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
|
|
|
|
* Copyright © 2024 Jean Sirmai <jean@a-lec.org> *
|
2024-08-23 23:30:39 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* This file is part of Gem-graph. *
|
2024-08-23 23:30:39 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU Affero General Public License *
|
|
|
|
* as publishedby the Free Software Foundation, *
|
|
|
|
* either version 3 of the License, or (at your option) any later version. *
|
2024-08-23 23:30:39 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* 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. *
|
2024-08-23 23:30:39 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* 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/>. *
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
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-09-21 08:47:17 +02:00
|
|
|
char *concat (const char *str, ...);
|
2024-08-23 23:30:39 +02:00
|
|
|
|
2024-08-27 15:07:16 +02:00
|
|
|
typedef struct pile {int value; struct pile *prev;} 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-08-26 07:26:53 +02:00
|
|
|
typedef struct elem {int value; struct elem *prev; struct elem *next;} elem;
|
2024-08-25 22:03:16 +02:00
|
|
|
typedef struct {elem *first; elem *last;} dblist; // structure d'accès à la liste
|
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
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
typedef struct slist {int value; struct slist *suiv;} slist ;
|
|
|
|
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-08-26 22:11:51 +02:00
|
|
|
void util_pile_test(); // called in fsm/measure.c
|
|
|
|
void util_double_list_test(); // " "
|
|
|
|
void util_sorted_list_test(); // " "
|
2024-08-25 11:35:43 +02:00
|
|
|
|
2024-09-10 13:25:47 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for stack entry and returns stack_id
|
|
|
|
*
|
|
|
|
* @params container_widget, generally the GtkBox that contains the GLArea
|
|
|
|
*
|
|
|
|
* @returns stack_id
|
|
|
|
*/
|
|
|
|
long util_gl_get_stack(void *container_widget);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for stack entry and returns stack_id
|
|
|
|
*
|
|
|
|
* @params container_widget, generally the GtkBox that contains the GLArea
|
|
|
|
*
|
|
|
|
* @returns stack_id
|
|
|
|
*/
|
|
|
|
long util_gl_is_util_ready(void *container_widget);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for stack entry and initializes OpenGL for it
|
|
|
|
*
|
|
|
|
* @params container_widget, generally the GtkBox that contains the GLArea
|
|
|
|
*
|
|
|
|
* @returns bool, true if success
|
|
|
|
*/
|
|
|
|
bool util_gl_init_stack(void *container_widget, GError *error_buffer);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for stack entry and shutdowns OpenGL for it
|
|
|
|
*
|
|
|
|
* @params container_widget, generally the GtkBox that contains the GLArea
|
|
|
|
*
|
|
|
|
* @returns bool, true if success
|
|
|
|
*/
|
|
|
|
bool util_gl_shutdown_stack(void *container_widget, GError *error_buffer);
|
|
|
|
|
|
|
|
void util_gl_clean_stack_index(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for stack entry and triggers OpenGL for drawing
|
|
|
|
*
|
|
|
|
* @params container_widget, generally the GtkBox that contains the GLArea
|
|
|
|
*
|
|
|
|
* @returns bool, true if success
|
|
|
|
*/
|
|
|
|
bool util_gl_render_stack(GtkWidget *container_widget);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for stack entry and triggers OpenGL for drawing
|
|
|
|
*
|
|
|
|
* @params container_widget, generally the GtkBox that contains the GLArea
|
|
|
|
*
|
|
|
|
* @returns bool, true if success
|
|
|
|
*/
|
|
|
|
bool util_gl_update_axis(GtkWidget *container_widget, int axis, int value);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for every stack entry and shutdowns OpenGL for it
|
|
|
|
*
|
|
|
|
* @params void
|
|
|
|
*
|
|
|
|
* @returns bool, true if success
|
|
|
|
*/
|
|
|
|
void util_gl_shutdown_all_stacks(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Creates a slider widget
|
|
|
|
*
|
|
|
|
* @params axis, meaning which axis we're building (for label)
|
|
|
|
*
|
|
|
|
* @returns GtkWidget*, pointer to the new widget
|
|
|
|
*/
|
|
|
|
GtkWidget *create_axis_slider(int axis);
|
|
|
|
|