PIPS
view.c
Go to the documentation of this file.
1 /*
2 
3  $Id: view.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31 
32 #include <dirent.h>
33 
34 #include <sys/stat.h>
35 #include <ctype.h>
36 #include <setjmp.h>
37 #include <unistd.h>
38 #include <errno.h>
39 
40 #include "linear.h"
41 #include "genC.h"
42 
43 #include "misc.h"
44 #include "ri-util.h"
45 
46 #include "pipsdbm.h"
47 #include "pipsmake.h" // safe_make()
48 
49 #include "top-level.h"
50 
51 /* returns the allocated full path name.
52  * the database is added if it is relative...
53  */
54 static string get_view_file(const char* print_type, bool displayable)
55 {
57 
58  if(displayable && !displayable_file_p(print_type)) {
59  pips_user_error("resource %s cannot be displayed\n", print_type);
60  }
61 
62  if (module_name != NULL)
63  {
65  {
66  string file_name =
68 
69  if (file_name[0]!='.' && file_name[0]!='/')
70  {
71  /* the file name is relative to the database.
72  * thus the workspace directory name is prefixed.
73  */
74  string pgm_wd, file_name_in_database;
75 
77  file_name_in_database =
78  strdup(concatenate(pgm_wd, "/", file_name, NULL));
79 
80  free(pgm_wd);
81  return file_name_in_database;
82  }
83  else
84  {
85  /* it is relative to pips pwd, or absolute. */
86  return strdup(file_name);
87  }
88  }
89  }
90  else {
91  /* should be show_message */
92  user_log("No current module; select a module\n");
93  }
94  return NULL;
95 }
96 
97 string build_view_file(const char* print_type)
98 {
99  return get_view_file(print_type, true);
100 }
101 
103 {
104  return get_view_file(print_type, false);
105 }
void user_log(const char *format,...)
Definition: message.c:234
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void free(void *)
bool displayable_file_p(const char *name)
rather approximated.
Definition: lowlevel.c:361
#define pips_user_error
Definition: misc-local.h:147
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define db_get_file_resource
#define build_pgmwd
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82
bool safe_make(const char *res_n, const char *module_n)
Definition: pipsmake.c:1717
void print_type(type)
For debugging.
Definition: type.c:111
char * strdup()
static string file_name
static string get_view_file(const char *print_type, bool displayable)
returns the allocated full path name.
Definition: view.c:54
string get_dont_build_view_file(const char *print_type)
Definition: view.c:102
string build_view_file(const char *print_type)
view.c
Definition: view.c:97