home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / edauxi.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-30  |  6.8 KB  |  262 lines

  1. /*
  2.     GWAda Development Environment for 386/486 PCs   
  3.     Copyright (C) 1993, Arthur Vargas Lopes  & Michael Bliss Feldman
  4.                         vlopes@vortex.ufrgs.br mfeldman@seas.gwu.edu
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; version 2 of the License.    
  9.  
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. /* edauxi.c */
  22. #include "externs.h"
  23.  
  24.  
  25. void AVL_MD_TOOLS()
  26. {
  27. }
  28.  
  29.  
  30.  
  31. void AVL_SHIFT_LEFT(char *s, short pos)
  32. {
  33.     int i, j;
  34.     if (pos < 1) return;
  35.     j = strlen(s);
  36.     for (i = pos - 1; i < j; ++i)
  37.         *(s+i) = *(s + i + 1);
  38. }
  39.  
  40.  
  41. void AVL_FULL_FN(char *s)
  42. {
  43.     sprintf(s,"%s%c%s",avl_dir_sources,'\\',avl_windows[avl_window].file_name);
  44. }
  45.  
  46.  
  47. void AVL_MAKE_FN(char *d, char *s)
  48. {
  49.     int i, j;
  50.     char fn[128];
  51.     for(i = strlen(s) - 1; i >= 0; --i)
  52.         if ((*(s + i) == ':') || (*(s + i) == '\\'))
  53.             break;
  54.     if (i < 0)
  55.         strcpy(d,s);
  56.     else 
  57.         strcpy(d,s+i+1);
  58. }
  59.         
  60.  
  61.  
  62. void AVL_FIX()
  63. {
  64.     unsigned int u, *u2;
  65.     int *i;
  66.     FILE *fp, *fopen();
  67.     char line[100];
  68.     AVL_LINE_PTR t;
  69.     AVL_EDIT_WINDOW_PTR w;
  70.     w = &avl_windows[avl_window];
  71.     w -> current_line = w -> head -> next;
  72.     w -> txt_pos = w -> line_no = 0;
  73.     if (w -> avl_win1 == NULL)  {
  74.         sprintf(line," Compiling %s ", w -> file_name);
  75.         w -> avl_win1 = AVL_MAKE_WINDOW(line,14,4,16,64,7,15);
  76.         _settextposition(3,1);
  77.         _outtext("Compiling line: ");
  78.         _settextposition(1,17);
  79.         }
  80. }
  81.  
  82. void AVL_GET_CDIR()
  83. {
  84.     avl_curr_directory[0] = '\0';
  85.     _getdcwd(0,avl_curr_directory,128);
  86. }
  87.  
  88. void AVL_DEFAULT_OPTIONS()
  89. {    
  90.     AVL_GET_CDIR();
  91.     strcpy(avl_dir_sources,avl_curr_directory);
  92.     sprintf(avl_dir_library,"%s",AVL_DEFAULT_LIB);
  93.     avl_heap = 32;
  94.     avl_monitor_on = '\0';
  95.     avl_pgm_stack = 4;
  96.     avl_task_stack = 2;
  97.     avl_scheduller = 0;
  98.     avl_trace_opts[0] = '\0';
  99.     avl_trace_opts[1] = '\0';
  100.     avl_trace_opts[2] = '\0';
  101.     avl_trace_opts[3] = '\0';
  102.     avl_trace_opts[4] = '\0';
  103.     avl_trace_opts[5] = '\0';
  104.     AVL_RESET_COLORS();
  105.     avl_tab_size = 4;
  106. }
  107.  
  108. void AVL_SAVE_OPTIONS()
  109. {
  110.     AVL_OPTIONS opt; 
  111.     int fp, n;
  112.     unlink(AVL_FN_OPTIONS);       
  113.     fp = open(AVL_FN_OPTIONS,O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
  114.     if (fp == -1)  {
  115.         AVL_ERROR("Can't save options. Check disk space.");
  116.         return;
  117.         }
  118.     strcpy(opt.sources,avl_dir_sources);
  119.     strcpy(opt.library,avl_dir_library);
  120.     opt.avl_monitor_on = avl_monitor_on;
  121.     opt.tabsize = avl_tab_size;
  122.     opt.avl_heap = avl_heap;
  123.     opt.avl_pgm_stack = avl_pgm_stack;
  124.     opt.avl_task_stack = avl_task_stack;
  125.     opt.avl_scheduller = avl_scheduller;
  126.     opt.avl_trace_opts[0] = avl_trace_opts[0];
  127.     opt.avl_trace_opts[1] = avl_trace_opts[1];
  128.     opt.avl_trace_opts[2] = avl_trace_opts[2];
  129.     opt.avl_trace_opts[3] = avl_trace_opts[3];
  130.     opt.avl_trace_opts[4] = avl_trace_opts[4];
  131.     opt.avl_trace_opts[5] = avl_trace_opts[5];
  132.     opt.avl_txt_color = avl_txt_color;
  133.     opt.avl_txt_bk_color = avl_txt_bk_color;
  134.     opt.avl_wnd_color = avl_wnd_color;
  135.     opt.avl_wnd_title = avl_wnd_title;
  136.     opt.avl_wnd_bk_color = avl_wnd_bk_color;
  137.     opt.avl_que_color = avl_que_color;
  138.     opt.avl_que_bk_color = avl_que_bk_color;
  139.     opt.avl_pro_color = avl_pro_color;
  140.     opt.avl_pro_bk_color = avl_pro_bk_color;
  141.     opt.avl_men_ready = avl_men_ready;
  142.     opt.avl_men_letter = avl_men_letter;
  143.     opt.avl_men_word = avl_men_word;
  144.     opt.avl_men_bk_color = avl_men_bk_color;
  145.     opt.avl_err_color = avl_err_color;
  146.     opt.avl_sta_color = avl_sta_color;
  147.     opt.avl_sta_bk_color = avl_sta_bk_color;
  148.     opt.avl_msg_color = avl_msg_color;
  149.     opt.avl_msg_bk_color = avl_msg_bk_color;
  150.  
  151.     n = write(fp,&opt,sizeof(AVL_OPTIONS));
  152.     if (n != sizeof(AVL_OPTIONS)) {
  153.         AVL_ERROR("Can't save options. Check disk space.");
  154.         close(fp);
  155.         unlink(AVL_FN_OPTIONS);       
  156.         }
  157.     else
  158.         close(fp);
  159. }
  160.  
  161. void AVL_READ_OPTIONS()
  162. {
  163.     AVL_OPTIONS opt; 
  164.     int fp, n;
  165.     fp = open(AVL_FN_OPTIONS,O_BINARY | O_RDWR, S_IREAD | S_IWRITE);
  166.     if (fp == -1)  {
  167.         AVL_DEFAULT_OPTIONS();
  168.         return;
  169.         }
  170.     n = read(fp,&opt,sizeof(AVL_OPTIONS));
  171.     if (n != sizeof(AVL_OPTIONS))  {
  172.         close(fp);
  173.         unlink(AVL_FN_OPTIONS);
  174.         AVL_DEFAULT_OPTIONS();
  175.         return;
  176.         }
  177.     avl_heap = opt.avl_heap;
  178.     avl_monitor_on = opt.avl_monitor_on;
  179.     avl_pgm_stack = opt.avl_pgm_stack;
  180.     avl_task_stack = opt.avl_task_stack;
  181.     avl_scheduller = opt.avl_scheduller;
  182.     avl_trace_opts[0] = opt.avl_trace_opts[0];
  183.     avl_trace_opts[1] = opt.avl_trace_opts[1];
  184.     avl_trace_opts[2] = opt.avl_trace_opts[2];
  185.     avl_trace_opts[3] = opt.avl_trace_opts[3];
  186.     avl_trace_opts[4] = opt.avl_trace_opts[4];
  187.     avl_trace_opts[5] = opt.avl_trace_opts[5];
  188.     avl_txt_color = opt.avl_txt_color;
  189.     avl_txt_bk_color = opt.avl_txt_bk_color;
  190.     avl_wnd_color = opt.avl_wnd_color;
  191.     avl_wnd_title = opt.avl_wnd_title;
  192.     avl_wnd_bk_color = opt.avl_wnd_bk_color;
  193.     avl_que_color = opt.avl_que_color;
  194.     avl_que_bk_color = opt.avl_que_bk_color;
  195.     avl_pro_color = opt.avl_pro_color;
  196.     avl_pro_bk_color = opt.avl_pro_bk_color;
  197.     avl_men_ready= opt.avl_men_ready;
  198.     avl_men_letter = opt.avl_men_letter;
  199.     avl_men_word = opt.avl_men_word;
  200.     avl_men_bk_color = opt.avl_men_bk_color;
  201.     avl_err_color = opt.avl_err_color;
  202.     avl_sta_color = opt.avl_sta_color;
  203.     avl_sta_bk_color = opt.avl_sta_bk_color;
  204.     avl_msg_color = opt.avl_msg_color;
  205.     avl_msg_bk_color = opt.avl_msg_bk_color;
  206.     strcpy(avl_dir_sources,opt.sources);
  207.     strcpy(avl_dir_library,opt.library);
  208.     avl_tab_size = opt.tabsize;
  209.     close(fp);
  210. }
  211.  
  212.  
  213.  
  214. AVL_LINE_PTR AVL_MAKE_LINE(char *l, int lno)
  215. {
  216.     AVL_LINE_PTR temp;
  217.     if (strlen(l) >= AVL_MAX_LINEL)  {
  218.         AVL_ERROR("Line too long. Truncated to 256 characters.");
  219.         *(l+256) = '\0';
  220.         }
  221.     temp = (AVL_LINE_PTR) calloc(1,sizeof(AVL_LINE_SIZE));
  222.     if (temp == NULL) {
  223.         AVL_ERROR("Out of memory...");
  224.         exit(1);
  225.         }
  226.     strcpy(temp -> line,l);
  227.     temp -> line_no = lno;
  228.     temp -> line_attrib = '\0';
  229.     temp -> previous =
  230.     temp -> next     = NULL;
  231.     return temp;
  232. }
  233.  
  234. void AVL_RENUMBER(AVL_LINE_PTR from, int c, int n)
  235. {
  236.     int count;
  237.     AVL_LINE_PTR temp;
  238.     count = c; 
  239.     temp = from;
  240.     while (temp -> line_no != 1)  {
  241.         temp -> line_no += count;
  242.         count += n;
  243.         temp = temp -> next;
  244.         }
  245. }
  246.  
  247. void AVL_LINE_INSERT(AVL_LINE_PTR this,AVL_LINE_PTR  *at)
  248. {
  249.     if (*at == NULL)  {  /*  First line  */
  250.         *at = this;
  251.         this -> previous =
  252.         this -> next     = this;
  253.         this -> line_no  = 1;
  254.         }    
  255.     else {
  256.         this -> previous = *at;
  257.         this -> next     = (*at) -> next;
  258.         ((*at) -> next) -> previous = this;
  259.         (*at) -> next = this;
  260.         AVL_RENUMBER(this, (*at) -> line_no + 1, 1);
  261.         }
  262. }
  263.