~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/util/macro_funcs.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <fcntl.h>
  2 #include <sys/file.h>
  3 #include <tina/all_tina.h>
  4 
  5 #define LINESIZE 128
  6 
  7 static Bool replay_break = false;
  8 static Bool replay = false;
  9 static char  macro_file[128] = "default";
 10 static char  macro_line[LINESIZE] = "no_line";
 11 static FILE   *fp = NULL;
 12 static char    name[LINESIZE], args[256];
 13 static int in_macro = 0;
 14 
 15 char *get_macro_line()
 16 {
 17    return(macro_line);
 18 }
 19 
 20 char *get_macro_file()
 21 {
 22     return(macro_file);
 23 }
 24 
 25 void start_macro_line()
 26 {
 27    char   callback_file[64];
 28 
 29    if (in_macro == 1)
 30    {
 31       (void) fclose(fp);
 32       fp = NULL;
 33       in_macro = 0;
 34    }
 35 
 36    if( in_macro == 0)
 37    {
 38       (void) string_append(callback_file, macro_file, ".cls", NULL);
 39       fp = fopen(callback_file, "r");
 40       if (fp == NULL)
 41       {  
 42           format("macro file not found\n");
 43           return;
 44       }  
 45       in_macro = 1;
 46    }
 47 }
 48 
 49 void next_macro_line()
 50 {
 51    char    sline[LINESIZE];
 52    void *disp_line_ptr = NULL;
 53 
 54 
 55    if((disp_line_ptr = (void *)get_line_ptr()) == NULL)
 56    {
 57       error("Pointer to display not assigned properly!", warning);
 58       return;
 59    }   
 60    if (in_macro == 0)
 61    {
 62       strcpy(macro_line,"no line");
 63       tw_sglobal_reset(disp_line_ptr);
 64       return;
 65    }
 66    if(freadline(fp, args) != EOF)
 67    {
 68       (void) sscanf(args, "%s", name);      
 69       strcpy(macro_line,args);
 70       tw_sglobal_reset(disp_line_ptr);
 71    }   
 72    else
 73    { 
 74       (void) fclose(fp); 
 75       fp = NULL; 
 76       in_macro = 0;
 77    } 
 78 }
 79 
 80 void execute_macro_line()
 81 {
 82    if (fp != NULL && strlen(name) != 0)
 83    { 
 84       replay = true;
 85       tw_run_cmnd(name, args);      
 86       replay = false;
 87    }
 88    else
 89    {
 90       format("macro file not found\n");
 91       return;
 92    } 
 93 }
 94 
 95 
 96 void init_macro_proc()
 97 {
 98     if(replay == false)
 99     {
100       tw_open_call_file( macro_file, "a");
101       tw_set_save(true);
102     }
103 }
104 
105 void save_macro_proc()
106 {
107    char temp[256];
108    tw_set_save(false);
109    tw_close_call_file();
110 }
111 
112 void set_replay_break()
113 {
114     replay_break = true;
115 }
116 
117 int process_macro_proc()
118 {
119    char temp[256];
120    if (replay_break == true)/* a get out for looped macros */
121    { 
122        replay_break = false;
123        return(0);
124    }
125    replay = true;
126    tw_read_call_file(macro_file);
127    replay =false;
128    return(1);
129 }
130 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.