annotate fteeprom/filesearch.c @ 101:ba741a1af0e3

doc/CP2102-EEPROM-tools: article started
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 Sep 2023 06:35:39 +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 }