LiVES  2.4.1-svn
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions
utils.c File Reference
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/file.h>
#include "main.h"
#include "support.h"
#include "audio.h"
#include "resample.h"

Macros

#define BUFFER_FILL_BYTES   65536
 
#define VER_MAJOR_MULT   1000000
 
#define VER_MINOR_MULT   1000
 
#define VER_MICRO_MULT   1
 
#define ASPECT_ALLOWANCE   0.005
 
#define rand_a   1073741789L
 
#define rand_c   32749L
 

Functions

char * filename_from_fd (char *val, int fd)
 
LIVES_INLINE void lives_srandom (unsigned int seed)
 
LIVES_INLINE uint64_t lives_random (void)
 
LIVES_INLINE pid_t lives_getpid (void)
 
LIVES_INLINE int lives_getuid (void)
 
LIVES_INLINE int lives_getgid (void)
 
LIVES_INLINE ssize_t lives_readlink (const char *path, char *buf, size_t bufsiz)
 
LIVES_INLINE boolean lives_fsync (int fd)
 
LIVES_INLINE void lives_sync (void)
 
LIVES_INLINE boolean lives_setenv (const char *name, const char *value)
 
int lives_system (const char *com, boolean allow_error)
 
lives_pgid_t lives_fork (const char *com)
 
ssize_t lives_write (int fd, const void *buf, size_t count, boolean allow_fail)
 
ssize_t lives_write_le (int fd, const void *buf, size_t count, boolean allow_fail)
 
int lives_fputs (const char *s, FILE *stream)
 
char * lives_fgets (char *s, int size, FILE *stream)
 
void lives_close_all_file_buffers (void)
 
ssize_t lives_read (int fd, void *buf, size_t count, boolean allow_less)
 
ssize_t lives_read_le (int fd, void *buf, size_t count, boolean allow_less)
 
LIVES_INLINE int lives_open_buffered_rdonly (const char *pathname)
 
LIVES_INLINE int lives_creat_buffered (const char *pathname, int mode)
 
int lives_close_buffered (int fd)
 
off_t lives_lseek_buffered_rdonly (int fd, off_t offset)
 
ssize_t lives_read_buffered (int fd, void *buf, size_t count, boolean allow_less)
 
ssize_t lives_read_le_buffered (int fd, void *buf, size_t count, boolean allow_less)
 
ssize_t lives_write_buffered (int fd, const void *buf, size_t count, boolean allow_fail)
 
ssize_t lives_write_le_buffered (int fd, const void *buf, size_t count, boolean allow_fail)
 
char * lives_format_storage_space_string (uint64_t space)
 
lives_storage_status_t get_storage_status (const char *dir, uint64_t warn_level, uint64_t *dsval)
 
int lives_chdir (const char *path, boolean allow_fail)
 
LIVES_INLINE void lives_freep (void **ptr)
 
LIVES_INLINE int lives_kill (lives_pid_t pid, int sig)
 
LIVES_INLINE int lives_killpg (lives_pgid_t pgrp, int sig)
 
LIVES_INLINE int myround (double n)
 
LIVES_INLINE void clear_mainw_msg (void)
 
LIVES_INLINE uint64_t lives_10pow (int pow)
 
LIVES_INLINE int get_approx_ln (uint32_t x)
 
int64_t lives_get_current_ticks (void)
 
int lives_alarm_set (int64_t ticks)
 
boolean lives_alarm_get (int alarm_handle)
 
void lives_alarm_clear (int alarm_handle)
 
LIVES_INLINE char * lives_strappend (char *string, int len, const char *xnew)
 
LIVES_INLINE LiVESList * lives_list_append_unique (LiVESList *xlist, const char *add)
 
LIVES_INLINE const char * get_image_ext_for_type (lives_image_type_t imgtype)
 
LIVES_INLINE float LEFloat_to_BEFloat (float f)
 
LIVES_INLINE double calc_time_from_frame (int clip, int frame)
 
LIVES_INLINE int calc_frame_from_time (int filenum, double time)
 nearest frame start More...
 
