PIPS
emacs.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <strings.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/filio.h>
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/notify.h>
#include "string.h"
#include "genC.h"
#include "misc.h"
#include "linear.h"
#include "ri.h"
#include "database.h"
#include "ri-util.h"
#include "pipsdbm.h"
#include "properties.h"
#include "wpips-labels.h"
#include "wpips.h"
+ Include dependency graph for emacs.c:

Go to the source code of this file.

Enumerations

enum  epips_input_automaton_states { epips_wait_for_begin , epips_wait_for_end }
 At initialization, we are waiting for an input command: More...
 
enum  { EPIPS_COMMAND_BUFFER_SIZE = 2000 }
 

Functions

static void send_text_to_emacs (char *some_text)
 Here are described all the functions used to send informations to emacs: More...
 
static void send_command_to_emacs (char *command_title, char *command_content)
 The function that frames the command to emacs: More...
 
void send_module_name_to_emacs (char *some_text)
 Here are all the methods used to send an object to Emacs: More...
 
void send_the_names_of_the_available_modules_to_emacs (void)
 Tell Emacs about what are the modules available in the current workspace, if any: More...
 
void send_prompt_user_to_emacs (char *some_text)
 
void send_user_error_to_emacs (char *some_text)
 
void send_user_log_to_emacs (char *some_text)
 
void send_user_warning_to_emacs (char *some_text)
 
void send_view_to_emacs (char *view_name, char *the_file_name)
 
void send_window_number_to_emacs (int number)
 
void send_notice_prompt_to_emacs (char *first_line,...)
 
void ask_emacs_to_open_a_new_daVinci_context ()
 
void ask_emacs_to_display_a_graph (string file_name)
 
static bool epips_select_module (char *module_name)
 Here are described all the functions used to receive informations from emacs: More...
 
static void epips_execute_and_display_something (char *view_label, char *module_name)
 Emacs said to display a sequential view: More...
 
static void epips_sequential_view (char *module_name)
 Emacs said to display a sequential view: More...
 
static void epips_execute_command (char *command_buffer)
 
static void trow_away_epips_input (char *entry_buffer, long int length)
 
static void add_command_to_buffer (char *entry_buffer, unsigned long int length)
 Copy a part of the entry_buffer in the command_buffer: More...
 
static char * unframe_commands_from_emacs (char *entry_buffer, long int *length)
 Try to unframe one half of command sent by emacs. More...
 
static Notify_value read_commands_from_emacs (Notify_client client, int fd)
 The function that accept commands from emacs: More...
 
void initialize_emacs_mode ()
 The function to initialize some things in the emacs mode: More...
 

Variables

bool wpips_emacs_mode = 0
 Here are all the stuff to interface Pips with Emacs. More...
 
static char EMACS_AVAILABLE_MODULES_NAME [] = "AVAILABLE_MODULES"
 The title of the commands used by the emacs interface: More...
 
static char EMACS_MODULE_NAME [] = "MODULE_NAME"
 
static char EMACS_PROMPT_USER [] = "PROMPT_USER"
 
static char EMACS_SEQUENTIAL_VIEW [] = "Sequential View"
 
static char EMACS_USER_ERROR [] = "USER_ERROR"
 
static char EMACS_USER_LOG [] = "USER_LOG"
 
static char EMACS_USER_WARNING [] = "USER_WARNING"
 
static char EMACS_WINDOW_NUMBER [] = "WINDOW_NUMBER"
 
static char EMACS_NEW_DAVINCI_CONTEXT [] = "NEW_DAVINCI_CONTEXT"
 
static char EMACS_VIEW_DAVINCI_GRAPH [] = "VIEW_DAVINCI_GRAPH"
 
static char epips_begin_of_command_token [] = "\200"
 The token to mark the begin and end of command. More...
 
static char epips_end_of_command_token [] = "\201"
 
static char epips_receive_begin_of_command_token [] = "\202"
 
static char epips_receive_end_of_command_token [] = "\203"
 
static epips_input_automaton_states epips_input_automaton_state = epips_wait_for_begin
 
static char command_buffer [EPIPS_COMMAND_BUFFER_SIZE]
 
