~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to xmetanet/init.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright INRIA */
 
2
#include <X11/Intrinsic.h>
 
3
#include <dirent.h>
 
4
#include <stdlib.h>
 
5
#include <string.h>
 
6
 
 
7
#include "list.h"
 
8
#include "graph.h"
 
9
#include "metio.h"
 
10
#include "menus.h"
 
11
#include "graphics.h"
 
12
 
 
13
extern char* my_basename();
 
14
extern char* dirname();
 
15
extern int LoadNamedGraph();
 
16
extern char *StripGraph();
 
17
 
 
18
#if defined(SYSV) || defined(SVR4)
 
19
#define getwd(x) getcwd(x,2*MAXNAM)
 
20
#endif
 
21
 
 
22
#define MAXGRAPHS 100
 
23
 
 
24
int arcStrDisplay = NODISP;
 
25
int nodeStrDisplay = NODISP;
 
26
double metaScale = 1.0;
 
27
 
 
28
int maxGraphs;
 
29
GG theGG;
 
30
char *graphNames[MAXGRAPHS];
 
31
graph *theGraph;
 
32
char datanet[2*MAXNAM];
 
33
char beginHelp[2*MAXNAM];
 
34
char studyHelp[2*MAXNAM];
 
35
char modifyHelp[2*MAXNAM];
 
36
 
 
37
void InitMetanet(path,scale)
 
38
char *path;
 
39
double scale;
 
40
{
 
41
  char *dir, *name;
 
42
  DIR *dirp;
 
43
  FILE *f1, *f2, *f3;
 
44
 
 
45
  name = NULL;
 
46
  if (path == NULL) {
 
47
    getwd(datanet);
 
48
  }
 
49
  else {
 
50
    if ((dirp=opendir(path)) != NULL) {
 
51
      strcpy(datanet,path);
 
52
      closedir(dirp);
 
53
    } else {
 
54
      name = my_basename(path);
 
55
      dir = dirname(path);
 
56
      if (dir == NULL) getwd(datanet);
 
57
      else strcpy(datanet,dir);
 
58
    }
 
59
 
 
60
    if ((dirp=opendir(datanet)) == NULL) {
 
61
      sprintf(Description,"Directory \"%s\" does not exist",datanet);
 
62
      MetanetAlert(Description);
 
63
      exit(1);
 
64
    }
 
65
    closedir(dirp);
 
66
  }
 
67
 
 
68
  dir=getenv("NETHELPDIR");
 
69
  if (dir == NULL || (dirp=opendir(dir)) == NULL) {
 
70
    sprintf(Description,"Help Directory does not exist\nHelp not available");
 
71
    MetanetAlert(Description);
 
72
  }  else {
 
73
    strcpy(beginHelp,dir);
 
74
    strcat(beginHelp,"/MetanetBegin.help");
 
75
    strcpy(studyHelp,dir);
 
76
    strcat(studyHelp,"/MetanetStudy.help");
 
77
    strcpy(modifyHelp,dir);
 
78
    strcat(modifyHelp,"/MetanetModify.help");
 
79
    if ((f1=fopen(beginHelp,"r")) == NULL || 
 
80
        (f2=fopen(studyHelp,"r")) == NULL ||
 
81
        (f3=fopen(modifyHelp,"r")) == NULL) {
 
82
      sprintf(Description,"Help Files does not exist\nHelp not available");   
 
83
    }
 
84
    fclose(f1); fclose(f2); fclose(f3);    
 
85
    closedir(dirp);
 
86
  }
 
87
  
 
88
  if (scale > 0) metaScale = scale;
 
89
  
 
90
  theGG.n_hilited_arcs = 0;
 
91
  theGG.n_hilited_nodes = 0;
 
92
  theGG.hilited_arcs = ListAlloc();
 
93
  theGG.hilited_nodes = ListAlloc();
 
94
  theGG.moving = 0;
 
95
  theGG.modified = 0;
 
96
  theGraph = NULL;
 
97
  maxGraphs = MAXGRAPHS;
 
98
  if (name != NULL && LoadNamedGraph(StripGraph(name))) return;
 
99
  DisplayMenu(BEGIN);
 
100
}