![]() |
STASIS
A pipeline delivery generator
|
#include <stdio.h>#include <stdlib.h>#include <dirent.h>#include <string.h>#include <unistd.h>#include <limits.h>#include <errno.h>#include "core.h"#include "log.h"#include "copy.h"#include "system.h"#include "strlist.h"#include "utils.h"#include "ini.h"
Go to the source code of this file.
Functions | |
| int | pushd (const char *path) |
| int | popd (void) |
| char * | expandpath (const char *_path) |
| int | rmtree (char *_path) |
| char ** | file_readlines (const char *filename, size_t start, size_t limit, ReaderFn *readerFn) |
| char * | path_basename (char *path) |
| char * | path_dirname (char *path) |
| char * | find_program (const char *name) |
| int | touch (const char *filename) |
| int | git_clone (struct Process *proc, char *url, char *destdir, char *gitref) |
| char * | git_describe (const char *path) |
| char * | git_rev_parse (const char *path, char *args) |
| int | is_git_assumed_unchanged (char *filename) |
| int | path_store (char **destptr, size_t maxlen, const char *base, const char *path) |
| void | msg (unsigned type, char *fmt,...) |
| void | debug_shell () |
| char * | xmkstemp (FILE **fp, const char *mode) |
| int | isempty_dir (const char *path) |
| int | xml_pretty_print_in_place (const char *filename, const char *pretty_print_prog, const char *pretty_print_args) |
| int | fix_tox_conf (const char *filename, char **result, size_t maxlen) |
| char * | collapse_whitespace (char **s) |
| int | redact_sensitive (const char **to_redact, size_t to_redact_size, char *src, char *dest, size_t maxlen) |
| struct StrList * | listdir (const char *path) |
| long | get_cpu_count () |
| int | mkdirs (const char *_path, mode_t mode) |
| int | env_manipulate_pathstr (const char *key, char *path, int mode) |
| int | gen_file_extension_str (char *filename, size_t maxlen, const char *extension) |
| char * | remove_extras (char *s) |
| void | debug_hexdump (char *data, size_t len) |
| int | grow (size_t size_new, size_t *size_orig, char **data) |
| int | in_ascii_range (char c, char lower, char upper) |
| int | is_git_sha (char const *hash) |
| int | check_python_package_dependencies (const char *srcdir, struct StrList **out_files, struct StrList **out_matches) |
| void | seconds_to_human_readable (int v, char *result, size_t maxlen) |
| int | str_to_timeout (char *s) |
| const char * | get_random_generator_file () |
| int | get_random_bytes (char *result, size_t maxlen) |
| int | non_format_len (const char *s) |
| char * | center_text (const char *s, size_t maxwidth) |
| int | is_file_compressed (const char *filename) |
| char * collapse_whitespace | ( | char ** | s | ) |
Collapse all whitespace in a string (to single spaces)
| s | address of string to modify |
| int env_manipulate_pathstr | ( | const char * | key, |
| char * | path, | ||
| int | mode ) |
Return pointer to a (possible) version specifier
```c char s[] = "abc==1.2.3"; char *spec_begin = find_version_spec(s); // spec_begin is "==1.2.3"
char package_name[255]; char s[] = "abc"; char *spec_pos = find_version_spec(s); if (spec_pos) { strncpy(package_name, spec_pos - s); // use spec } else { // spec not found }
| str | a pointer to a buffer containing a package spec (i.e. abc==1.2.3, abc>=1.2.3, abc) |
mode flags for env_manipulate_pathstr #define PM_APPEND 1 << 0 #define PM_PREPEND 1 << 1 #define PM_ONCE 1 << 2
/** Add paths to the head or tail of an environment variable.
| key | environment variable to manipulate |
| path | to insert (does not need to exist) |
| mode | PM_APPEND $path:$PATH |
| mode | PM_PREPEND $PATH:path |
| mode | PM_ONCE do not manipulate if path is present in PATH variable |

| char * expandpath | ( | const char * | _path | ) |
Expand "~" to the user's home directory
| _path | (Must start with a ~) |

| char * find_program | ( | const char * | name | ) |
Scan PATH directories for a named program
| name | program name |
| int fix_tox_conf | ( | const char * | filename, |
| char ** | result, | ||
| size_t | maxlen ) |
Applies STASIS fixups to a tox ini config
| filename | path to tox.ini |
| result | path to processed configuration |
| maxlen |
| filename | /path/to/tox.ini |
| result | path of replacement tox.ini configuration |
| maxlen |

| int gen_file_extension_str | ( | char * | filename, |
| size_t | maxlen, | ||
| const char * | extension ) |
Append or replace a file extension

| long get_cpu_count | ( | ) |
Get CPU count
| int git_clone | ( | struct Process * | proc, |
| char * | url, | ||
| char * | destdir, | ||
| char * | gitref ) |
Clone a git repository
| proc | Process struct |
| url | URL (or file system path) of repoistory to clone |
| destdir | destination directory |
| gitref | commit/branch/tag of checkout (NULL will use HEAD of default branch for repo) |

| char * git_describe | ( | const char * | path | ) |
Git describe wrapper
| path | to repository |

| char * git_rev_parse | ( | const char * | path, |
| char * | args ) |
Git rev-parse wrapper
| path | to repository |
| args | to pass to git rev-parse |

| int grow | ( | size_t | size_new, |
| size_t * | size_orig, | ||
| char ** | data ) |
Realloc helper
| size_new | increase by size_new bytes |
| size_orig | address of variable containing the original allocation size (modified) |
| data | address to write data |
| int is_file_compressed | ( | const char * | filename | ) |
Check magic bytes against known compression formats
| filename | path to maybe-compressed file |
| int is_git_assumed_unchanged | ( | char * | filename | ) |
Check if a file in a git repository is flagged with 'assumed-unchanged'.
| filename | path to file |
Check if a file in a git repository is flagged as 'assumed-unchanged'.
| filename | path to file |

| int isempty_dir | ( | const char * | path | ) |
Is the path an empty directory structure?
| path | directory |
| struct StrList * listdir | ( | const char * | path | ) |
Given a directory path, return a list of files
| path | of a directory |
Retrieve file names in a directory (no metadata, non-recursive)
| path | directory path |

| int mkdirs | ( | const char * | _path, |
| mode_t | mode ) |
Create all leafs in directory path
| _path | directory path to create |
| mode | mode_t permissions |
| int non_format_len | ( | const char * | s | ) |
Get length of s as if any formatters are not present
| s | format string |
| char * path_basename | ( | char * | path | ) |
Strip directory from file name Note: Caller is responsible for freeing memory
| _path |
| char * path_dirname | ( | char * | path | ) |
Return parent directory of file, or the parent of a directory
| path |
| int path_store | ( | char ** | destptr, |
| size_t | maxlen, | ||
| const char * | base, | ||
| const char * | path ) |
Helper function to initialize simple STASIS internal path strings
| destptr | address of destination string pointer |
| maxlen | maximum length of the path |
| base | path |
| path | to append to base |

| int popd | ( | void | ) |
Return from directory. Pop last path from directory stack.
| int pushd | ( | const char * | path | ) |
| int redact_sensitive | ( | const char ** | to_redact, |
| size_t | to_redact_size, | ||
| char * | src, | ||
| char * | dest, | ||
| size_t | maxlen ) |
Write REDACTED in dest for each occurrence of to_redacted token present in src
| to_redact | array of tokens to redact |
| src | input string |
| dest | output string |
| maxlen | maximum length of dest byte array |
Replace sensitive text in strings with REDACTED
| to_redact | a list of tokens to redact |
| to_redact_size | limit to n tokens in list |
| src | to read |
| dest | to write modified string |
| maxlen | maximum length of dest string |

| char * remove_extras | ( | char * | s | ) |
Remove [extra]s from a spec string
| int rmtree | ( | char * | _path | ) |
| int touch | ( | const char * | filename | ) |
Create an empty file, or update modified timestamp on an existing file
| filename | file to touch |
| char * xmkstemp | ( | FILE ** | fp, |
| const char * | mode ) |
Creates a temporary file returning an open file pointer via fp, and the path to the file. The caller is responsible for closing fp and free()ing the returned file path.
| fp | pointer to FILE (to be initialized) |
| mode | fopen() style file mode string |

| int xml_pretty_print_in_place | ( | const char * | filename, |
| const char * | pretty_print_prog, | ||
| const char * | pretty_print_args ) |
Rewrite an XML file with a pretty printer command
| filename | path to modify |
| pretty_print_prog | program to call |
| pretty_print_args | arguments to pass to program |