static unsigned int command_buffer_length
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
EPIPS_COMMAND_BUFFER_SIZE 

Definition at line 373 of file emacs.c.

373 { EPIPS_COMMAND_BUFFER_SIZE = 2000 };
@ EPIPS_COMMAND_BUFFER_SIZE
Definition: emacs.c:373

◆ epips_input_automaton_states

At initialization, we are waiting for an input command:

Enumerator
epips_wait_for_begin 
epips_wait_for_end 

Definition at line 88 of file emacs.c.

89 {
epips_input_automaton_states
At initialization, we are waiting for an input command:
Definition: emacs.c:89
@ epips_wait_for_begin
Definition: emacs.c:90
@ epips_wait_for_end
Definition: emacs.c:91

Function Documentation

◆ add_command_to_buffer()

static void add_command_to_buffer ( char *  entry_buffer,
unsigned long int  length 
)
static

Copy a part of the entry_buffer in the command_buffer:

Definition at line 380 of file emacs.c.

382 {
383  pips_assert("add_command_to_buffer in emacs.c: command too big !!!",
384  length + command_buffer_length < sizeof(command_buffer) - 1);
385  (void) memcpy(command_buffer + command_buffer_length,
386  entry_buffer,
387  length);
388  command_buffer_length += length;
390 }
static unsigned int command_buffer_length
Definition: emacs.c:375
static char command_buffer[EPIPS_COMMAND_BUFFER_SIZE]
Definition: emacs.c:374
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172

References command_buffer, command_buffer_length, and pips_assert.

Referenced by unframe_commands_from_emacs().

+ Here is the caller graph for this function:

◆ ask_emacs_to_display_a_graph()

void ask_emacs_to_display_a_graph ( string  file_name)

Definition at line 243 of file emacs.c.

244 {
246 }
static void send_command_to_emacs(char *command_title, char *command_content)
The function that frames the command to emacs:
Definition: emacs.c:114
static char EMACS_VIEW_DAVINCI_GRAPH[]
Definition: emacs.c:78
static string file_name

References EMACS_VIEW_DAVINCI_GRAPH, file_name, and send_command_to_emacs().

Referenced by wpips_display_graph_file_display().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ask_emacs_to_open_a_new_daVinci_context()

void ask_emacs_to_open_a_new_daVinci_context ( )

Definition at line 236 of file emacs.c.

237 {
239 }
static char EMACS_NEW_DAVINCI_CONTEXT[]
Definition: emacs.c:77

References EMACS_NEW_DAVINCI_CONTEXT, and send_command_to_emacs().

Referenced by wpips_display_graph_file_display().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ epips_execute_and_display_something()

static void epips_execute_and_display_something ( char *  view_label,
char *  module_name 
)
static

Emacs said to display a sequential view:

If module_name is not an empty string, we need to select this module first:

Display something only if an eventual module selection has been successful:

Definition at line 302 of file emacs.c.

303 {
304  bool module_selection_result = TRUE;
305 
306  if (module_name != '\0')
307  /* If module_name is not an empty string, we need to select this
308  module first: */
309  module_selection_result = epips_select_module(module_name);
310 
311  if (module_selection_result)
312  /* Display something only if an eventual module selection has
313  been successful: */
315 }
static bool epips_select_module(char *module_name)
Here are described all the functions used to receive informations from emacs:
Definition: emacs.c:255
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void wpips_execute_and_display_something_from_alias(char *alias_name)
To execute something and display some Pips output with wpips or epips by knowing its alias:
Definition: xv_edit2.c:493

References epips_select_module(), module_name(), and wpips_execute_and_display_something_from_alias().

Referenced by epips_sequential_view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ epips_execute_command()

static void epips_execute_command ( char *  command_buffer)
static

Separate the command name from the content with a ":" :

Now we can choose what command to execute:

Definition at line 327 of file emacs.c.

328 {
329  char * command_name, * command_content;
330 
331  /* Separate the command name from the content with a ":" : */
332  char * separator_index = (char *) index(command_buffer, ':');
333  debug(2, "epips_execute_command", "Command: \"%s\"\n", command_buffer);
334 
335  if (separator_index == NULL) {
336  user_warning("epips_execute_command",
337  "Cannot understand command: \"%s\"\n", command_buffer);
338  return;
339  }
340 
341  command_name = command_buffer;
342  *separator_index = '\0';
343  command_content = separator_index + 1;
344  debug(2, "epips_execute_command",
345  "command_name: \"%s\", command_content: \"%s\"\n",
346  command_name,
347  command_content);
348 
349  /* Now we can choose what command to execute: */
350  if (strcmp(command_name, EMACS_MODULE_NAME) == 0)
351  epips_select_module(command_content);
352  else if (strcmp(command_name, EMACS_SEQUENTIAL_VIEW) == 0)
353  epips_sequential_view(command_content);
354  else {
355  user_warning("epips_execute_command",
356  "Cannot understand command \"%s\" with argument \"%s\"\n",
357  command_name, command_content);
358  }
359 }
static char EMACS_MODULE_NAME[]
Definition: emacs.c:70
static void epips_sequential_view(char *module_name)
Emacs said to display a sequential view:
Definition: emacs.c:320
static char EMACS_SEQUENTIAL_VIEW[]
Definition: emacs.c:72
#define user_warning(fn,...)
Definition: misc-local.h:262
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189

References command_buffer, debug(), EMACS_MODULE_NAME, EMACS_SEQUENTIAL_VIEW, epips_select_module(), epips_sequential_view(), and user_warning.

Referenced by unframe_commands_from_emacs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ epips_select_module()

static bool epips_select_module ( char *  module_name)
static

Here are described all the functions used to receive informations from emacs:

Emacs said to select a module:

If there is no module...

Just to be sure that the selected module exist:

args_free zeroes also its length argument...

Something went wrong.

Definition at line 255 of file emacs.c.

256 {
257  gen_array_t modules;
258  int new_module_list_length;
259  int module_list_length = 0;
260  int i = 0;
261 
262  if (db_get_current_workspace_name() == NULL) {
263  user_warning("epips_select_module",
264  "No workspace selected or created yet !\n");
265  return FALSE;
266  }
267 
268  modules = db_get_module_list();
269  module_list_length = gen_array_nitems(modules);
270 
271  if (module_list_length == 0)
272  {
273  /* If there is no module... */
274  prompt_user("No module available in this workspace");
275  }
276  else {
277  /* Just to be sure that the selected module exist: */
278  for(i = 0; i < module_list_length; i++) {
279  if (strcmp(module_name, gen_array_item(modules, i)) == 0) {
281  break;
282  }
283  }
284  if (i == module_list_length)
285  user_warning("epips_select_module",
286  "The module \"%s\" does not exist.\n", module_name);
287  }
288  /* args_free zeroes also its length argument... */
289  new_module_list_length = module_list_length;
290  gen_array_full_free(modules);
291 
292  if (module_list_length == 0 || i == module_list_length)
293  /* Something went wrong. */
294  return FALSE;
295 
296  return TRUE;
297 }
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
void gen_array_full_free(gen_array_t a)
Definition: array.c:77
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
gen_array_t db_get_module_list(void)
Get an array of all the modules (functions, procedures and compilation units) of a workspace.
Definition: database.c:1266
void prompt_user(string a_printf_format,...)
Definition: gtk_log.c:66
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82
void end_select_module_notify(string name)
Definition: xv_select.c:882

References db_get_current_workspace_name(), db_get_module_list(), end_select_module_notify(), gen_array_full_free(), gen_array_item(), gen_array_nitems(), module_name(), prompt_user(), and user_warning.

Referenced by epips_execute_and_display_something(), and epips_execute_command().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ epips_sequential_view()

static void epips_sequential_view ( char *  module_name)
static

Emacs said to display a sequential view:

Definition at line 320 of file emacs.c.

321 {
323 }
static void epips_execute_and_display_something(char *view_label, char *module_name)
Emacs said to display a sequential view:
Definition: emacs.c:302

References EMACS_SEQUENTIAL_VIEW, epips_execute_and_display_something(), and module_name().

Referenced by epips_execute_command().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize_emacs_mode()

void initialize_emacs_mode ( )

The function to initialize some things in the emacs mode:

An arbitrary number to identify the notify client function:

The commands from emacs are read from stdin.

Thus, we need to register stdin in the XView event Notifier:

The user query is redirected to Emacs:

pips_request_handler = epips_user_request;

Initialize the epips.el epips-window-number variable:

Ask for Emacs prettyprinting:

Ask Pips to display the declarations from the RI to have hypertext functions on the declarations:

Since the comments of the declarations are not in the RI, pick them in the text:

Definition at line 511 of file emacs.c.

512 {
513  if (wpips_emacs_mode) {
514  /* An arbitrary number to identify the notify client function: */
515  Notify_client notifier_client = (Notify_client) 1234;
516 
517  /* The commands from emacs are read from stdin.
518 
519  Thus, we need to register stdin in the XView event Notifier: */
520  (void) notify_set_input_func(notifier_client,
522  fileno(stdin));
523 
524  /* The user query is redirected to Emacs: */
525  /* pips_request_handler = epips_user_request; */
526 
527  /* Initialize the epips.el epips-window-number variable: */
529 
530  /* Ask for Emacs prettyprinting: */
531  set_bool_property("PRETTYPRINT_ADD_EMACS_PROPERTIES", TRUE);
532  /* Ask Pips to display the declarations from the RI to have
533  hypertext functions on the declarations: */
534  set_bool_property("PRETTYPRINT_ALL_DECLARATIONS", TRUE);
535  /* Since the comments of the declarations are not in the RI,
536  pick them in the text: */
537  set_bool_property("PRETTYPRINT_HEADER_COMMENTS", TRUE);
538  }
539 }
bool wpips_emacs_mode
Here are all the stuff to interface Pips with Emacs.
Definition: emacs.c:65
void send_window_number_to_emacs(int number)
Definition: emacs.c:209
static Notify_value read_commands_from_emacs(Notify_client client, int fd)
The function that accept commands from emacs:
Definition: emacs.c:459
void set_bool_property(const char *, bool)
#define INITIAL_NUMBER_OF_WPIPS_WINDOWS
Definition: wpips-local.h:31

References INITIAL_NUMBER_OF_WPIPS_WINDOWS, read_commands_from_emacs(), send_window_number_to_emacs(), set_bool_property(), and wpips_emacs_mode.

Referenced by wpips_main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_commands_from_emacs()

static Notify_value read_commands_from_emacs ( Notify_client  client,
int  fd 
)
static

The function that accept commands from emacs:

Nasty thing. In act, if stdin happens to close (for example I debugged the stuff with wpips -emacs < a), the notifier loop on read_commands_from_emacs(). Thus, in this case, we disinterest the notifier from stdin:

We have something to read:

OK, we have read something...

Try to parse until the buffer is empty:

Do not try a blocking read:

Definition at line 459 of file emacs.c.

460 {
461  char emacs_entry_buffer[1000];
462  long int length;
463 
464  debug_on("EPIPS_DEBUG_LEVEL");
465 
466  if (ioctl(fd, FIONREAD, &length) == -1 || length == 0) {
467  /* Nasty thing. In act, if stdin happens to close (for example I
468  debugged the stuff with wpips -emacs < a), the notifier loop
469  on read_commands_from_emacs(). Thus, in this case, we
470  disinterest the notifier from stdin: */
471  debug(3, "read_commands_from_emacs",
472  "Detach the notifyer from stdin (length to read is %d)\n",
473  length);
474  (void) notify_set_input_func(client,
475  NOTIFY_FUNC_NULL,
476  fileno(stdin));
477  }
478  else {
479  /* We have something to read: */
480  long int read_length;
481  char * entry_buffer = emacs_entry_buffer;
482  do {
483  read_length = read(fd,
484  emacs_entry_buffer,
485  sizeof(emacs_entry_buffer) - 1);
486  if (read_length > 0) {
487  long int analyze_length = read_length;
488 
489  /* OK, we have read something... */
490  emacs_entry_buffer[length] = '\0';
491  debug(9, "read_commands_from_emacs", "Read got \"%s\"\n",
492  emacs_entry_buffer);
493  /* Try to parse until the buffer is empty: */
494  while(*(entry_buffer
495  = unframe_commands_from_emacs(entry_buffer, &analyze_length)) != '\0')
496  debug(8, "unframe_commands_from_emacs", "Return \"%s\"\n",
497  entry_buffer);
498 ;
499  }
500  /* Do not try a blocking read: */
501  } while (read_length > 0 && (length -= read_length) > 0);
502  }
503  debug_off();
504 
505  return NOTIFY_DONE;
506 }
static char * unframe_commands_from_emacs(char *entry_buffer, long int *length)
Try to unframe one half of command sent by emacs.
Definition: emacs.c:396
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160

References debug(), debug_off, debug_on, and unframe_commands_from_emacs().

Referenced by initialize_emacs_mode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_command_to_emacs()

static void send_command_to_emacs ( char *  command_title,
char *  command_content 
)
static

The function that frames the command to emacs:

Separate the command name from the content with a ":" :

Definition at line 114 of file emacs.c.

115 {
117  send_text_to_emacs(command_title);
118  /* Separate the command name from the content with a ":" : */
119  send_text_to_emacs(":");
120  send_text_to_emacs(command_content);
122 }
static char epips_begin_of_command_token[]
The token to mark the begin and end of command.
Definition: emacs.c:82
static char epips_end_of_command_token[]
Definition: emacs.c:83
static void send_text_to_emacs(char *some_text)
Here are described all the functions used to send informations to emacs:
Definition: emacs.c:105

References epips_begin_of_command_token, epips_end_of_command_token, and send_text_to_emacs().

Referenced by ask_emacs_to_display_a_graph(), ask_emacs_to_open_a_new_daVinci_context(), send_module_name_to_emacs(), send_prompt_user_to_emacs(), send_the_names_of_the_available_modules_to_emacs(), send_user_error_to_emacs(), send_user_log_to_emacs(), send_user_warning_to_emacs(), send_view_to_emacs(), and send_window_number_to_emacs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_module_name_to_emacs()

void send_module_name_to_emacs ( char *  some_text)

Here are all the methods used to send an object to Emacs:

Definition at line 128 of file emacs.c.

129 {
131 }

References EMACS_MODULE_NAME, and send_command_to_emacs().

Referenced by wpips_file_view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_notice_prompt_to_emacs()

void send_notice_prompt_to_emacs ( char *  first_line,
  ... 
)

Definition at line 220 of file emacs.c.

221 {
222  va_list ap;
223  char * prompt_string;
224 
225  va_start(ap, first_line);
226 
227  send_prompt_user_to_emacs(first_line);
228  while((prompt_string = va_arg(ap, char *)) != NULL)
229  send_prompt_user_to_emacs(prompt_string);
230 
231  va_end(ap);
232 }
void send_prompt_user_to_emacs(char *some_text)
Definition: emacs.c:164

References send_prompt_user_to_emacs().

Referenced by continue_create_workspace_notify(), end_delete_workspace_notify(), and quit_notify().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_prompt_user_to_emacs()

void send_prompt_user_to_emacs ( char *  some_text)

Definition at line 164 of file emacs.c.

165 {
167 }
static char EMACS_PROMPT_USER[]
Definition: emacs.c:71

References EMACS_PROMPT_USER, and send_command_to_emacs().

Referenced by prompt_user(), and send_notice_prompt_to_emacs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_text_to_emacs()

static void send_text_to_emacs ( char *  some_text)
static

Here are described all the functions used to send informations to emacs:

Just send some raw text to emacs:

Definition at line 105 of file emacs.c.

106 {
107  (void) printf("%s", some_text);
108  fflush(stdout);
109 }
int printf()

References printf().

Referenced by send_command_to_emacs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_the_names_of_the_available_modules_to_emacs()

void send_the_names_of_the_available_modules_to_emacs ( void  )

Tell Emacs about what are the modules available in the current workspace, if any:

Definition at line 137 of file emacs.c.

138 {
139  if (wpips_emacs_mode) {
140  char * module_string_list_string = strdup("(");
141 
142  if (db_get_current_workspace_name() != NULL) {
143  gen_array_t modules = db_get_module_list();
144  int module_list_length = gen_array_nitems(modules), i;
145  for(i = 0; i < module_list_length; i++) {
146  char * new_module_string_list_string =
147  strdup(concatenate(module_string_list_string,
148  "\"", gen_array_item(modules, i), "\" ",
149  NULL));
150  free(module_string_list_string);
151  module_string_list_string = new_module_string_list_string;
152  }
153  gen_array_full_free(modules);
154  }
156  concatenate(module_string_list_string,
157  ")", NULL));
158  free(module_string_list_string);
159  }
160 }
static char EMACS_AVAILABLE_MODULES_NAME[]
The title of the commands used by the emacs interface:
Definition: emacs.c:69
void free(void *)
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
char * strdup()

