PIPS
help.c File Reference
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "genC.h"
#include "constants.h"
#include "misc.h"
#include "top-level.h"
+ Include dependency graph for help.c:

Go to the source code of this file.

Macros

#define BEGIN_STR   "BEGIN"
 
#define END_STR   "END"
 

Functions

void get_help_topics (gen_array_t array)
 help.c More...
 
void get_help_topic (string topic, gen_array_t array)
 
void pips_checks (void)
 add checkings here (FI: why in help.c?) SG : PIPS_ROOT should not be required :) More...
 

Macro Definition Documentation

◆ BEGIN_STR

#define BEGIN_STR   "BEGIN"

Definition at line 39 of file help.c.

◆ END_STR

#define END_STR   "END"

Definition at line 40 of file help.c.

Function Documentation

◆ get_help_topic()

void get_help_topic ( string  topic,
gen_array_t  array 
)
Parameters
topicopic
arrayrray

Definition at line 64 of file help.c.

65 {
66  FILE *fd;
67  int selected = false, index=0;
68  int begin_length, end_length;
69 
70  char *line;
71 
72 
73  begin_length = strlen(BEGIN_STR);
74  end_length = strlen(END_STR);
75 
76  fd = fopen_config(XV_HELP_RC, NULL,NULL);
77  while ((line = safe_readline(fd)) != NULL)
78  {
79  if (strncmp(line, BEGIN_STR, begin_length) == 0 &&
80  strcmp(line + begin_length + 1, topic) == 0) {
81  selected = true;
82  } else if (strncmp(line, END_STR, end_length) == 0) {
83  if (selected) break;
84  }
85  else if (selected)
86  gen_array_dupaddto(array, index++, line);
87  free(line);
88  }
89 
90  if (! selected)
91  gen_array_dupaddto(array, index++, "Sorry: no help on this topic");
92 
93  fclose(fd);
94 }
void gen_array_dupaddto(gen_array_t a, size_t i, void *what)
Definition: array.c:111
char * safe_readline(FILE *file)
returns the allocated line read, whatever its length.
Definition: file.c:497
FILE * fopen_config(const char *canonical_name, const char *cproperty, const char *cenv)
Definition: file.c:952
void free(void *)
#define END_STR
Definition: help.c:40
#define BEGIN_STR
Definition: help.c:39
static int line
FLEX_SCANNER.
Definition: scanner.c:852
static entity array

References array, BEGIN_STR, END_STR, fopen_config(), free(), gen_array_dupaddto(), line, and safe_readline().

Referenced by display_help().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_help_topics()

void get_help_topics ( gen_array_t  array)

help.c

Parameters
arrayrray

Definition at line 43 of file help.c.

44 {
45  int index = 0, begin_length;
46  FILE *fd;
47  char *line;
48 
49 
50  begin_length = strlen(BEGIN_STR);
51 
52  fd = fopen_config(XV_HELP_RC, NULL,NULL);
53 
54  while ((line = safe_readline(fd)) != NULL) {
55  if (strncmp(line, BEGIN_STR, begin_length) == 0)
56  gen_array_dupaddto(array, index++, line+begin_length+1);
57  free(line);
58  }
59 
60  fclose(fd);
61 }

References array, BEGIN_STR, fopen_config(), free(), gen_array_dupaddto(), line, and safe_readline().

+ Here is the call graph for this function:

◆ pips_checks()

void pips_checks ( void  )

add checkings here (FI: why in help.c?) SG : PIPS_ROOT should not be required :)

Definition at line 100 of file help.c.

101 {
102  /*
103  if (!getenv("PIPS_ROOT")) {
104  (void) fprintf(stderr, "PIPS_ROOT environment variable not set. \n"
105  "Set it properly and relaunch.\n");
106  exit(1);
107  }
108  */
109 }

Referenced by gpips_main(), pips_main(), tpips_init(), and wpips_main().

+ Here is the caller graph for this function: