~ubuntu-branches/debian/sid/rlinetd/sid

« back to all changes in this revision

Viewing changes to stack.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2010-03-20 18:03:45 UTC
  • mfrom: (2.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100320180345-x1srfbe2tg00ezsf
Tags: 0.7-1
* New upstream version.
* Recommend rsyslog instead of sysklogd (closes: #526922).
* update-inetd:
  + add support for enabling, disabling and removing entries;
  + use ucf for managing generated files;
  + ignore ucf files in rlinetd.conf;
  + make appropriate changes in  postinst and postrm scripts.
* Set debhelper compat level to 7
* Standards-Version: 3.8.4 (no changes). 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdlib.h>
2
 
 
3
 
#include "bytecode.h"
4
 
#include "error.h"
5
 
#include "stack.h"
6
 
 
7
 
void rlstk_push(struct rl_stack *s, rl_opcode_t val) {
8
 
        if(s->top == STACKSIZE)
9
 
                rl_fatal(EX_SOFTWARE, "Stack overflow");
10
 
        s->data[s->top++] = val;
11
 
}
12
 
 
13
 
rl_opcode_t rlstk_pop(struct rl_stack *s) {
14
 
        if(!s->top)
15
 
                rl_fatal(EX_SOFTWARE, "Stack underflow");
16
 
        return s->data[--s->top];
17
 
}
18
 
 
19
 
rl_opcode_t rlstk_peek(struct rl_stack *s, int offset) {
20
 
        if(offset >= s->top)
21
 
                rl_fatal(EX_SOFTWARE, "Stack peek undefined");
22
 
        return s->data[s->top - offset - 1];
23
 
}
24
 
 
25
 
void rlstk_poke(struct rl_stack *s, int offset, rl_opcode_t val) {
26
 
        if(offset >= s->top)
27
 
                rl_fatal(EX_SOFTWARE, "Stack peek undefined");
28
 
        s->data[s->top - offset - 1] = val;
29
 
}
30
 
 
31
 
struct rl_stack *rlstk_new() {
32
 
        struct rl_stack *s;
33
 
 
34
 
        s = malloc(sizeof(*s));
35
 
        if (!s)
36
 
                rl_fatal(EX_SOFTWARE, "ABORT - Can't allocate memory");
37
 
        memset(s, 0, sizeof(*s));
38
 
        return s;
39
 
}
40
 
 
41
 
void rlstk_free(struct rl_stack *s) {
42
 
        free(s);
43
 
}
44
 
 
45
 
/* vim: set ts=2: */