version 1.3, 2025/03/09 19:14:25
|
version 1.4, 2025/03/22 18:43:54
|
Line 24
|
Line 24
|
* along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
* along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
* |
* |
* $Log$ |
* $Log$ |
|
* Revision 1.4 2025/03/22 18:43:54 snw |
|
* Make STRLEN 255 chars and add BIGSTR macro for larger buffers |
|
* |
* Revision 1.3 2025/03/09 19:14:25 snw |
* Revision 1.3 2025/03/09 19:14:25 snw |
* First phase of REUSE compliance and header reformat |
* First phase of REUSE compliance and header reformat |
* |
* |
Line 56 int fma_routines_list (int optc, char **
|
Line 59 int fma_routines_list (int optc, char **
|
DIR *dir; |
DIR *dir; |
struct dirent *ent; |
struct dirent *ent; |
|
|
char filename[STRLEN]; |
char filename[PATHLEN]; |
char *rtnname; |
char *rtnname; |
char *rtnext; |
char *rtnext; |
|
|
Line 75 int fma_routines_list (int optc, char **
|
Line 78 int fma_routines_list (int optc, char **
|
|
|
while ((ent = readdir (dir)) != NULL) { |
while ((ent = readdir (dir)) != NULL) { |
|
|
strncpy (filename, ent->d_name, STRLEN - 1); |
strncpy (filename, ent->d_name, PATHLEN - 1); |
|
|
rtnname = strtok (filename, "."); |
rtnname = strtok (filename, "."); |
rtnext = strtok (NULL, "."); |
rtnext = strtok (NULL, "."); |
|
|
if (rtnext != NULL && strncmp (rtnext, "m", STRLEN - 1) == 0) { |
if (rtnext != NULL && strncmp (rtnext, "m", PATHLEN - 1) == 0) { |
printf (" %s\n", rtnname); |
printf (" %s\n", rtnname); |
ct++; |
ct++; |
} |
} |
Line 97 int fma_routines_list (int optc, char **
|
Line 100 int fma_routines_list (int optc, char **
|
int fma_routines_edit (int optc, char **opts) |
int fma_routines_edit (int optc, char **opts) |
{ |
{ |
FILE *fp; |
FILE *fp; |
char rpath[STRLEN]; |
char rpath[PATHLEN]; |
char ecmd[STRLEN]; |
char ecmd[STRLEN]; |
char *editor; |
char *editor; |
|
|
Line 118 int fma_routines_edit (int optc, char **
|
Line 121 int fma_routines_edit (int optc, char **
|
|
|
} |
} |
|
|
snprintf (rpath, STRLEN - 1, "%s/%s.m", fma_routine_path, opts[fma_base_opt]); |
snprintf (rpath, PATHLEN - 1, "%s/%s.m", fma_routine_path, opts[fma_base_opt]); |
|
|
if (file_exists (rpath) == FALSE) { |
if (file_exists (rpath) == FALSE) { |
if ((fp = fopen (rpath, "w")) == NULL) { |
if ((fp = fopen (rpath, "w")) == NULL) { |
Line 144 int fma_routines_examine (int optc, char
|
Line 147 int fma_routines_examine (int optc, char
|
|
|
FILE *fp; |
FILE *fp; |
char c; |
char c; |
char rpath[STRLEN]; |
char rpath[PATHLEN]; |
/* char *editor; */ |
/* char *editor; */ |
|
|
if (optc < fma_min_args) { |
if (optc < fma_min_args) { |
Line 152 int fma_routines_examine (int optc, char
|
Line 155 int fma_routines_examine (int optc, char
|
return 1; |
return 1; |
} |
} |
|
|
snprintf (rpath, STRLEN - 1, "%s/%s.m", fma_routine_path, opts[fma_base_opt]); |
snprintf (rpath, PATHLEN - 1, "%s/%s.m", fma_routine_path, opts[fma_base_opt]); |
|
|
if (file_exists (rpath) == FALSE) { |
if (file_exists (rpath) == FALSE) { |
fprintf (stderr, "fmadm: routine %s does not exist in namespace %s\n", opts[1], fma_namespace); |
fprintf (stderr, "fmadm: routine %s does not exist in namespace %s\n", opts[1], fma_namespace); |
Line 179 int fma_routines_backup (int optc, char
|
Line 182 int fma_routines_backup (int optc, char
|
time_t t = time (NULL); |
time_t t = time (NULL); |
struct tm *buf; |
struct tm *buf; |
char rcmd[STRLEN]; |
char rcmd[STRLEN]; |
char backup_filename[STRLEN]; |
char backup_filename[PATHLEN]; |
char dtstamp[STRLEN]; |
char dtstamp[STRLEN]; |
char bup_path[STRLEN]; |
char bup_path[PATHLEN]; |
|
|
buf = gmtime (&t); |
buf = gmtime (&t); |
|
|
if (optc > 1) { |
if (optc > 1) { |
strncpy (bup_path, opts[fma_base_opt], STRLEN - 1); |
strncpy (bup_path, opts[fma_base_opt], PATHLEN - 1); |
} |
} |
else { |
else { |
strncpy (bup_path, "/tmp", STRLEN - 1); |
strncpy (bup_path, "/tmp", PATHLEN - 1); |
} |
} |
|
|
snprintf (dtstamp, STRLEN - 1, "%d%02d%02d%02d%02d%02d", buf->tm_year, buf->tm_mon, buf->tm_mday, buf->tm_hour, buf->tm_min, buf->tm_sec); |
snprintf (dtstamp, STRLEN - 1, "%d%02d%02d%02d%02d%02d", buf->tm_year, buf->tm_mon, buf->tm_mday, buf->tm_hour, buf->tm_min, buf->tm_sec); |
snprintf (backup_filename, STRLEN - 1, "%s/freem-routines-backup-%s-%s.tar", bup_path, fma_namespace, dtstamp); |
snprintf (backup_filename, PATHLEN - 1, "%s/freem-routines-backup-%s-%s.tar", bup_path, fma_namespace, dtstamp); |
|
|
printf ("\nFreeM Routine Backup\n"); |
printf ("\nFreeM Routine Backup\n"); |
printf ("--------------------\n\n"); |
printf ("--------------------\n\n"); |
Line 266 int fma_routines_import (int optc, char
|
Line 269 int fma_routines_import (int optc, char
|
return 1; |
return 1; |
} |
} |
|
|
if (strncmp (fma_namespace, "SYSTEM", STRLEN - 1) != 0) { |
if (strncmp (fma_namespace, "SYSTEM", PATHLEN - 1) != 0) { |
|
|
if (get_conf ("SYSTEM", "routines_path", pct_rtn_path) == FALSE) { |
if (get_conf ("SYSTEM", "routines_path", pct_rtn_path) == FALSE) { |
fprintf (stderr, "fmadm: could not determine percent routine access path from configuration for namespace '%s'.\n", namespace); |
fprintf (stderr, "fmadm: could not determine percent routine access path from configuration for namespace '%s'.\n", namespace); |
Line 403 int fma_routines_export (int optc, char
|
Line 406 int fma_routines_export (int optc, char
|
DIR *dir; /* namespace directory */ |
DIR *dir; /* namespace directory */ |
|
|
struct dirent *ent; |
struct dirent *ent; |
char output_file[STRLEN]; |
char output_file[PATHLEN]; |
char routine_spec[STRLEN]; |
char routine_spec[PATHLEN]; |
char filename[STRLEN]; |
char filename[PATHLEN]; |
char *rtnname; |
char *rtnname; |
char *rtnext; |
char *rtnext; |
int i; |
int i; |
Line 420 int fma_routines_export (int optc, char
|
Line 423 int fma_routines_export (int optc, char
|
|
|
/* if routines aren't listed, assume we should export entire namespace */ |
/* if routines aren't listed, assume we should export entire namespace */ |
if (optc == fma_min_args) { |
if (optc == fma_min_args) { |
strncpy (routine_spec, "*", STRLEN - 1); |
strncpy (routine_spec, "*", PATHLEN - 1); |
} |
} |
|
|
strncpy (output_file, opts[1], STRLEN - 1); |
strncpy (output_file, opts[1], PATHLEN - 1); |
strncpy (routine_spec, opts[2], STRLEN - 1); |
strncpy (routine_spec, opts[2], PATHLEN - 1); |
|
|
if (file_exists (output_file) == TRUE) { |
if (file_exists (output_file) == TRUE) { |
fprintf (stderr, "fmadm: output file %s already exists\n", output_file); |
fprintf (stderr, "fmadm: output file %s already exists\n", output_file); |
Line 470 int fma_routines_export (int optc, char
|
Line 473 int fma_routines_export (int optc, char
|
|
|
while ((ent = readdir (dir)) != NULL) { |
while ((ent = readdir (dir)) != NULL) { |
|
|
strncpy (filename, ent->d_name, STRLEN - 1); |
strncpy (filename, ent->d_name, PATHLEN - 1); |
|
|
rtnname = strtok (filename, "."); |
rtnname = strtok (filename, "."); |
rtnext = strtok (NULL, "."); |
rtnext = strtok (NULL, "."); |
|
|
if (rtnext != NULL && strncmp (rtnext, "m", STRLEN - 1) == 0) { |
if (rtnext != NULL && strncmp (rtnext, "m", PATHLEN - 1) == 0) { |
ct += fma_do_export (out, rtnname); |
ct += fma_do_export (out, rtnname); |
} |
} |
|
|
Line 504 int fma_routines_export (int optc, char
|
Line 507 int fma_routines_export (int optc, char
|
int fma_do_export (FILE *out, char *rtn_name) |
int fma_do_export (FILE *out, char *rtn_name) |
{ |
{ |
FILE *in; |
FILE *in; |
char rtnfile[STRLEN]; |
char rtnfile[PATHLEN]; |
char line[FM_STR_MAX]; |
char line[FM_STR_MAX]; |
|
|
snprintf (rtnfile, STRLEN - 1, "%s/%s.m", fma_routine_path, rtn_name); |
snprintf (rtnfile, PATHLEN - 1, "%s/%s.m", fma_routine_path, rtn_name); |
|
|
printf (" Exporting %-10s\t", rtn_name); |
printf (" Exporting %-10s\t", rtn_name); |
|
|
Line 539 int fma_routines_create (int optc, char
|
Line 542 int fma_routines_create (int optc, char
|
int fma_routines_remove (int optc, char **opts) |
int fma_routines_remove (int optc, char **opts) |
{ |
{ |
|
|
char rpath[STRLEN]; |
char rpath[PATHLEN]; |
int i; |
int i; |
int ct = 0; |
int ct = 0; |
int er = 0; |
int er = 0; |
Line 554 int fma_routines_remove (int optc, char
|
Line 557 int fma_routines_remove (int optc, char
|
for (i = fma_base_opt; i < optc; i++) { |
for (i = fma_base_opt; i < optc; i++) { |
printf ("%-10s\t", opts[i]); |
printf ("%-10s\t", opts[i]); |
|
|
snprintf (rpath, STRLEN - 1, "%s/%s.m", fma_routine_path, opts[i]); |
snprintf (rpath, PATHLEN - 1, "%s/%s.m", fma_routine_path, opts[i]); |
|
|
if (unlink (rpath) == -1) { |
if (unlink (rpath) == -1) { |
printf ("[FAIL]\n"); |
printf ("[FAIL]\n"); |