References concatenate(), db_get_current_workspace_name(), db_get_module_list(), EMACS_AVAILABLE_MODULES_NAME, free(), gen_array_full_free(), gen_array_item(), gen_array_nitems(), send_command_to_emacs(), strdup(), and wpips_emacs_mode.

Referenced by close_workspace_notify(), end_create_workspace_notify(), end_open_workspace_notify(), execute_safe_apply_outside_the_notifyer(), and execute_wpips_execute_and_display_something_outside_the_notifyer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_user_error_to_emacs()

void send_user_error_to_emacs ( char *  some_text)

Definition at line 171 of file emacs.c.

172 {
174 }
static char EMACS_USER_ERROR[]
Definition: emacs.c:73

References EMACS_USER_ERROR, and send_command_to_emacs().

Referenced by wpips_user_error_message().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_user_log_to_emacs()

void send_user_log_to_emacs ( char *  some_text)

Definition at line 178 of file emacs.c.

179 {
181 }
static char EMACS_USER_LOG[]
Definition: emacs.c:74

References EMACS_USER_LOG, and send_command_to_emacs().

Referenced by wpips_user_log().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_user_warning_to_emacs()

void send_user_warning_to_emacs ( char *  some_text)

Definition at line 185 of file emacs.c.

186 {
188 }
static char EMACS_USER_WARNING[]
Definition: emacs.c:75

