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

« back to all changes in this revision

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