atlas  0.6
Macros | Enumerations | Functions | Variables
common.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include "common.h"
#include <stdarg.h>
Include dependency graph for common.c:

Macros

#define max_bytes   50000L \
 
#define max_modules   1000
 
#define max_idents   5000
 
#define max_sections   4000 \
 
#define hash_size   353
 
#define buf_size   200
 
#define longest_name   1000 \
 
#define long_buf_size   (buf_size+longest_name)
 
#define local   static
 
#define array_size(a)   ((int)(sizeof(a)/sizeof(a[0])))
 
#define false   (boolean) 0
 
#define true   (boolean) 1
 
#define ctangle   0
 
#define cweave   1
 
#define and_and   04
 
#define lt_lt   020
 
#define gt_gt   021
 
#define plus_plus   013
 
#define minus_minus   01
 
#define minus_gt   031
 
#define not_eq   032
 
#define lt_eq   034
 
#define gt_eq   035
 
#define eq_eq   036
 
#define or_or   037
 
#define find_char()   (loc<=limit || get_line())
 
#define id_index(p)   ((sixteen_bits)((p)-id_table))
 
#define id_at(i)   (&id_table[i])
 
#define mod_index(p)   ((sixteen_bits)((p)-mod_table))
 
#define mod_at(i)   (&mod_table[i])
 
#define name_begin(p)   ((p)->byte_start)
 
#define length(p)   ((int)(strlen(name_begin(p))))
 
#define name_end(p)   (name_begin(p)+length(p))
 
#define complete_name(p)   ((p)->byte_start[-1]=='\0')
 
#define print_mod(p)   printf(": <%s%s>",name_begin(p), complete_name(p) ? "" : "..." )
 
#define spotless   0
 
#define harmless_message   1
 
#define error_message   2
 
#define fatal_message   3
 
#define mark_harmless()   if (history==spotless) history=harmless_message; else
 
#define mark_error()   (history=error_message)
 
#define overflow(t)   fatal("\n! Sorry, %s capacity exceeded",t) \
 
#define confusion(s)   fatal("\n! This can't happen: %s",s)
 
#define show_banner   flags['b']
 
#define show_happiness   flags['h']
 
#define show_progress   flags['p']
 
#define show_stats   flags['s']
 
#define C_plus_plus   flags['+']
 
#define compatibility_mode   flags['c']
 
#define update_terminal()   fflush(stdout)
 
#define new_line()   putchar('\n')
 
#define term_write(string, leng)   printf("%.*s",(int)(leng),string)
 
#define buffer_end   (&buffer[buf_size-2])
 
#define max_include_depth   32 \
 
#define max_include_paths   16 \
 
#define max_path_length   200
 
#define lines_match()
 
#define byte_mem_end   (&byte_mem[max_bytes])
 
#define id_table_end   (&id_table[max_idents])
 
#define mod_table_end   (&mod_table[max_modules])
 
#define copy_char(c)   if (id_loc<mod_text_end) *id_loc++=c; else (void)(c)
 
#define CPPEXT   "cpp"
 

Enumerations

enum  mod_comparison {
  less, equal, greater, prefix,
  extension
}
 

Functions

boolean names_match (id_pointer, char *, int, int)
 
void init_id_name (id_pointer, int)
 
void init_module_name (mod_pointer)
 
local void scan_args (int argc, char **argv)
 
void common_init (int argc, char **argv, char *version)
 
local boolean input_ln (FILE *f)
 
boolean locate_file_name ()
 
boolean push_input_file (boolean header, boolean suspend)
 
local boolean get_web_line (void)
 
local void prime_the_change_buffer (void)
 
local void check_change (void)
 
void reset_input (void)
 
boolean get_line (void)
 
void check_complete (void)
 
char * store_string (char *s, int l)
 
id_pointer id_lookup (char *first, char *last, int ilk)
 
local enum mod_comparison mod_name_cmp (char *p, int l1, char *q, int l2)
 
local mod_pointer make_mod_node (char *name)
 
local mod_pointer mod_name_lookup (char *name, int l)
 