References EMACS_USER_WARNING, and send_command_to_emacs().

Referenced by wpips_user_warning_message().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_view_to_emacs()

void send_view_to_emacs ( char *  view_name,
char *  the_file_name 
)

Send a complete file path since the current directory in Emacs is no the same a priori:

Definition at line 192 of file emacs.c.

193 {
194  unsigned int number_of_characters_written;
195  char full_path[1000];
196 
197  /* Send a complete file path since the current directory in Emacs
198  is no the same a priori: */
199  (void) sprintf(full_path, "%s/%s%n", get_cwd(), the_file_name,
200  &number_of_characters_written);
201  pips_assert("send_view_to_emacs",
202  number_of_characters_written < sizeof(full_path));
203 
204  send_command_to_emacs(view_name, full_path);
205 }
char * get_cwd(void)
returns the current working directory name.
Definition: file.c:486

References get_cwd(), pips_assert, and send_command_to_emacs().

Referenced by wpips_file_view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_window_number_to_emacs()

void send_window_number_to_emacs ( int  number)

Definition at line 209 of file emacs.c.

210 {
211  char a_string[10];
212 
213  (void) sprintf(a_string, "%d", number);
215 }
static char EMACS_WINDOW_NUMBER[]
Definition: emacs.c:76
#define a_string
Definition: genread_lex.c:843

