FOSSology  4.4.0
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  SPDX-FileCopyrightText: © 2007-2011 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: LGPL-2.1-only
6 */
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include "libfossology.h"
16 
17 #ifdef COMMIT_HASH
18 char BuildVersion[]="Build version: " COMMIT_HASH ".\n";
19 #endif
20 
21 int main(int argc, char* argv[])
22 {
23  char* Path;
24  int i;
25  char fname[FILENAME_MAX + 1];
26  char* sysconfigdir;
27  GError* error = NULL;
28 
29  sysconfigdir = DEFAULT_SETUP; /* defined in Makefile */
30  if (sysconfigdir)
31  {
32  snprintf(fname, FILENAME_MAX, "%s/%s", sysconfigdir, "fossology.conf");
33  sysconfig = fo_config_load(fname, &error);
34  if (error)
35  {
36  fprintf(stderr, "FATAL %s.%d: unable to open system configuration: %s\n",
37  __FILE__, __LINE__, error->message);
38  exit(-1);
39  }
40  }
41  else
42  {
43  fprintf(stderr, "FATAL %s.%d: Build error, unspecified system configuration location.\n",
44  __FILE__, __LINE__);
45  exit(-1);
46  }
47 
48  if ((argc % 2) != 1)
49  {
50  fprintf(stderr, "Usage: %s type filename [type filename [...]]\n", argv[0]);
51  exit(-1);
52  }
53 
54  for (i = 1; i < argc; i += 2)
55  {
56  Path = fo_RepMkPath(argv[i], argv[i + 1]);
57  if (Path)
58  {
59  printf("%s\n", Path);
60  free(Path);
61  }
62  else
63  {
64  fprintf(stderr, "ERROR: type='%s' filename='%s' invalid.\n",
65  argv[i], argv[i + 1]);
66  }
67  }
68  return (0);
69 } /* main() */
char BuildVersion[]
Definition: buckets.c:68
fo_conf * fo_config_load(char *rawname, GError **error)
Load the configuration information from the provided file.
Definition: fossconfig.c:275
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:352
char * sysconfigdir
fo_conf * sysconfig