LIVES_INLINE int calc_frame_from_time2 (int filenum, double time)
 nearest frame end More...
 
LIVES_INLINE int calc_frame_from_time3 (int filenum, double time)
 nearest frame mid More...
 
boolean is_realtime_aplayer (int ptype)
 
void calc_aframeno (int fileno)
 
int calc_new_playback_position (int fileno, uint64_t otc, uint64_t *ntc)
 
void calc_maxspect (int rwidth, int rheight, int *cwidth, int *cheight)
 
void init_clipboard (void)
 
void d_print (const char *fmt,...)
 
boolean add_lmap_error (lives_lmap_error_t lerror, const char *name, livespointer user_data, int clipno, int frameno, double atime, boolean affects_current)
 
void clear_lmap_errors (void)
 
boolean check_for_lock_file (const char *set_name, int type)
 
boolean is_legal_set_name (const char *set_name, boolean allow_dupes)
 
boolean check_frame_count (int idx)
 
void get_frame_count (int idx)
 
void get_frames_sizes (int fileno, int frame)
 
void get_next_free_file (void)
 
void get_dirname (char *filename)
 
char * get_dir (const char *filename)
 
void get_basename (char *filename)
 
void get_filename (char *filename, boolean strip_dir)
 
char * get_extension (const char *filename)
 
char * ensure_extension (const char *fname, const char *ext)
 
boolean ensure_isdir (char *fname)
 
void get_location (const char *exe, char *val, int maxlen)
 
uint64_t get_version_hash (const char *exe, const char *sep, int piece)
 
uint64_t make_version_hash (const char *ver)
 
char * repl_tmpdir (const char *entry, boolean fwd)
 
void remove_layout_files (LiVESList *map)
 
void get_play_times (void)
 
void draw_little_bars (double ptrtime)
 
void get_total_time (lives_clip_t *file)
 
void find_when_to_stop (void)
 
void minimise_aspect_delta (double aspect, int hblock, int vblock, int hsize, int vsize, int *width, int *height)
 
void zero_spinbuttons (void)
 
boolean switch_aud_to_jack (void)
 
boolean switch_aud_to_pulse (void)
 
void switch_aud_to_sox (boolean set_in_prefs)
 
void switch_aud_to_mplayer (boolean set_in_prefs)
 
void switch_aud_to_mplayer2 (boolean set_in_prefs)
 
boolean prepare_to_play_foreign (void)
 
boolean after_foreign_play (void)
 
void set_menu_text (LiVESWidget *menuitem, const char *text, boolean use_mnemonic)
 
void get_menu_text (LiVESWidget *menuitem, char *text)
 
void get_menu_text_long (LiVESWidget *menuitem, char *text)
 
LIVES_INLINE boolean int_array_contains_value (int *array, int num_elems, int value)
 
void reset_clipmenu (void)
 
boolean check_file (const char *file_name, boolean check_existing)
 check if file exists More...
 
boolean check_dir_access (const char *dir)
 
boolean check_dev_busy (char *devstr)
 
void activate_url_inner (const char *link)
 
void activate_url (LiVESAboutDialog *about, const char *link, livespointer data)
 
void show_manual_section (const char *lang, const char *section)
 
uint64_t get_file_size (int fd)
 
uint64_t sget_file_size (const char *name)
 
void reget_afilesize (int fileno)
 
boolean create_event_space (int length)
 
int lives_list_strcmp_index (LiVESList *list, livesconstpointer data)
 
void add_to_recent (const char *filename, double start, int frames, const char *extra_params)
 
int verhash (char *version)
 
void set_undoable (const char *what, boolean sensitive)
 
void set_redoable (const char *what, boolean sensitive)
 
void set_sel_label (LiVESWidget *sel_label)
 
LIVES_INLINE void lives_list_free_strings (LiVESList *list)
 
boolean cache_file_contents (const char *filename)
 
char * get_val_from_cached_list (const char *key, size_t maxlen)
 
char * clip_detail_to_string (lives_clip_details_t what, size_t *maxlenp)
 