References a_string, EMACS_WINDOW_NUMBER, and send_command_to_emacs().

Referenced by initialize_emacs_mode(), and window_number_notify().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trow_away_epips_input()

static void trow_away_epips_input ( char *  entry_buffer,
long int  length 
)
static

By default, send what we do not understand to stderr:

I can't remember how to give an argument to %...c ...

Definition at line 363 of file emacs.c.

364 {
365  if (length > 0) {
366  /* By default, send what we do not understand to stderr: */
367  /* I can't remember how to give an argument to %...c ...*/
368  (void) write(fileno(stderr), entry_buffer, length);
369  }
370 }

Referenced by unframe_commands_from_emacs().

+ Here is the caller graph for this function:

◆ unframe_commands_from_emacs()

static char* unframe_commands_from_emacs ( char *  entry_buffer,
long int length 
)
static

Try to unframe one half of command sent by emacs.

Thus needs an iterator outside.

Wait for a begin of command:

No begin of command:

Return an empty string:

Discard the begin of buffer:

Now we wait for an end of command:

Empty the command buffer:

Skip the begin token:

Look for an end of command:

No end of packet found yet. Add the content to the command buffer and keep waiting:

Go in the wait for begin state:

Skip the end token:

Definition at line 396 of file emacs.c.

397 {
399  /* Wait for a begin of command: */
400  char * epips_packet_begin_position =
401  (char*) index(entry_buffer,
403  debug(8, "unframe_commands_from_emacs",
404  "epips_packet_begin_position = %8X\n", epips_packet_begin_position);
405  if (epips_packet_begin_position == NULL) {
406  /* No begin of command: */
407  trow_away_epips_input(entry_buffer, *length);
408  /* Return an empty string: */
409  entry_buffer += *length;
410  *length = 0;
411  return entry_buffer;
412  }
413  else {
414  /* Discard the begin of buffer: */
415  trow_away_epips_input(entry_buffer,
416  epips_packet_begin_position - entry_buffer);
417  /* Now we wait for an end of command: */
419  /* Empty the command buffer: */
421  /* Skip the begin token: */
422  *length -= epips_packet_begin_position + 1 - entry_buffer;
423  return epips_packet_begin_position + 1;
424  }
425  }
426  else {
427  /* Look for an end of command: */
428  char * epips_packet_end_position =
429  (char*) index(entry_buffer,
431  debug(8, "unframe_commands_from_emacs",
432  "epips_packet_end_position = %8X\n", epips_packet_end_position);
433  if (epips_packet_end_position == NULL) {
434  /* No end of packet found yet. Add the content to the command
435  buffer and keep waiting: */
436  add_command_to_buffer(entry_buffer,
437  *length);
438  entry_buffer += *length;
439  *length = 0;
440  return entry_buffer;
441  }
442  else {
443  add_command_to_buffer(entry_buffer,
444  epips_packet_end_position - entry_buffer);
446  /* Go in the wait for begin state: */
448  /* Skip the end token: */
449  *length -= epips_packet_end_position + 1 - entry_buffer;
450  return epips_packet_end_position + 1;
451  }
452 
453  }
454 }
static void epips_execute_command(char *command_buffer)
Definition: emacs.c:327
static epips_input_automaton_states epips_input_automaton_state
Definition: emacs.c:95
static void trow_away_epips_input(char *entry_buffer, long int length)
Definition: emacs.c:363
static char epips_receive_begin_of_command_token[]
Definition: emacs.c:84
static void add_command_to_buffer(char *entry_buffer, unsigned long int length)
Copy a part of the entry_buffer in the command_buffer:
Definition: emacs.c:380
static char epips_receive_end_of_command_token[]
Definition: emacs.c:85

References add_command_to_buffer(), command_buffer, command_buffer_length, debug(), epips_execute_command(), epips_input_automaton_state, epips_receive_begin_of_command_token, epips_receive_end_of_command_token, epips_wait_for_begin, epips_wait_for_end, and trow_away_epips_input().

Referenced by read_commands_from_emacs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ command_buffer

char command_buffer[EPIPS_COMMAND_BUFFER_SIZE]
static

◆ command_buffer_length

unsigned int command_buffer_length
static

Definition at line 375 of file emacs.c.

Referenced by add_command_to_buffer(), and unframe_commands_from_emacs().

◆ EMACS_AVAILABLE_MODULES_NAME

char EMACS_AVAILABLE_MODULES_NAME[] = "AVAILABLE_MODULES"
static

The title of the commands used by the emacs interface:

Definition at line 69 of file emacs.c.

Referenced by send_the_names_of_the_available_modules_to_emacs().

◆ EMACS_MODULE_NAME

char EMACS_MODULE_NAME[] = "MODULE_NAME"
static

Definition at line 70 of file emacs.c.

Referenced by epips_execute_command(), and send_module_name_to_emacs().

◆ EMACS_NEW_DAVINCI_CONTEXT

char EMACS_NEW_DAVINCI_CONTEXT[] = "NEW_DAVINCI_CONTEXT"
static

Definition at line 77 of file emacs.c.

Referenced by ask_emacs_to_open_a_new_daVinci_context().

◆ EMACS_PROMPT_USER

char EMACS_PROMPT_USER[] = "PROMPT_USER"
static

Definition at line 71 of file emacs.c.

Referenced by send_prompt_user_to_emacs().

◆ EMACS_SEQUENTIAL_VIEW

char EMACS_SEQUENTIAL_VIEW[] = "Sequential View"
static

Definition at line 72 of file emacs.c.

Referenced by epips_execute_command(), and epips_sequential_view().

◆ EMACS_USER_ERROR

char EMACS_USER_ERROR[] = "USER_ERROR"
static

Definition at line 73 of file emacs.c.

Referenced by send_user_error_to_emacs().

◆ EMACS_USER_LOG

char EMACS_USER_LOG[] = "USER_LOG"
static

Definition at line 74 of file emacs.c.

Referenced by send_user_log_to_emacs().

◆ EMACS_USER_WARNING

char EMACS_USER_WARNING[] = "USER_WARNING"
static

Definition at line 75 of file emacs.c.

Referenced by send_user_warning_to_emacs().

◆ EMACS_VIEW_DAVINCI_GRAPH

char EMACS_VIEW_DAVINCI_GRAPH[] = "VIEW_DAVINCI_GRAPH"
static

Definition at line 78 of file emacs.c.

Referenced by ask_emacs_to_display_a_graph().

◆ EMACS_WINDOW_NUMBER

char EMACS_WINDOW_NUMBER[] = "WINDOW_NUMBER"
static

Definition at line 76 of file emacs.c.

Referenced by send_window_number_to_emacs().

◆ epips_begin_of_command_token

char epips_begin_of_command_token[] = "\200"
static

The token to mark the begin and end of command.

Use some strings to be usually never used in ISO-8859-1:

Definition at line 82 of file emacs.c.

Referenced by send_command_to_emacs().

◆ epips_end_of_command_token

char epips_end_of_command_token[] = "\201"
static

Definition at line 83 of file emacs.c.

Referenced by send_command_to_emacs().

◆ epips_input_automaton_state

epips_input_automaton_states epips_input_automaton_state = epips_wait_for_begin
static

Definition at line 95 of file emacs.c.

Referenced by unframe_commands_from_emacs().

◆ epips_receive_begin_of_command_token

char epips_receive_begin_of_command_token[] = "\202"
static

Definition at line 84 of file emacs.c.

Referenced by unframe_commands_from_emacs().

◆ epips_receive_end_of_command_token

char epips_receive_end_of_command_token[] = "\203"
static

Definition at line 85 of file emacs.c.

Referenced by unframe_commands_from_emacs().

◆ wpips_emacs_mode

bool wpips_emacs_mode = 0

Here are all the stuff to interface Pips with Emacs.

This variable is used to indicate wether wpips is in the Emacs mode:

Ronan.nosp@m..Ker.nosp@m.yell@.nosp@m.cri..nosp@m.ensmp.nosp@m..fr, 23/05/1995. Include the label names: This variable is used to indicate wether wpips is in the Emacs mode: By default, wpips is not called from emacs. RK.

Definition at line 65 of file emacs.c.

Referenced by continue_create_workspace_notify(), create_edit_menu(), create_log_menu(), edit_close_notify(), edit_notify(), end_delete_workspace_notify(), initialize_emacs_mode(), notify_hpfc_file_view(), prompt_user(), quit_notify(), send_the_names_of_the_available_modules_to_emacs(), window_number_notify(), wpips_display_graph_file_display(), wpips_file_view(), wpips_main(), wpips_parse_arguments(), wpips_user_error_message(), wpips_user_log(), wpips_user_warning_message(), and wpips_view_marked_busy().