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

Linux Cross Reference
Tina6/tina-tools/tinatool/tlbase/tlbaseMcr_funcs.c

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

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/tlbase/tlbaseMcr_funcs.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: tlbaseMcr_funcs.c,v 1.3 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : Simple display tv_screen (ie a tv_screen in a window).
 44  *
 45  *********
 46 */
 47 
 48 #include "tlbaseMcr_funcs.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #   include <config.h>
 52 #endif
 53 
 54 #include <string.h>
 55 
 56 #include <fcntl.h>
 57 #include <sys/file.h>
 58 #include <tina/sys/sysDef.h>
 59 #include <tina/sys/sysPro.h>
 60 #include <tinatool/wdgts/wdgtsPro.h>
 61 #include <tinatool/tlbase/tlbaseMcr_tool.h>
 62 
 63 
 64 #define LINESIZE 128
 65 
 66 static Bool replay_break = false;
 67 static Bool replay = false;
 68 static char  macro_file[128] = "default";
 69 static char  macro_line[LINESIZE] = "no_line";
 70 static FILE   *fp = NULL;
 71 static char    name[LINESIZE], args[256];
 72 static int in_macro = 0;
 73 
 74 char *get_macro_line()
 75 {
 76    return(macro_line);
 77 }
 78 
 79 char *get_macro_file()
 80 {
 81     return(macro_file);
 82 }
 83 
 84 void start_macro_line()
 85 {
 86    char   callback_file[64];
 87 
 88    if (in_macro == 1)
 89    {
 90       (void) fclose(fp);
 91       fp = NULL;
 92       in_macro = 0;
 93    }
 94 
 95    if( in_macro == 0)
 96    {
 97       (void) string_append(callback_file, macro_file, ".cls", NULL);
 98       fp = fopen(callback_file, "r");
 99       if (fp == NULL)
100       {  
101           format("macro file not found\n");
102           return;
103       }  
104       in_macro = 1;
105    }
106 }
107 
108 void next_macro_line()
109 {
110    char    sline[LINESIZE];
111    void *disp_line_ptr = NULL;
112 
113 
114    if((disp_line_ptr = (void *)get_line_ptr()) == NULL)
115    {
116       error("Pointer to display not assigned properly!", warning);
117       return;
118    }   
119    if (in_macro == 0)
120    {
121       strcpy(macro_line,"no line");
122       tw_sglobal_reset(disp_line_ptr);
123       return;
124    }
125    if(freadline(fp, args) != EOF)
126    {
127       (void) sscanf(args, "%s", name);      
128       strcpy(macro_line,args);
129       tw_sglobal_reset(disp_line_ptr);
130    }   
131    else
132    { 
133       (void) fclose(fp); 
134       fp = NULL; 
135       in_macro = 0;
136    } 
137 }
138 
139 void execute_macro_line()
140 {
141    if (fp != NULL && strlen(name) != 0)
142    { 
143       replay = true;
144       tw_run_cmnd(name, args);      
145       replay = false;
146    }
147    else
148    {
149       format("macro file not found\n");
150       return;
151    } 
152 }
153 
154 
155 void init_macro_proc()
156 {
157     if(replay == false)
158     {
159       tw_open_call_file(macro_file, "a");
160       tw_set_save(true);
161     }
162 }
163 
164 void save_macro_proc()
165 {
166    char temp[256];
167    tw_set_save(false);
168    tw_close_call_file();
169 }
170 
171 void set_replay_break()
172 {
173     replay_break = true;
174 }
175 
176 int process_macro_proc()
177 {
178    char temp[256];
179    if (replay_break == true)/* a get out for looped macros */
180    { 
181        replay_break = false;
182        return(0);
183    }
184    replay = true;
185    tw_read_call_file(macro_file);
186    replay =false;
187    return(1);
188 }
189 

~ [ 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.