boolean get_clip_value (int which, lives_clip_details_t what, void *retval, size_t maxlen)
 
void save_clip_value (int which, lives_clip_details_t what, void *val)
 
LiVESList * get_set_list (const char *dir, boolean utf8)
 
boolean check_for_ratio_fps (double fps)
 
double get_ratio_fps (const char *string)
 
char * remove_trailing_zeroes (double val)
 
uint32_t get_signed_endian (boolean is_signed, boolean little_endian)
 
int get_token_count (const char *string, int delim)
 
int lives_utf8_strcasecmp (const char *s1, const char *s2)
 
char * subst (const char *string, const char *from, const char *to)
 
char * insert_newlines (const char *text, int maxwidth)
 
int hextodec (char *string)
 
int get_hex_digit (const char *c)
 
LIVES_INLINE uint32_t fastrand (void)
 
void fastsrand (uint32_t seed)
 
boolean is_writeable_dir (const char *dir)
 
uint64_t get_fs_free (const char *dir)
 
LIVES_INLINE LiVESInterpType get_interp_value (short quality)
 
LIVES_INLINE LiVESList * lives_list_move_to_first (LiVESList *list, LiVESList *item)
 
LiVESList * lives_list_delete_string (LiVESList *list, char *string)
 
LiVESList * lives_list_copy_strings (LiVESList *list)
 
boolean string_lists_differ (LiVESList *alist, LiVESList *blist)
 
lives_cancel_t check_for_bad_ffmpeg (void)
 

Macro Definition Documentation

#define ASPECT_ALLOWANCE   0.005
#define BUFFER_FILL_BYTES   65536
#define rand_a   1073741789L
#define rand_c   32749L
#define VER_MAJOR_MULT   1000000
#define VER_MICRO_MULT   1
#define VER_MINOR_MULT   1000

Function Documentation

void activate_url ( LiVESAboutDialog *  about,
const char *  link,
livespointer  data 
)
void activate_url_inner ( const char *  link)
boolean add_lmap_error ( lives_lmap_error_t  lerror,
const char *  name,
livespointer  user_data,
int  clipno,
int  frameno,
double  atime,
boolean  affects_current 
)
void add_to_recent ( const char *  filename,
double  start,
int  frames,
const char *  extra_params 
)
boolean after_foreign_play ( void  )
boolean cache_file_contents ( const char *  filename)
void calc_aframeno ( int  fileno)
LIVES_INLINE int calc_frame_from_time ( int  filenum,
double  time 
)

nearest frame start

LIVES_INLINE int calc_frame_from_time2 ( int  filenum,
double  time 
)

nearest frame end

LIVES_INLINE int calc_frame_from_time3 ( int  filenum,
double  time 
)

nearest frame mid

void calc_maxspect ( int  rwidth,
int  rheight,
int *  cwidth,
int *  cheight 
)
int calc_new_playback_position ( int  fileno,
uint64_t  otc,
uint64_t *  ntc 
)
LIVES_INLINE double calc_time_from_frame ( int  clip,
int  frame 
)
boolean check_dev_busy ( char *  devstr)
boolean check_dir_access ( const char *  dir)
boolean check_file ( const char *  file_name,
boolean  check_existing 
)

check if file exists

lives_cancel_t check_for_bad_ffmpeg ( void  )
boolean check_for_lock_file ( const char *  set_name,
int  type 
)
boolean check_for_ratio_fps ( double  fps)
boolean check_frame_count ( int  idx)
void clear_lmap_errors ( void  )
LIVES_INLINE void clear_mainw_msg ( void  )
char* clip_detail_to_string ( lives_clip_details_t  what,
size_t *  maxlenp 
)
boolean create_event_space ( int  length)
void d_print ( const char *  fmt,
  ... 
)
void draw_little_bars ( double  ptrtime)

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

