File: funcs.c

package info (click to toggle)
oleo 1.6-16
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,640 kB
  • ctags: 3,139
  • sloc: ansic: 39,221; yacc: 1,737; sh: 362; makefile: 88
file content (123 lines) | stat: -rw-r--r-- 3,198 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*	Copyright (C) 1993 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this software; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */



/* 
 * This file contains descriptions of all the interactive functions 
 * built into oleo. 
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "global.h"
#include "cmd.h"
#include "key.h"
#include "io-term.h"
#include "basic.h"
#include "format.h"
#include "print.h"
#include "font.h"
#include "io-abstract.h"
#include "io-x11.h"
#include "io-edit.h"
#include "regions.h"
#include "help.h"
#include "window.h"
#include "font.h"
#include "graph.h"
#include "lists.h"


/* This include builds the function table, doc strings, and FUNC_ARGS strings.
 */
#include "defuns.h"


/* Returns 0 if the function is found.
 * Also returns (through parameters) the vector and cmd_func.
 * The output parameters can be NULL.
 */

int
find_function (int * vec_out, struct cmd_func ** cmd_out, char * name, int len)
{
  int vector;
  struct cmd_func * cmd;
  for (vector = 0; vector < num_funcs; vector++)
    for (cmd = &the_funcs[vector][0]; cmd->func_name; cmd++)
      if (!(strincmp (name, cmd->func_name, len) || cmd->func_name[len]))
	{
	  if (vec_out)
	    *vec_out = vector;
	  if (cmd_out)
	    *cmd_out = cmd;
	  return 0;
	}
  return 1;
}  




static struct cmd_func * named_macro_strings = 0;
static int num_named_macro_strings = 0;
static int named_macro_vec;

void
init_named_macro_strings (void)
{
  named_macro_strings =
    (struct cmd_func *) ck_malloc (sizeof (struct cmd_func));
  bzero (named_macro_strings, sizeof (struct cmd_func));
  named_macro_vec = add_usr_cmds (named_macro_strings);
}


void 
name_macro_string (char * name, char * str)
{
  int i = num_named_macro_strings;
  ++num_named_macro_strings;
  named_macro_strings =
    ((struct cmd_func *)
     ck_realloc (named_macro_strings,
		 ((1 + num_named_macro_strings) * sizeof (struct cmd_func))));
  the_funcs [named_macro_vec] = named_macro_strings;
  bzero (named_macro_strings + num_named_macro_strings,
	 sizeof (struct cmd_func));
  {
    struct cmd_func * cf = &named_macro_strings [i];
    cf->func_name = ck_savestr (name);
    cf->func_func = run_string_as_macro;
    cf->init_code = 0;
    {
      struct info_buffer * ib = find_or_make_info (name);
      clear_info (ib);
      print_info (ib, "Equivalent to %s.", str);
      cf->func_doc = ib->text;
    }
    {
      int i = 0;
      cf->func_args = (char **)ck_malloc (3 * sizeof (char *));
      cf->func_args [i++] = mk_sprintf ("=%s", str);
      cf->func_args [i++] = "p";
      cf->func_args [i++] = 0;
    }
  }
}