⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stk.c

📁 Solaris操作系统下的过滤驱动程序, C源码程序.
💻 C
字号:
/* * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 2001-2003 Stony Brook University * Copyright (c) 1997-2000 Columbia University * * For specific licensing information, see the COPYING file distributed with * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. * * This Copyright notice must be kept intact and distributed with all * fistgen sources INCLUDING sources generated by fistgen. *//* * stk.c: stack manipulation routines * Fistgen sources. */#ifdef HAVE_CONFIG_H# include <config.h>#endif /* HAVE_CONFIG_H */typedef struct stk_cell {  int val;  struct stk_cell *next;} stk_cell_t;static stk_cell_t *cpp_stack = NULL;voidstk_init(void){  if (cpp_stack)    fprintf(stderr, "internal error: stack is not empty!\n");  cpp_stack = NULL;		/* XXX: free it if not NULL */}/* pust a new element onto the stack */voidstk_push(int val){  stk_cell_t *tmp = malloc(sizeof(stk_cell_t));  if (!tmp) {    fprintf(stderr, "no more memory for stack cells\n");    exit(1);  }  tmp->val = val;  tmp->next = cpp_stack;  cpp_stack = tmp;}/* return top element in the stack, or -1 of empty */intstk_pop(void){  stk_cell_t *tmp;  int val;  if (!cpp_stack) {    fprintf(stderr, "cannot pop an empty stack. cpp error.\n");    return -1;  }  tmp = cpp_stack;  cpp_stack = cpp_stack->next;  val = tmp->val;  free(tmp);  tmp = NULL;  return val;}/* * Return value at top of stack. * TRUE/FALSE or -1 if stack is empty. */intstk_top(void){  if (!cpp_stack) {    fprintf(stderr, "stk_top: state stack is empty!\n");    return -1;  }  return cpp_stack->val;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -