/* * sequence.h * Author: Hannah C. Tang (hctang@cs) * * Specification of public functions for the sequence struct * (wrapper for basic Sequence operations) * * $Id: Sequence.h,v 1.1 2001/12/18 00:24:16 cse466_t Exp $ * */ #ifndef SEQUENCE_H #define SEQUENCE_H #include #include "common.h" struct Sequence { unsigned int length : 8; /* 8 bits ==> [0, 255] */ unsigned int period : 4; /* 4 bits ==> [0, 15] */ unsigned int mode : 4; /* 4 bits ==> [0, 15] */ }; extern const struct Sequence MODE_BEGIN; extern const struct Sequence PROGRAM_BEGIN; extern const struct Sequence INF_LOOP_BEGIN; extern const struct Sequence GOTO_LOOP; /* Dynamically allocate and free Sequence structs */ struct Sequence* Sequence_mallocOne( void ); struct Sequence* Sequence_mallocMany( unsigned int numSequences ); void Sequence_free( struct Sequence *pS ); /* Print a Sequence */ void Sequence_print( const struct Sequence *pS, FILE *stream ); /* Get/Set the length field of a Sequence. Returns Bool_false on * overflow, Bool_true otherwise */ unsigned int Sequence_getLength( const struct Sequence *pS ); Bool Sequence_setLength( struct Sequence *pS, unsigned int length ); /* Get/Set the period field of a Sequence. Returns Bool_false on * overflow, Bool_true otherwise */ unsigned int Sequence_getPeriod( const struct Sequence *pS ); Bool Sequence_setPeriod( struct Sequence *pS, unsigned int period ); /* Get/Set the mode field of a Sequence. Returns Bool_false on * overflow, Bool_true otherwise */ unsigned int Sequence_getMode( const struct Sequence *pS ); Bool Sequence_setMode( struct Sequence *pS, unsigned int mode ); /* Get/Set all the fields of a Sequence. setAll Bool_false * if any of these fields are invalid. The values of pLength, * pPeriod, and pMode are 0 if pS is NULL */ void Sequence_getAll( const struct Sequence *pS, unsigned int *pLength, unsigned int *pPeriod, unsigned int *pMode ); Bool Sequence_setAll( struct Sequence *pS, unsigned int length, unsigned int period, unsigned int mode ); #endif /* SEQUENCE_H */