CHDK_DE Vorschauversion  Trunk Rev. 5456
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
lib_thumb.c-Dateireferenz
#include "platform.h"
#include "conf.h"
#include "gui_draw.h"
+ Include-Abhängigkeitsdiagramm für lib_thumb.c:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  __dirent
 

Funktionen

int fw_closedir (void *d)
 
void * fw_opendir (const char *name)
 
DIRopendir (const char *name)
 
DIRopendir_chdk (const char *name, unsigned flags)
 
struct direntreaddir (DIR *d)
 
int closedir (DIR *d)
 
int iscntrl (int c)
 
int isalnum (int c)
 
char * strstr (const char *s1, const char *s2)
 
struct tmget_localtime ()
 
unsigned int GetJpgCount (void)
 
unsigned int GetRawCount (void)
 
int vid_get_viewport_image_offset ()
 
int vid_get_viewport_row_offset ()
 

Dokumentation der Funktionen

int closedir ( DIR d)

Definiert in Zeile 115 der Datei lib_thumb.c.

116 {
117  int rv = -1;
118  if (d && d->cam_DIR)
119  {
120 #if defined(CAM_DRYOS)
121  if (d->fw_dir == 0)
122  {
123  rv = CHDKCloseDir(d->cam_DIR);
124  }
125  else
126 #endif
127  rv = fw_closedir(d->cam_DIR);
128 
129  // Mark closed (just in case)
130  d->cam_DIR = 0;
131  // Free allocated memory
132  free(d);
133  }
134  return rv;
135 }
int fw_closedir ( void *  d)

Definiert in Zeile 579 der Datei wrappers.c.

580 {
581  int have_semaphore = takeFileIOSemaphore();
582  if (!have_semaphore)
583 #if defined(CAM_IS_VID_REC_WORKS)
584  if (!conf.allow_unsafe_io)
585 #endif
586  return -1;
587 
588  extern int _closedir(void *d);
589  int ret = _closedir(d);
590 
591  if (have_semaphore)
592  _GiveSemaphore(fileio_semaphore);
593 
594  return ret;
595 }
void* fw_opendir ( const char *  name)

Definiert in Zeile 637 der Datei wrappers.c.

638  {
639  void *ret;
640  int have_semaphore = takeFileIOSemaphore();
641  if (!have_semaphore)
642 #if defined(CAM_IS_VID_REC_WORKS)
643  if (!conf.allow_unsafe_io)
644 #endif
645  return NULL;
646 
647  extern void *_opendir(const char* name);
648  ret = _opendir(name);
649 
650  if (have_semaphore)
651  _GiveSemaphore(fileio_semaphore);
652 
653  return ret;
654  }
struct tm* get_localtime ( )

Definiert in Zeile 223 der Datei lib_thumb.c.

224 {
225  time_t t = time(NULL);
226  return localtime(&t);
227 }
unsigned int GetJpgCount ( void  )

Definiert in Zeile 231 der Datei lib_thumb.c.

232 {
233  return strtol(camera_jpeg_count_str(),((void*)0),0);
234 }
unsigned int GetRawCount ( void  )

Definiert in Zeile 236 der Datei lib_thumb.c.

237 {
238  unsigned free_kb = GetFreeCardSpaceKb();
239  unsigned raw_kb = camera_sensor.raw_size/1024;
240  unsigned jpgcount = GetJpgCount();
241  unsigned avg_jpg_kb = (jpgcount>0)? free_kb/jpgcount : 0;
242 
243  // 0.25 raw margin
244  unsigned margin_kb = raw_kb/4;
245  if(free_kb <= raw_kb + margin_kb) {
246  return 0;
247  }
248  free_kb -= margin_kb;
249  return free_kb/(raw_kb+avg_jpg_kb);
250 }
int isalnum ( int  c)

Definiert in Zeile 174 der Datei lib_thumb.c.

174 { return (isdigit(c) || isalpha(c)); }
int iscntrl ( int  c)

Definiert in Zeile 170 der Datei lib_thumb.c.

170 { return ((c >=0 && c <32) || c == 127); }
DIR* opendir ( const char *  name)

Definiert in Zeile 17 der Datei lib_thumb.c.

18 {
19  return opendir_chdk(name,OPENDIR_FL_NONE);
20 }
DIR* opendir_chdk ( const char *  name,
unsigned  flags 
)

Definiert in Zeile 22 der Datei lib_thumb.c.

23 {
24  // Create CHDK DIR structure
25  DIR *dir = malloc(sizeof(DIR));
26  // If malloc failed return failure
27  if (dir == 0) return NULL;
28 
29 #if defined(CAM_DRYOS)
30  extern int get_fstype(void);
31  // try built-in routine first, but only on FAT
32  if ((get_fstype() < 4) && (flags & OPENDIR_FL_CHDK_LFN))
33  {
34  dir->fw_dir = 0;
35  dir->cam_DIR = CHDKOpenDir(name);
36  }
37  else
38  {
39  dir->cam_DIR = NULL;
40  }
41  if (!dir->cam_DIR)
42  {
43  // try firmware routine if built-in failed
44  dir->fw_dir = 1;
45  dir->cam_DIR = fw_opendir(name);
46  }
47 #else
48  dir->cam_DIR = fw_opendir(name);
49 #endif
50 
51  // Init readdir return value
52  dir->dir.d_name[0] = 0;
53 
54  // If failed clean up and return failure
55  if (!dir->cam_DIR)
56  {
57  free(dir);
58  return NULL;
59  }
60 
61  return dir;
62 }
struct dirent* readdir ( DIR d)

Definiert in Zeile 72 der Datei lib_thumb.c.

73 {
74  if (d && d->cam_DIR)
75  {
76  // Get next entry from firmware function
77  extern void *fw_readdir(void *d);
78  struct __dirent *de = fw_readdir(d->cam_DIR);
79  // Return next directory name if present, else return 0 (end of list)
80  if (de)
81  {
82  strcpy(d->dir.d_name,de->d_name);
83  return &d->dir;
84  }
85  else
86  {
87  d->dir.d_name[0] = 0;
88  }
89  }
90  return NULL;
91 }
char* strstr ( const char *  s1,
const char *  s2 
)

Definiert in Zeile 195 der Datei lib_thumb.c.

196 {
197  const char *p = s1;
198  const int len = strlen(s2);
199 
200  for (; (p = strchr(p, *s2)) != 0; p++)
201  {
202  if (strncmp(p, s2, len) == 0)
203  return (char*)p;
204  }
205  return (0);
206 }
int vid_get_viewport_image_offset ( )

Definiert in Zeile 257 der Datei lib_thumb.c.

int vid_get_viewport_row_offset ( )

Definiert in Zeile 264 der Datei lib_thumb.c.

264  {
265 #ifndef THUMB_FW
267 #else
269 #endif
270 }