Back to index

texmacs  1.0.7.15
Defines | Functions | Variables
tm_maple_9.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <time.h>
#include "maplec.h"

Go to the source code of this file.

Defines

#define DATA_BEGIN   ((char) 2)
#define DATA_END   ((char) 5)
#define DATA_ESCAPE   ((char) 27)
#define CDECL

Functions

void next_input ()
void CDECL catch_intr (int signo)
static M_BOOL M_DECL queryInterrupt (void *data)
static M_BOOL M_DECL writeHelpChar (void *data, int c)
static void M_DECL textCallBack (void *data, int tag, char *output)
static void M_DECL errorCallBack (void *data, M_INT offset, char *msg)
int main (int argc, char *argv[])

Variables

static int counter = 0
static char in [2148]
static char err [2048]
static int Interrupted = 0

Define Documentation

#define CDECL

Definition at line 50 of file tm_maple_9.c.

#define DATA_BEGIN   ((char) 2)

Definition at line 19 of file tm_maple_9.c.

#define DATA_END   ((char) 5)

Definition at line 20 of file tm_maple_9.c.

#define DATA_ESCAPE   ((char) 27)

Definition at line 21 of file tm_maple_9.c.


Function Documentation

void CDECL catch_intr ( int  signo)

Definition at line 57 of file tm_maple_9.c.

{
  Interrupted = TRUE;
  signal(SIGINT,catch_intr);
#ifdef _MSC_VER
  signal(SIGBREAK,catch_intr);
#endif
}

Here is the caller graph for this function:

static void M_DECL errorCallBack ( void *  data,
M_INT  offset,
char *  msg 
) [static]

Definition at line 90 of file tm_maple_9.c.

{
  M_INT i;
  /* TODO: too wide (>= 80 characters) user input */

  if (offset < 0)
    fprintf (stderr, "%s\n", msg);
  else {
    /* put ^^^ under the original input to indicate where 
       the syntax error probably was
    */
    fprintf (stderr, "Syntax Error, %s\n> %s\n", msg, in);
    for (i=0; i<offset; ++i)
      fputc (' ', stderr);
    fprintf (stderr, "^\n");
  }
}

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 113 of file tm_maple_9.c.

                              {
  MKernelVector kv;  /* Maple kernel handle */
  MCallBackVectorDesc cb = {  textCallBack, 
                           errorCallBack,
                           0,   /* statusCallBack not used */
                           0,   /* readLineCallBack not used */
                           0,   /* redirectCallBack not used */
                           0,   /* streamCallBack not used */
                           queryInterrupt, 
                           0    /* callBackCallBack not used */
                           };
  ALGEB r, l;  /* Maple data-structures */

  signal(SIGINT,catch_intr);
  printf("\2verbatim:");
  printf("    |\\^/|     Maple\n");
  printf("._|\\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2004\n");
  printf(" \\OPENMAPLE/  All rights reserved. Maple and OpenMaple are trademarks of\n");
  printf(" <____ ____>  Waterloo Maple Inc.\n");
  printf("      |       Type ? for help.\n");
  printf("\nTeXmacs interface by Joris van der Hoeven\n");
  
  /* initialize Maple */
  if( (kv=StartMaple(argc,argv,&cb,NULL,NULL,err)) == NULL ) {
    printf("Fatal error, %s\n",err);
    return( 1 );
  }

  r= EvalMapleStatement (kv, "tmmaple:=9:");
  char* tm_path= getenv ("TEXMACS_PATH");
  char init[1000];
  strcpy (init, "read (`");
  strcat (init, tm_path);
  strcat (init, "/plugins/maple/maple/init-maple.mpl`);");
  r= EvalMapleStatement (kv, init);

  while (1) {
    next_input ();
    printf("\5");
    fflush (stdout);
    int i= 0;
    for (i=0; i<2047; i++) {
      char c= getchar ();
      if (c == '\n') break;
      in[i]= c;
    }
    in[i]= '\0';
    while (in[strlen(in)-1] == ';') in[strlen(in)-1]= '\0';
    if (strncmp (in, "quit", 4) == 0) break;
    printf("%c%s", DATA_BEGIN, "verbatim:");
    if (in[0] == '?')
      MapleHelp (kv, in+1, NULL, writeHelpChar, NULL, 80, NULL);
    else {
      if (in[strlen(in)-1] != ':')
       strcat (in, ":tmresult:=\%:tmprint(tmresult):tmresult:");
      r = EvalMapleStatement (kv, in);
    }
  }

  StopMaple(kv);

  return (0);
}

Here is the call graph for this function:

void next_input ( )

Definition at line 35 of file tm_maple_9.c.

              {
  counter++;
  printf ("\2channel:prompt\5");
  printf ("\2scheme:(with \"color\" \"brown\" \"");
  printf ("%s%i%s", "Maple ", counter, "] ");
  printf ("\")\5");
}
static M_BOOL M_DECL queryInterrupt ( void *  data) [static]

Definition at line 67 of file tm_maple_9.c.

{
  if (Interrupted) {
    Interrupted = 0;
    return (TRUE);
  }
  return (FALSE);
}

Here is the caller graph for this function:

static void M_DECL textCallBack ( void *  data,
int  tag,
char *  output 
) [static]

Definition at line 84 of file tm_maple_9.c.

{
  if (tag != MAPLE_TEXT_STATUS)
    printf ("%s\n", output);
}

Here is the caller graph for this function:

static M_BOOL M_DECL writeHelpChar ( void *  data,
int  c 
) [static]

Definition at line 77 of file tm_maple_9.c.

{
    putchar (c);
    return (FALSE);
}

Here is the caller graph for this function:


Variable Documentation

int counter = 0 [static]

Definition at line 26 of file tm_maple_9.c.

char err[2048] [static]

Definition at line 28 of file tm_maple_9.c.

char in[2148] [static]

Definition at line 27 of file tm_maple_9.c.

int Interrupted = 0 [static]

Definition at line 54 of file tm_maple_9.c.