CHDK_DE Vorschauversion  Trunk Rev. 5163
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
lib_thumb.c-Dateireferenz
#include "platform.h"
#include "conf.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 114 der Datei lib_thumb.c.

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

Definiert in Zeile 550 der Datei wrappers.c.

551 {
552  int have_semaphore = takeFileIOSemaphore();
553  if (!have_semaphore)
554 #if defined(CAM_IS_VID_REC_WORKS)
555  if (!conf.allow_unsafe_io)
556 #endif
557  return -1;
558 
559  extern int _closedir(void *d);
560  int ret = _closedir(d);
561 
562  if (have_semaphore)
563  _GiveSemaphore(fileio_semaphore);
564 
565  return ret;
566 }
void* fw_opendir ( const char *  name)

Definiert in Zeile 608 der Datei wrappers.c.

609  {
610  void *ret;
611  int have_semaphore = takeFileIOSemaphore();
612  if (!have_semaphore)
613 #if defined(CAM_IS_VID_REC_WORKS)
614  if (!conf.allow_unsafe_io)
615 #endif
616  return NULL;
617 
618  extern void *_opendir(const char* name);
619  ret = _opendir(name);
620 
621  if (have_semaphore)
622  _GiveSemaphore(fileio_semaphore);
623 
624  return ret;
625  }
struct tm* get_localtime ( )

Definiert in Zeile 222 der Datei lib_thumb.c.

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

Definiert in Zeile 230 der Datei lib_thumb.c.

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

Definiert in Zeile 235 der Datei lib_thumb.c.

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

Definiert in Zeile 173 der Datei lib_thumb.c.

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

Definiert in Zeile 169 der Datei lib_thumb.c.

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

Definiert in Zeile 16 der Datei lib_thumb.c.

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

Definiert in Zeile 21 der Datei lib_thumb.c.

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

Definiert in Zeile 71 der Datei lib_thumb.c.

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

Definiert in Zeile 194 der Datei lib_thumb.c.

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

Definiert in Zeile 256 der Datei lib_thumb.c.

int vid_get_viewport_row_offset ( )

Definiert in Zeile 263 der Datei lib_thumb.c.

263  {
265 }