File: testmod.c

package info (click to toggle)
grass 6.0.0-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 38,764 kB
  • ctags: 31,167
  • sloc: ansic: 320,650; tcl: 25,669; cpp: 10,098; sh: 9,695; makefile: 4,714; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (49 lines) | stat: -rw-r--r-- 1,110 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
#include <stdio.h>
#include <string.h>
#include "../list.h"
#include "../mapcalc.h"
#include "../map.h"


/*
 * Required function:
 * Return the name of the main function which is useable in v.mapcalc.
 */
char *
fname (void)
{
  return "dltest";
}

/*
 * Required function:
 * Return the prototype of the main function. Generally, it's the initial
 * letter of the C-type, plus "m" for (MAP *) and "p" for (POINT *).
 * Indirection doesn't fully work, but to return a pointer to one of the
 * above types, the letter "a" is used ("ai" means an integer pointer).
 *
 * Each prototype needs to be represented by one of the typedef and switch
 * cases in func.c of mapcalc.
 */
char *
proto (void)
{
  return "m=mm";
}

/*
 * This is the main function which needs to have the name and prototype
 * as returned above.
 */
MAP *
dltest (MAP *m, MAP *n)
{
  char namebuf[128];

  printf ("Performing 2 arg dynamically loaded map function on maps "
	  "%s and %s\n", m->name, n->name);
  sprintf (namebuf, "%s.%s", m->name, n->name);
  m = (MAP *)listitem (sizeof (MAP));
  m->name = strdup (namebuf);
  return m;
}