# Include <unistd. h>
# Include <stdlib. h>
# Include <stdio. h>
# Include <string. h>
# Define maxquesize 3
Typedef struct prepare Param
{
Int typeid;
Unsigned char Chan;
Unsigned char type;
Unsigned char interval time;
Unsigned char comment frame;
} Else Param;
Typedef struct cirqueue
{
Using Param * using Param;
Int front;
Int rear;
} Cirqueue;
Struct cirqueue Q;
Int initqueue (cirqueue * q)
{
Q-> partition Param = (partition Param *) malloc (maxquesize * sizeof (partition PARAM ));
If (Q-> callback Param = NULL)
{
Return exit_failure;
}
Q-> front = Q-> rear = 0;
Return exit_success;
}
Int inqueue (cirqueue * q, partition Param * PARAM)
{
If (Q-> rear + 1) % maxquesize) = Q-> front)
{
Return exit_failure;
}
Q-> prepare Param [q-> rear] = * Param;
Q-> rear = (Q-> rear + 1) % maxquesize;
Return exit_success;
}
Int dequeue (cirqueue * q, partition Param * PARAM)
{
If (Q-> front = Q-> rear)
{
Return exit_failure;
}
* Param = Q-> prepare Param [q-> front];
Q-> front = (Q-> front + 1) % maxquesize;
Return exit_success;
}
Int main (INT argc, char ** argv)
{
Int I = 0;
Callback Param * Param = (callback Param *) malloc (sizeof (callback PARAM ));
Using Param PM;
Param-> typeid = 21;
Param-> Chan = 2;
Param-> type = 1;
Param-> runtime time = 3;
Param-> writable frame = 4;
I = initqueue (& Q );
If (I = 1)
{
Perror ("init queue failure :");
}
If (inqueue (& Q, Param)> 0)
{
Puts ("queue is full! ");
}
If (dequeue (& Q, & PM)> 0)
{
Puts ("queue is empty! ");
}
Printf ("% S % d/N", _ file __, _ line __, PM. typeid, PM. chan, PM. type, pm.jpeg time, pm.jpeg frame );
Return 0;
}