📄 xesps.c
字号:
/* Copyright (c) 1995 Entropic Research Laboratory, Inc. *//* * This material contains unpublished, proprietary software of * Entropic Research Laboratory, Inc. Any reproduction, distribution, * or publication of this work must be authorized in writing by Entropic * Research Laboratory, Inc., and must bear the notice: * * "Copyright (c) 1986-1990 Entropic Speech, Inc. * "Copyright (c) 1990-1993 Entropic Research Laboratory, Inc. * All rights reserved" * * The copyright notice above does not evidence any actual or intended * publication of this source code. * * Written by: John Shore * Checked by: * Revised by: Alan Parker, David Talkin * * Brief description: * */static char *sccs_id = "@(#)xesps.c 1.16 9/28/98 ATT/ERL";#ifdef hpux#define _BSD#endif#ifdef DEC_ALPHA#include <sys/types.h>#endif#include <sys/wait.h>#include <Objects.h>#ifndef hpux#include <sys/param.h>#else#define MAXPATHLEN 1024#endif#include <xview/scrollbar.h>#include <esps/esps.h>#include <esps/unix.h>#include <esps/fea.h>#include <sys/time.h>#ifndef DS3100#include <sys/resource.h>#endif#include <esps/exview.h>#if defined(SUN4) && !defined(OS5)#include <vfork.h>#endif#define SINGLE_HIT if(((event_id(event) == LOC_MOVE)||event_is_down(event)) && (event_id(event) != LOC_DRAG))/*#define SINGLE_HIT if(event_is_down(event) && (event_id(event) != LOC_DRAG)) */extern char *checking_selectors();#define CHECK_QUERY(a,b) { char *cret; if((cret = checking_selectors(a,b))) return(cret); }void setup_output_dir();char *mk_esps_temp();char *savestring();char *inc_esps_name();void markers_to_common();void menu_change();void call_operator();char *basename2();extern int debug_level; /* THE FOLLOWING GLOBALS MAY BE SET FROM <a profile file> */extern char temp_path[], remote_path[], remote_input_path[], remote_output_path[];extern int w_verbose;#define NAME_TAB 150struct fname { char *name; char num; struct fname *next;};struct fname *names[NAME_TAB];/*********************************************************************//* Called when the add_espst command is issued to waves (via command file or panel entry). This sets up the ESPS command components and adds the command name to the view-window menus. */extern char ok[], null[]; /* in message.c */static char espst_name[50];static char espst_command[MES_BUF_SIZE];static char espst_menu[50];Selector et3 = {"menu", "%s", espst_menu, NULL}, et2b = {"command", "#strq", espst_command, &et3}, et2 = {"op", "#strq", espst_command, &et2b}, et1 = {"name", "#strq", espst_name, &et2};char *meth_add_espst(ob, str) Object *ob; char *str;{ extern void call_operator(); char command_line[MES_BUF_SIZE]; *espst_name = '\0'; *espst_command = '\0'; *espst_menu = '\0'; CHECK_QUERY(str, &et1) (void) get_args(str, &et1); if(debug_level) fprintf(stderr,"meth_add_espst: name = %s, command = %s, menu = %s\n", espst_name, espst_command, espst_menu); sprintf(command_line, "xtext %s _range_samp _file", espst_command); menu_change(espst_name, espst_name, new_menuop(espst_menu, espst_name, call_operator, (caddr_t) savestring(command_line)), espst_menu); return(ok);}/*********************************************************************//* Called when the add_espsf command is issued to waves (via command file or panel entry). This sets up the ESPS command components and adds the command name to the view-window menus. */typedef struct { int num_outputs; int display; char *out_ext; char *command;} espsfInfo;static int espsf_num_outputs;static int espsf_display;static char espsf_out_ext[50];static char new_command[10 * MES_BUF_SIZE];static char espsf_name[50];static char espsf_menu[50];Selector ef6 = {"menu", "%s", espsf_menu, NULL}, ef2b = {"command", "#strq", new_command, &ef6}, ef2 = {"op", "#strq", new_command, &ef2b}, ef1 = {"name", "#qstr", espsf_name, &ef2}, ef5 = {"outputs", "%d", (char *) &espsf_num_outputs, &ef1}, ef4 = {"display", "%d", (char *) &espsf_display, &ef5}, ef3 = {"out_ext", "%s", espsf_out_ext, &ef4};/*********************************************************************/char *meth_add_espsf(ob, str) Object *ob; char *str;{ espsfInfo *espsf_info; char command[5000]; int i; *espsf_menu = '\0'; espsf_num_outputs = 1; espsf_display = 1; strcpy(espsf_out_ext, "out"); *new_command = '\0'; *espsf_name = '\0'; CHECK_QUERY(str, &ef3) (void) get_args(str, &ef3); if (debug_level) { fprintf(stderr,"meth_add_espsf:\n"); fprintf(stderr,"name = %s, out_ext = %s, command = %s, display = %d\n", espsf_name, espsf_out_ext, new_command, espsf_display); fprintf(stderr,"outputs = %d, menu = %s\n", espsf_num_outputs, espsf_menu); } sprintf(command, "%s _range_samp _file", new_command); for (i = 0; i < espsf_num_outputs; i++) if(espsf_display) sprintf(command+strlen(command)," _out.g.%s ", espsf_out_ext); else sprintf(command+strlen(command)," _out.n.%s ", espsf_out_ext); menu_change(espsf_name, espsf_name, new_menuop(espsf_menu, espsf_name, call_operator, (caddr_t)savestring(command)), espsf_menu); return(ok);}static char espsn_name[50];static char espsn_command[MES_BUF_SIZE];static char espsn_menu[50];Selector e3 = {"menu", "%s", espsn_menu, NULL}, e2b = {"command", "#strq", espsn_command, &e3}, e2 = {"op", "#strq", espsn_command, &e2b}, e1 = {"name", "#qstr", espsn_name, &e2};/*********************************************************************//* Called when the add_espsn command is issued to waves (via command file or panel entry). This sets up the ESPS command components and adds the command name to the view-window menus. */char *meth_add_espsn(ob, str) Object *ob; char *str;{ char command[MES_BUF_SIZE]; *espsn_name = '\0'; *espsn_command = '\0'; *espsn_menu = '\0'; CHECK_QUERY(str, &e1) (void) get_args(str, &e1); if (debug_level) { fprintf(stderr,"meth_add_espsn:\n"); fprintf(stderr,"name = %s, command = %s\n", espsn_name, espsn_command); } sprintf(command, "%s _range_samp _file", espsn_command); menu_change(espsn_name, espsn_name, new_menuop(espsn_menu, espsn_name, call_operator, (caddr_t) savestring(command)), espsn_menu); return(ok);}/*********************************************************************/char *meth_add_operator(ob, str) Object *ob; char *str;{ *espsf_menu = '\0'; *new_command = '\0'; *espsf_name = '\0'; CHECK_QUERY(str, &ef1) if(get_args(str, &ef1) && *new_command && *espsf_name) { if (debug_level) { fprintf(stderr,"meth_add_operator:\n"); fprintf(stderr,"name = %s, command = %s\n", espsf_name, new_command); fprintf(stderr,"menu = %s\n", espsf_menu); } menu_change(espsf_name, espsf_name, new_menuop(espsf_menu, espsf_name, call_operator, (caddr_t) savestring(new_command)), espsf_menu); return(ok); } else { sprintf(notice_msg, "Bad args to meth_add_operator(%s)\n",(str)? str : "<null>"); show_notice(1,notice_msg); } return(null);}/***********************************************************************/is_an_add_op(mo) Menuop *mo;{ if(mo && mo->name && mo->name[0] && (mo->proc == call_operator)) { char *p = (char*)mo->data; return(p && *p); } else return(FALSE);}/***********************************************************************/is_an_add_waves(mo) Menuop *mo;{ extern void e_exec_waves(); if(mo && mo->name && mo->name[0] && (mo->proc == e_exec_waves)) { char *p = (char*)mo->data; return(p && *p); } else return(FALSE);}/***********************************************************************/dump_add_ops(file) char *file;{ if(file && *file) { char scrat[NAMELEN]; FILE *of; /* expand any environment variables */ (void) build_filename(scrat, "", file); if((of = fopen(scrat, "w"))) { Menuop *mo; Moplist *menu_get_op_lists(), *mol = menu_get_op_lists(); while(mol) { mo = mol->first_op; while(mo) { if(is_an_add_op(mo)) fprintf(of,"add_op name \"%s\" menu %s op %s\n", mo->name, mol->name, mo->data); else if(is_an_add_waves(mo)) fprintf(of,"add_waves name \"%s\" menu %s op %s\n", mo->name, mol->name, mo->data); mo = mo->next; } mol = mol->next; } fprintf(of,"return\n"); fclose(of); return(TRUE); } else { sprintf(notice_msg,"Can't open %s for output in dump_add_ops.",scrat); show_notice(1,notice_msg); } } return(FALSE);}/***********************************************************************/char *meth_dump_add_ops(o, str) Object *o; char *str;{ static char file[NAMELEN]; static Selector s = {"output", "%s", file, NULL}; extern char ok[], null[]; CHECK_QUERY(str,&s) if(get_args(str,&s)) { if(dump_add_ops(file)) return(ok); else { sprintf(notice_msg,"Problems dumping add_ops to file %s"); show_notice(1,notice_msg); } } else show_notice(1,"No output file was specified to meth_dump_add_ops"); return(null);}/***********************************************************************/#define PID_TABSIZE 100static struct { char **out_files; char **text_files; char *command; int (*func)(); int pid; char oname[NAMELEN]; void *ipc_client_info; caddr_t client_data; } pid_table[PID_TABSIZE];static int pid_not_initialized = 1;/***********************************************************************/static void pid_reset_entry(i) int i;{ pid_table[i].pid = -1; pid_table[i].out_files = NULL; /* should be called "graphic_files" */ pid_table[i].text_files = NULL; pid_table[i].command = NULL; pid_table[i].func = NULL; pid_table[i].client_data = NULL; pid_table[i].ipc_client_info = NULL; pid_table[i].oname[0] = 0;}/***********************************************************************/static int init_pid_table(){ int i; /* If first time in, initialize the pid table entries to -1. */ if (pid_not_initialized) { for (i = 0; i < PID_TABSIZE; i++) pid_reset_entry(i); pid_not_initialized = 0; return(0); } else { /* Be sure that there is a free entry. */ for (i = 0; i < PID_TABSIZE; i++) if (pid_table[i].pid == -1) { pid_reset_entry(i); return(i); } return (-1); /* no free pid slots */ }}/***********************************************************************/static void pid_clear_out_files(i) int i;{ char **cp; if(( cp = pid_table[i].out_files)) { while (*cp) free(*cp++); free(pid_table[i].out_files); pid_table[i].out_files = NULL; } if(( cp = pid_table[i].text_files)) { while (*cp) free(*cp++); free(pid_table[i].text_files); pid_table[i].text_files = NULL; } if(pid_table[i].command) free(pid_table[i].command); pid_table[i].command = NULL;}/***********************************************************************/static int pid_get_table_index(pid) int pid;{ int i; for(i=0; i < PID_TABSIZE; i++) if(pid == pid_table[i].pid) return(i); if(w_verbose) fprintf(stderr,"Couldn't find table entry for pid %d\n",pid); return(-1);}/***********************************************************************/void reset_esps_callback(pid, newcallback) int pid; int (*newcallback)(); /* if !NULL, then call this function whe n done */{ int i = pid_get_table_index(pid); if(i >= 0) pid_table[i].func = newcallback;}/***********************************************************************/void set_esps_callback_data(pid, data) int pid; caddr_t data;{ int i = pid_get_table_index(pid); if(i >= 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -