File: mkfunmainlib

package info (click to toggle)
funtools 1.4.4+dfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 16,168 kB
  • ctags: 10,760
  • sloc: ansic: 87,238; sh: 9,727; lex: 4,595; asm: 3,281; ada: 1,681; makefile: 1,458; pascal: 1,089; cpp: 1,001; cs: 879; perl: 161; yacc: 64; sed: 32; csh: 10; tcl: 9
file content (68 lines) | stat: -rwxr-xr-x 1,817 bytes parent folder | download | duplicates (6)
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
#!/bin/sh

if [ x"$1" = x"-tcl" ]; then
  DOTCL=1
else
  DOTCL=0
fi

awk '
BEGIN{
  dotcl='$DOTCL'
  if( dotcl == 0 ){
    printf("#include <mainlib.h>\n\n")
  }
  else{
    printf("#include <tclmainlib.h>\n\n")
  }
  printf("\n");
  j = 0
}
{
  for(i=1; i<=NF; i++){
    name[j] = $i
    printf("int %s_main _PRx((int argc, char **argv));\n", $i)
    j++
  }
}
END{
  if( dotcl == 0 ){
    printf("\n")
    printf("void *funtoolsMainLibInit(void)\n")
    printf("{\n")
    printf("  MainLib ml;\n")
    printf("  if( !(ml=MainLibNew()) )\n");
    printf("     return NULL;\n");
    for(i=0; i<j; i++){
      printf("  if( !MainLibAdd(ml, \"funtools\", \"%s\", %s_main, MAINLIB_ARGV) )\n", name[i], name[i])
      printf("     return NULL;\n");
    }
    printf("  return ml;\n");
    printf("}\n")
    printf("\n")
  }
  else{
    printf("\n")
    printf("#include <tcl.h>\n")
    printf("\n")
    printf("int Tclfun_Init (void *vinterp)\n")
    printf("{\n")
    printf("  Tcl_Interp *interp = (Tcl_Interp *)vinterp;\n")
    printf("\n")
    for(i=0; i<j; i++){
      printf("  Tcl_CreateObjCommand(interp, \"%s\", MainLibProcess_Tcl,\n", name[i])
      printf("    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);\n")
    }
    printf("  Tcl_CreateObjCommand(interp, \"mainlib\", MainLibProcess_Tcl,\n")
    printf("    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);\n")
    printf("  Tcl_CreateObjCommand(interp, \"mainlibcleanup\", MainLibProcessCleanup_Tcl,\n")
    printf("    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);\n")
    printf("  Tcl_CreateObjCommand(interp, \"mainlibload\", MainLibLoad_Tcl,\n")
    printf("    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);\n")
    printf("  Tcl_PkgProvide(interp, \"tclfun\", \"1.0\");\n")
    printf("  return(TCL_OK);\n")
    printf("}\n")
    printf("\n")
  }
}
'