view libutil/filesearch.c @ 53:fbedb67d234f

serial: fix parity for inverse coding convention Important note: it is my (Mother Mychaela's) understanding that SIM cards with inverse coding convention are extremely rare, and I have never seen such a card. Therefore, our support for the inverse coding convention will likely remain forever untested.
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Mar 2021 20:46:09 +0000
parents 34bbb0585cab
children
line wrap: on
line source

/*
 * This module implements the function that searches for files
 * in a dedicated directory for SIM programming scripts.
 */

#include <stdio.h>
#include <string.h>
#include <strings.h>

static char script_install_dir[] = "/opt/freecalypso/sim-scripts";

FILE *
open_script_input_file(req_filename)
	char *req_filename;
{
	char pathbuf[256];
	FILE *f;

	if (!index(req_filename, '/') && strlen(req_filename) < 128) {
		sprintf(pathbuf, "%s/%s", script_install_dir, req_filename);
		f = fopen(pathbuf, "r");
		if (f)
			return f;
	}
	f = fopen(req_filename, "r");
	return f;
}