char* ensure_extension ( const char *  fname,
const char *  ext 
)
boolean ensure_isdir ( char *  fname)
LIVES_INLINE uint32_t fastrand ( void  )
void fastsrand ( uint32_t  seed)
char* filename_from_fd ( char *  val,
int  fd 
)
void find_when_to_stop ( void  )
LIVES_INLINE int get_approx_ln ( uint32_t  x)
void get_basename ( char *  filename)
boolean get_clip_value ( int  which,
lives_clip_details_t  what,
void *  retval,
size_t  maxlen 
)
char* get_dir ( const char *  filename)
void get_dirname ( char *  filename)
char* get_extension ( const char *  filename)
uint64_t get_file_size ( int  fd)
void get_filename ( char *  filename,
boolean  strip_dir 
)
void get_frame_count ( int  idx)
void get_frames_sizes ( int  fileno,
int  frame 
)
uint64_t get_fs_free ( const char *  dir)
int get_hex_digit ( const char *  c)
LIVES_INLINE const char* get_image_ext_for_type ( lives_image_type_t  imgtype)
LIVES_INLINE LiVESInterpType get_interp_value ( short  quality)
void get_location ( const char *  exe,
char *  val,
int  maxlen 
)
void get_menu_text ( LiVESWidget *  menuitem,
char *  text 
)
void get_menu_text_long ( LiVESWidget *  menuitem,
char *  text 
)
void get_next_free_file ( void  )
void get_play_times ( void  )

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

< opaque black

< opaque white

double get_ratio_fps ( const char *  string)
LiVESList* get_set_list ( const char *  dir,
boolean  utf8 
)
uint32_t get_signed_endian ( boolean  is_signed,
boolean  little_endian 
)
lives_storage_status_t get_storage_status ( const char *  dir,
uint64_t  warn_level,
uint64_t *  dsval 
)
int get_token_count ( const char *  string,
int  delim 
)
void get_total_time ( lives_clip_t file)
char* get_val_from_cached_list ( const char *  key,
size_t  maxlen 
)
uint64_t get_version_hash ( const char *  exe,
const char *  sep,
int  piece 
)

get version hash output for an executable from the backend

int hextodec ( char *  string)
void init_clipboard ( void  )
char* insert_newlines ( const char *  text,
int  maxwidth 
)

< we will insert a nl here

LIVES_INLINE boolean int_array_contains_value ( int *  array,
int  num_elems,
int  value 
)
boolean is_legal_set_name ( const char *  set_name,
boolean  allow_dupes 
)
boolean is_realtime_aplayer ( int  ptype)
boolean is_writeable_dir ( const char *  dir)
LIVES_INLINE float LEFloat_to_BEFloat ( float  f)
LIVES_INLINE uint64_t lives_10pow ( int  pow)
void lives_alarm_clear ( int  alarm_handle)
boolean lives_alarm_get ( int  alarm_handle)
int lives_alarm_set ( int64_t  ticks)

set alarm for now + delta ticks (10 nanosec) param ticks (10 nanoseconds) is the offset when we want our alarm to trigger returns int handle or -1 call lives_get_alarm(handle) to test if time arrived

int lives_chdir ( const char *  path,
boolean  allow_fail 
)
void lives_close_all_file_buffers ( void  )
int lives_close_buffered ( int  fd)
LIVES_INLINE int lives_creat_buffered ( const char *  pathname,
int  mode 
)
char* lives_fgets ( char *  s,
int  size,
FILE *  stream 
)
lives_pgid_t lives_fork ( const char *  com)
char* lives_format_storage_space_string ( uint64_t  space)
int lives_fputs ( const char *  s,
FILE *  stream 
)
LIVES_INLINE void lives_freep ( void **  ptr)
LIVES_INLINE boolean lives_fsync ( int  fd)
int64_t lives_get_current_ticks ( void  )

return current (wallclock) time in ticks (units of 10 nanoseconds)