local mod_pointer prefix_lookup (char *name, int l)
 
mod_pointer get_module_name (void)
 
boolean get_control_text (void)
 
void get_string (void)
 
void err_print (char *s)
 
void wrap_up (void)
 
void fatal (char *s,...)
 
void open_output_file (void)
 
void print (char *s,...)
 
void print_progress (char *s)
 
void print_section_progress (void)
 

Variables

int program
 
int phase
 
char buffer [long_buf_size]
 
char * loc =buffer
 
char * limit =buffer
 
struct f file [max_include_depth]
 
struct f change
 
local char web_file_name [max_file_name_length]
 
local char change_file_name [max_file_name_length]
 
local char alt_web_file_name [max_file_name_length]
 
int include_depth
 
boolean input_has_ended
 
boolean changing
 
boolean web_file_open =false
 
boolean print_where =false
 
struct {
   char *   name
 
   int   length
 
at_h_path [max_include_paths]
 
struct {
   char *   name
 
   int   length
 
at_i_path [max_include_paths]
 
boolean including_header_file =false
 
local boolean saved_changing
 
local char * saved_change_limit
 
local int saved_include_depth =0
 
local char change_buffer [buf_size]
 
local char * change_limit
 
sixteen_bits section_count
 
eight_bits changed_section [(max_sections+7)/8]
 
char byte_mem [max_bytes]
 
char * byte_ptr =&byte_mem[0]
 
id_info id_table [max_idents]
 
id_pointer id_ptr =&id_table[0]
 
mod_info mod_table [max_modules]
 
mod_pointer mod_ptr =&mod_table[0]
 
id_pointer hash [hash_size]
 
mod_pointer root =NULL
 
char mod_text [longest_name+1]
 
char * id_first
 
char * id_loc
 
int history =spotless
 
boolean flags [UCHAR_MAX+1]
 
char C_file_name [max_file_name_length]
 
local char tex_file_name [max_file_name_length]
 
char idx_file_name [max_file_name_length]
 
char scn_file_name [max_file_name_length]
 
local boolean change_file_explicit =false
 
FILE * C_file
 
FILE * tex_file
 
local boolean term_line_empty =true
 

Macro Definition Documentation

#define and_and   04
#define array_size (   a)    ((int)(sizeof(a)/sizeof(a[0])))
#define buf_size   200
#define buffer_end   (&buffer[buf_size-2])
#define byte_mem_end   (&byte_mem[max_bytes])
#define C_plus_plus   flags['+']
#define compatibility_mode   flags['c']
#define complete_name (   p)    ((p)->byte_start[-1]=='\0')
#define confusion (   s)    fatal("\n! This can't happen: %s",s)
#define copy_char (   c)    if (id_loc<mod_text_end) *id_loc++=c; else (void)(c)
#define CPPEXT   "cpp"
#define ctangle   0
#define cweave   1
#define eq_eq   036
#define error_message   2
#define false   (boolean) 0
#define fatal_message   3
#define find_char ( )    (loc<=limit || get_line())
#define gt_eq   035
#define gt_gt   021
#define harmless_message   1
#define hash_size   353
#define id_at (   i)    (&id_table[i])
#define id_index (   p)    ((sixteen_bits)((p)-id_table))
#define id_table_end   (&id_table[max_idents])
#define length (   p)    ((int)(strlen(name_begin(p))))
#define lines_match ( )
Value:
&& strncmp(buffer, change_buffer, limit-buffer)==0)
char buffer[long_buf_size]
Definition: common.c:88
local char change_buffer[buf_size]
Definition: common.c:112
char * limit
Definition: common.c:91
local char * change_limit
Definition: common.c:113
#define local   static
#define long_buf_size   (buf_size+longest_name)
#define longest_name   1000 \
#define lt_eq   034
#define lt_lt   020
#define mark_error ( )    (history=error_message)
#define mark_harmless ( )    if (history==spotless) history=harmless_message; else
#define max_bytes   50000L \
#define max_idents   5000
#define max_include_depth   32 \
#define max_include_paths   16 \
#define max_modules   1000
#define max_path_length   200
#define max_sections   4000 \
#define minus_gt   031
#define minus_minus   01
#define mod_at (   i)    (&mod_table[i])
#define mod_index (   p)    ((sixteen_bits)((p)-mod_table))
#define mod_table_end   (&mod_table[max_modules])
#define name_begin (   p)    ((p)->byte_start)
#define name_end (   p)    (name_begin(p)+length(p))
#define new_line ( )    putchar('\n')
#define not_eq   032
#define or_or   037
#define overflow (   t)    fatal("\n! Sorry, %s capacity exceeded",t) \
#define plus_plus   013
#define print_mod (   p)    printf(": <%s%s>",name_begin(p), complete_name(p) ? "" : "..." )
#define show_banner   flags['b']
#define show_happiness   flags['h']
#define show_progress   flags['p']
#define show_stats   flags['s']
#define spotless   0
#define term_write (   string,
  leng 
)    printf("%.*s",(int)(leng),string)
#define true   (boolean) 1
#define update_terminal ( )    fflush(stdout)

