annotate fteeprom/filesearch.c @ 105:1e820ed0904e

Installed-binaries: list of binaries installed by this package I am establishing a new convention for all FreeCalypso tools, across different packages and source repositories: each FC tools package will have a file name Installed-binaries listing all user-invokable binaries that package installs in /opt/freecalypso/bin. These files are to serve as an aid to users and distro package maintainers who prefer to not add /opt/freecalypso/bin to their PATH. The alternative to adding this directory to PATH is to create a symlink for every installed binary in some standard location such as /usr/bin or /usr/local/bin, pointing to the actual binary in /opt/freecalypso/bin; having a list of all FC-installed binaries in a standardized format will allow this process to be automated.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 29 Sep 2023 19:42:53 +0000
parents b2c891299e83
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the function that searches for FTDI EEPROM config
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * files in a dedicated installation directory. It is based on the version
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * in fc-sim-tools that looks in the sim-scripts directory.
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 static char ftdi_install_dir[] = "/opt/freecalypso/ftdi";
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 FILE *
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 open_eeprom_config_file(req_filename)
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char *req_filename;
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char pathbuf[256];
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 FILE *f;
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 if (!index(req_filename, '/') && strlen(req_filename) < 128) {
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 sprintf(pathbuf, "%s/%s", ftdi_install_dir, req_filename);
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 f = fopen(pathbuf, "r");
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (f)
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return f;
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 f = fopen(req_filename, "r");
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 return f;
b2c891299e83 ftee-gen*: look for EEPROM config file in /opt/freecalypso/ftdi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }