File: help.c

package info (click to toggle)
cufflinks 1.3.0-2
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 3,864 kB
  • sloc: cpp: 48,999; ansic: 12,297; sh: 3,381; python: 432; makefile: 209
file content (88 lines) | stat: -rw-r--r-- 1,892 bytes parent folder | download | duplicates (5)
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
/*
 *   Copyright (c) 1996-2000 Lucent Technologies.
 *   See README file for details.
 *
 *
 *
 *   The example() function is used to tnterpreting examples
 *   in the locfit.ceg file.
 */

#include "local.h"

#ifdef CVERSION

static FILE *help;
extern char *lfhome;

void example(v)
vari *v;
{ int i, j, run, ti;
  char *z, elin[10], helpfile[100], line[200];

  run = 0;
  i = getarg(v,"ex",1);
  ti = (i==0);
  if (!ti)
  { z = strchr(argval(v,i),'.');
    if (z==NULL)
    { ERROR(("example: invalid number %s",argval(v,i)));
      return;
    }
    j = getarg(v,"run",1);
    if (j>0) run = getlogic(v,j);
  }

  if (lfhome!=NULL)
    sprintf(helpfile,"%s/locfit.ceg",lfhome);
  else
    sprintf(helpfile,"locfit.ceg");

  help = fopen(helpfile,"r");
  if (help==NULL)
  { ERROR(("Can't find locfit.ceg file -- is LFHOME set?"));
    return;
  }

  do
  { z = fgets(line,190,help);
    if (z==NULL) /* reached end of file */
    { if (!ti) ERROR(("No example %s in help file",argval(v,i)));
      fclose(help);
      return;
    }
    if (line[0]=='e')
    { sscanf(&line[2],"%s",elin);
      if (ti) printf("Example %s. ",elin);
    }
    else elin[0] = 0;
    if ((ti) && (line[0]=='t'))
      printf("%s",&line[2]);
  }  while ((ti) || (strcmp(elin,argval(v,i))!=0));

  while(1)
  { z = fgets(line,190,help);
    switch(z[0])
    { case 'f': /* end example */
        fclose(help);
        printf("\n");
        return;
      case 't': /* title */
        printf("\nExample %s. %s\n",argval(v,i),&line[2]);
        break;
      case 'c': /* code */
        printf("  %s",&line[2]);
      case 'h': /* hidden code, usually sleep */
        if (run) makecmd(&line[2]);
        break;
      case 'd': /* discussion */
        printf("%s",&line[2]);
        break;
      case 'n': /* no code */
        printf("There is no code for this example.\n");
        break;
    }
  }
}

#endif