#include #include "gst_cp.h" struct cp_st { int *charge; int *incr; int *reset; int *entree; int *sortie; }; cp_st cp_init (int *charge, int *incr, int *reset, int *entree, int *sortie) { cp_st cp = (cp_st) malloc (sizeof (struct cp_st)); assert (cp != NULL); cp->charge = charge; cp->incr = incr; cp->reset = reset; cp->entree = entree; cp->sortie = sortie; return cp; } void cp_evalue (cp_st cp) { if (*cp->reset == 1) *cp->sortie = 0; else if (*cp->reset == 0 && *cp->charge == 1) *cp->sortie = *cp->entree; else if (*cp->reset == 0 && *cp->charge == 0 && *cp->incr == 1) (*cp->sortie)++; } void cp_libere (cp_st cp) { free (cp); }