LIVES_INLINE int lives_getgid ( void  )
LIVES_INLINE pid_t lives_getpid ( void  )
LIVES_INLINE int lives_getuid ( void  )
LIVES_INLINE int lives_kill ( lives_pid_t  pid,
int  sig 
)
LIVES_INLINE int lives_killpg ( lives_pgid_t  pgrp,
int  sig 
)
LIVES_INLINE LiVESList* lives_list_append_unique ( LiVESList *  xlist,
const char *  add 
)
LiVESList* lives_list_copy_strings ( LiVESList *  list)
LiVESList* lives_list_delete_string ( LiVESList *  list,
char *  string 
)
LIVES_INLINE void lives_list_free_strings ( LiVESList *  list)
LIVES_INLINE LiVESList* lives_list_move_to_first ( LiVESList *  list,
LiVESList *  item 
)
int lives_list_strcmp_index ( LiVESList *  list,
livesconstpointer  data 
)
off_t lives_lseek_buffered_rdonly ( int  fd,
off_t  offset 
)
LIVES_INLINE int lives_open_buffered_rdonly ( const char *  pathname)
LIVES_INLINE uint64_t lives_random ( void  )
ssize_t lives_read ( int  fd,
void *  buf,
size_t  count,
boolean  allow_less 
)
ssize_t lives_read_buffered ( int  fd,
void *  buf,
size_t  count,
boolean  allow_less 
)
ssize_t lives_read_le ( int  fd,
void *  buf,
size_t  count,
boolean  allow_less 
)
ssize_t lives_read_le_buffered ( int  fd,
void *  buf,
size_t  count,
boolean  allow_less 
)
LIVES_INLINE ssize_t lives_readlink ( const char *  path,
char *  buf,
size_t  bufsiz 
)
LIVES_INLINE boolean lives_setenv ( const char *  name,
const char *  value 
)
LIVES_INLINE void lives_srandom ( unsigned int  seed)
LIVES_INLINE char* lives_strappend ( char *  string,
int  len,
const char *  xnew 
)
LIVES_INLINE void lives_sync ( void  )
int lives_system ( const char *  com,
boolean  allow_error 
)
int lives_utf8_strcasecmp ( const char *  s1,
const char *  s2 
)
ssize_t lives_write ( int  fd,
const void *  buf,
size_t  count,
boolean  allow_fail 
)
ssize_t lives_write_buffered ( int  fd,
const void *  buf,
size_t  count,
boolean  allow_fail 
)
ssize_t lives_write_le ( int  fd,
const void *  buf,
size_t  count,
boolean  allow_fail 
)
ssize_t lives_write_le_buffered ( int  fd,
const void *  buf,
size_t  count,
boolean  allow_fail 
)
uint64_t make_version_hash ( const char *  ver)

convert a version to uint64_t hash, for comparing

void minimise_aspect_delta ( double  aspect,
int  hblock,
int  vblock,
int  hsize,
int  vsize,
int *  width,
int *  height 
)
LIVES_INLINE int myround ( double  n)
boolean prepare_to_play_foreign ( void  )
void reget_afilesize ( int  fileno)
void remove_layout_files ( LiVESList *  map)
char* remove_trailing_zeroes ( double  val)
char* repl_tmpdir ( const char *  entry,
boolean  fwd 
)
void reset_clipmenu ( void  )
void save_clip_value ( int  which,
lives_clip_details_t  what,
void *  val 
)
void set_menu_text ( LiVESWidget *  menuitem,
const char *  text,
boolean  use_mnemonic 
)
void set_redoable ( const char *  what,
boolean  sensitive 
)
void set_sel_label ( LiVESWidget *  sel_label)
void set_undoable ( const char *  what,
boolean  sensitive 
)
uint64_t sget_file_size ( const char *  name)
void show_manual_section ( const char *  lang,
const char *  section 
)
boolean string_lists_differ ( LiVESList *  alist,
LiVESList *  blist 
)
char* subst ( const char *  string,
const char *  from,
const char *  to 
)
boolean switch_aud_to_jack ( void  )
void switch_aud_to_mplayer ( boolean  set_in_prefs)
void switch_aud_to_mplayer2 ( boolean  set_in_prefs)
boolean switch_aud_to_pulse ( void  )
void switch_aud_to_sox ( boolean  set_in_prefs)
int verhash ( char *  version)
void zero_spinbuttons ( void  )