CHDK_DE Vorschauversion  Trunk Rev. 6014
 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 "dirent.h"
#include "ctype.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 119 der Datei lib_thumb.c.

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

Definiert in Zeile 574 der Datei wrappers.c.

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

Definiert in Zeile 632 der Datei wrappers.c.

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

Definiert in Zeile 227 der Datei lib_thumb.c.

228 {
229  time_t t = time(NULL);
230  return localtime(&t);
231 }
unsigned int GetJpgCount ( void  )

Definiert in Zeile 235 der Datei lib_thumb.c.

236 {
237  return strtol(camera_jpeg_count_str(),((void*)0),0);
238 }
unsigned int GetRawCount ( void  )

Definiert in Zeile 240 der Datei lib_thumb.c.

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

Definiert in Zeile 178 der Datei lib_thumb.c.

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

Definiert in Zeile 174 der Datei lib_thumb.c.

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

Definiert in Zeile 20 der Datei lib_thumb.c.

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

Definiert in Zeile 25 der Datei lib_thumb.c.

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

Definiert in Zeile 76 der Datei lib_thumb.c.

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

Definiert in Zeile 199 der Datei lib_thumb.c.

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

Definiert in Zeile 261 der Datei lib_thumb.c.

int vid_get_viewport_row_offset ( )

Definiert in Zeile 268 der Datei lib_thumb.c.

268  {
269 #ifndef THUMB_FW
271 #else
273 #endif
274 }