Enumeration Type Documentation

Enumerator
less 
equal 
greater 
prefix 
extension 

Function Documentation

local void check_change ( void  )
void check_complete ( void  )
void common_init ( int  argc,
char **  argv,
char *  version 
)
void err_print ( char *  s)
void fatal ( char *  s,
  ... 
)
boolean get_control_text ( void  )
boolean get_line ( void  )
mod_pointer get_module_name ( void  )
void get_string ( void  )
local boolean get_web_line ( void  )
id_pointer id_lookup ( char *  first,
char *  last,
int  ilk 
)
void init_id_name ( id_pointer  dummy,
int  ilk 
)
void init_module_name ( mod_pointer  node)
local boolean input_ln ( FILE *  f)
boolean locate_file_name ( )
local mod_pointer make_mod_node ( char *  name)
local enum mod_comparison mod_name_cmp ( char *  p,
int  l1,
char *  q,
int  l2 
)
local mod_pointer mod_name_lookup ( char *  name,
int  l 
)
boolean names_match ( id_pointer  x,
char *  q,
int  l,
int  dummy 
)
void open_output_file ( void  )
local mod_pointer prefix_lookup ( char *  name,
int  l 
)
local void prime_the_change_buffer ( void  )
void print ( char *  s,
  ... 
)
void print_progress ( char *  s)
void print_section_progress ( void  )
boolean push_input_file ( boolean  header,
boolean  suspend 
)
void reset_input ( void  )
local void scan_args ( int  argc,
char **  argv 
)
char* store_string ( char *  s,
int  l 
)
void wrap_up ( void  )

Variable Documentation

local char alt_web_file_name[max_file_name_length]
local { ... } at_h_path[max_include_paths]
local { ... } at_i_path[max_include_paths]
char buffer[long_buf_size]
char byte_mem[max_bytes]
char* byte_ptr =&byte_mem[0]
FILE* C_file
char C_file_name[max_file_name_length]
struct f change
local char change_buffer[buf_size]
local boolean change_file_explicit =false
local char change_file_name[max_file_name_length]
local char* change_limit
eight_bits changed_section[(max_sections+7)/8]
boolean changing
struct f file[max_include_depth]
boolean flags[UCHAR_MAX+1]
int history =spotless
char* id_first
char* id_loc
id_pointer id_ptr =&id_table[0]
id_info id_table[max_idents]
char idx_file_name[max_file_name_length]
int include_depth
boolean including_header_file =false
boolean input_has_ended
int length
char* limit =buffer
char* loc =buffer
mod_pointer mod_ptr =&mod_table[0]
mod_info mod_table[max_modules]
char mod_text[longest_name+1]
char* name
int phase
boolean print_where =false
int program
mod_pointer root =NULL
local char* saved_change_limit
local boolean saved_changing
local int saved_include_depth =0
char scn_file_name[max_file_name_length]
sixteen_bits section_count
local boolean term_line_empty =true
FILE* tex_file
local char tex_file_name[max_file_name_length]
local char web_file_name[max_file_name_length]
boolean web_file_open =false