CHDK_DE Vorschauversion  Trunk Rev. 5573
 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 "keyboard.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 116 der Datei lib_thumb.c.

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

Definiert in Zeile 576 der Datei wrappers.c.

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

Definiert in Zeile 634 der Datei wrappers.c.

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

Definiert in Zeile 224 der Datei lib_thumb.c.

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

Definiert in Zeile 232 der Datei lib_thumb.c.

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

Definiert in Zeile 237 der Datei lib_thumb.c.

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

Definiert in Zeile 175 der Datei lib_thumb.c.

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

Definiert in Zeile 171 der Datei lib_thumb.c.

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

Definiert in Zeile 18 der Datei lib_thumb.c.

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

Definiert in Zeile 23 der Datei lib_thumb.c.

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

Definiert in Zeile 73 der Datei lib_thumb.c.

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

Definiert in Zeile 196 der Datei lib_thumb.c.

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

Definiert in Zeile 258 der Datei lib_thumb.c.

int vid_get_viewport_row_offset ( )

Definiert in Zeile 265 der Datei lib_thumb.c.

265  {
266 #ifndef THUMB_FW
268 #else
270 #endif
271 }