31#if __has_include(<unistd.h>)
45#if defined(__APPLE__) && defined(__MACH__)
46#include <mach-o/dyld.h>
49#if defined(__FreeBSD__)
50#include <sys/sysctl.h>
61 if (
stat(name_c, &buf) == 0) {
79 *ierr =
stat(name_c, &statbuf);
82 mtime = statbuf.st_mtime;
83 timeinfo = localtime(&mtime);
84 mod_time_c = asctime(timeinfo);
87 mod_time_c = malloc(
sizeof(
char));
92 printf(
"ierr = %i\n", *ierr);
105 return S_ISDIR(statbuf.st_mode);
111void oct_rm(
char * name_c) {
121 tmp = realpath(
fn, NULL);
127 strcpy(dn, dirname(
fn));
131 strcpy(bn, basename(
fn));
136 tmp = getenv(name_c);
154 for (
i = 0;
i < 16384;
i++)
159 for (c1 = c; isdigit(*
s) || isspace(*
s);
s++)
167 for (c1 = c; isdigit(*
s) || isspace(*
s);
s++)
175 for (
i = i1;
i <= i2;
i++)
176 if (
i >= 0 &&
i < 16384)
206 *sec = (int)tv.tv_sec;
207 *usec = (
int)tv.tv_usec;
225 FC_FUNC_(oct_gettimeofday, OCT_GETTIMEOFDAY)(&sec, &usec);
226 return sec + 1.0e-6 * usec;
228 return (
double)
clock() / CLOCKS_PER_SEC;
238 nanosleep(&req, NULL);
255 pf = fopen(name_c,
"r");
259 while ((c = getc(pf)) != EOF) {
274 OCT_BREAK_C_STRING)(
char **str,
char **
s,
281 if (*
s == NULL || **
s ==
'\0') {
286 for (c = line; **
s !=
'\0' && **
s !=
'\n'; (*s)++, c++)
292 strcpy(line_f, line);
320 char *num_start, *num_end;
321 double read_value, min;
322 int found_something, read_tag;
339 num_start = strchr(ent->d_name,
'_');
341 if (num_start != NULL) {
345 read_value = strtod(num_start, &num_end);
347 if (num_end == num_start)
351 if (num_end[0] ==
'_') {
353 num_start = num_end + 1;
354 read_tag = (int)strtol(num_start, &num_end, 10);
355 if (num_end == num_start)
357 if (read_tag != *tag)
364 if (!found_something) {
377 if (found_something) {
385#warning directory search not compiled
386 fprintf(
stderr,
"Warning: Directory search not available since certain C "
387 "functions are not available.\n");
392void *
FC_FUNC_(oct_get_memory_usage, OCT_GET_MEMORY_USAGE)() {
394 static size_t pagesize = 0;
404 sprintf(
s,
"%s%d%s",
"/proc/", pid,
"/statm");
405 if ((
f = fopen(
s,
"r")) == (
FILE *)NULL)
407 fscanf(
f,
"%lu", &mem);
410 return (
void *)(mem * pagesize);
419#if defined(__APPLE__) && defined(__MACH__)
423 ret = _NSGetExecutablePath(buf, &bufsize);
425 buf = (
char *)malloc(bufsize);
427 ret = _NSGetExecutablePath(buf, &bufsize);
429 path = realpath(buf, NULL);
431#elif defined(linux) || defined(__linux)
432 path = realpath(
"/proc/self/exe", NULL);
433#elif defined(__NETBSD__) || defined(__NetBSD__)
434 path = realpath(
"/proc/curproc/exe", NULL);
435#elif defined(__DragonFly__)
436 path = realpath(
"/proc/curproc/file", NULL);
437#elif defined(__FreeBSD__)
438 int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
441 ret = sysctl(mib, 4, NULL, &len, NULL, 0);
444 assert(path != NULL);
445 ret = sysctl(mib, 4, path, &len, NULL, 0);
449 path = (
char *)malloc(1);
450 assert(path != NULL);
454 fprintf(
stderr,
"%s:%d: in %s: Something went wrong\n", __FILE__, __LINE__, __func__);
455 path = (
char *)malloc(1);
456 assert(path != NULL);
char * getcwd(char *__buf, size_t __size) __attribute__((__nothrow__
double fabs(double __x) __attribute__((__nothrow__
double fn(const gsl_vector *v, void *params)
real(real64) function s()
long int sysconf(int __name) __attribute__((__nothrow__
void oct_wfs_list(char *str_c, fint l[16384])
void oct_executable_path(char *path)
void oct_rm(char *name_c)
void oct_getcwd(char *name)
int mkdir(const char *__path, __mode_t __mode) __attribute__((__nothrow__
void oct_basename(char *fn, char *bn)
int gettimeofday(struct timeval *__restrict __tv, void *__restrict __tz) __attribute__((__nothrow__
void oct_sysname(char *name_c)
int oct_number_of_lines(char *name_c)
void oct_stat(fint *ierr, char *name_c, char *mod_time_c)
void oct_realpath(char *fn, char *rn)
void oct_dirname(char *fn, char *dn)
void oct_getenv(char *name_c, char *var_c)
DIR DIR struct dirent * readdir(DIR *__dirp) __attribute__((__nonnull__(1)))
DIR * opendir(const char *__name) __attribute__((__nonnull__(1))) __attribute__((__malloc__)) __attribute__((__malloc__(closedir
int closedir(DIR *__dirp) __attribute__((__nonnull__(1)))
int oct_dir_exists(char *name_c)
void FC_FUNC_(oct_progress_bar, OCT_PROGRESS_BAR)
int stat(const char *__restrict __file, struct stat *__restrict __buf) __attribute__((__nothrow__
int fclose(FILE *__stream)
void oct_search_file_lr(double *freq, const fint *tag, fint *ierr, char *name_c)
void progress_bar(int actual, int max)
void oct_mkdir(char *name_c)
static double f(double w, void *p)
__syscall_slong_t tv_nsec