File: queue.h

package info (click to toggle)
yodl 4.04.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,720 kB
  • sloc: ansic: 7,803; perl: 683; cpp: 570; sh: 411; xml: 190; makefile: 164
file content (43 lines) | stat: -rw-r--r-- 946 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef INCLUDED_QUEUE_H_
#define INCLUDED_QUEUE_H_

#include "../root/root.h"

typedef struct
{
    char *d_memory;
    char *d_memory_end;
    char *d_read;
    char *d_write;
}
Queue;

              void  queue_construct(register Queue *qp, char const *str);
static inline void  queue_destruct(register Queue *qp);

int queue_get(register Queue *qp);
void queue_push(register Queue *qp, size_t extra_length, char const *info);
void queue_unget(register Queue *qp, int ch);           /* must have room   */

/* 
    Internal use only. Not used outside of this directory, needed here
    to allow proper compilation of the static inline functions below
*/

#include <stdlib.h>
#include <stdio.h>


/*  public interface continues from here */


static inline int queue_peek(register Queue *qp)
{
    return qp->d_read != qp->d_write ? *qp->d_read : EOF;
}
static inline void queue_destruct(register Queue *qp)
{
    free(qp->d_memory);
}

#endif