FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
reppath.c
Go to the documentation of this file.
1 /****************************************************************
2 reppath: display the path to the file.
3 
4 Copyright (C) 2007-2011 Hewlett-Packard Development Company, L.P.
5 
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License version 2.1 as published by the Free Software Foundation.
9 
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License
16 along with this library; if not, write to the Free Software Foundation, Inc.0
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 ****************************************************************/
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include "libfossology.h"
28 
29 #ifdef COMMIT_HASH
30 char BuildVersion[]="Build version: " COMMIT_HASH ".\n";
31 #endif
32 
33 int main(int argc, char* argv[])
34 {
35  char* Path;
36  int i;
37  char fname[FILENAME_MAX + 1];
38  char* sysconfigdir;
39  GError* error = NULL;
40 
41  sysconfigdir = DEFAULT_SETUP; /* defined in Makefile */
42  if (sysconfigdir)
43  {
44  snprintf(fname, FILENAME_MAX, "%s/%s", sysconfigdir, "fossology.conf");
45  sysconfig = fo_config_load(fname, &error);
46  if (error)
47  {
48  fprintf(stderr, "FATAL %s.%d: unable to open system configuration: %s\n",
49  __FILE__, __LINE__, error->message);
50  exit(-1);
51  }
52  }
53  else
54  {
55  fprintf(stderr, "FATAL %s.%d: Build error, unspecified system configuration location.\n",
56  __FILE__, __LINE__);
57  exit(-1);
58  }
59 
60  if ((argc % 2) != 1)
61  {
62  fprintf(stderr, "Usage: %s type filename [type filename [...]]\n", argv[0]);
63  exit(-1);
64  }
65 
66  for (i = 1; i < argc; i += 2)
67  {
68  Path = fo_RepMkPath(argv[i], argv[i + 1]);
69  if (Path)
70  {
71  printf("%s\n", Path);
72  free(Path);
73  }
74  else
75  {
76  fprintf(stderr, "ERROR: type='%s' filename='%s' invalid.\n",
77  argv[i], argv[i + 1]);
78  }
79  }
80  return (0);
81 } /* main() */
char BuildVersion[]
Definition: buckets.c:79
fo_conf * sysconfig
char * sysconfigdir
The main FOSSology C library.
char * fo_RepMkPath(const char *Type, char *Filename)
Given a filename, construct the full path to the file.
Definition: libfossrepo.c:364
fo_conf * fo_config_load(char *rawname, GError **error)
Load the configuration information from the provided file.
Definition: fossconfig.c:280