Sample program demonstrating basic usage of C API.
#include <stdio.h>
#include <locale.h>
#include <glib.h>
int main ()
{
int i, j;
const struct lfMount *
const *mounts;
const struct lfLens *
const *lenses;
setlocale (LC_ALL, "");
ldb = lf_db_new ();
if (!ldb)
{
fprintf (stderr, "Failed to create database\n");
return -1;
}
g_print ("< --------------- < Mounts > --------------- >\n");
for (i = 0; mounts [i]; i++)
{
if (mounts [i]->Compat)
for (j = 0; mounts [i]->
Compat [j]; j++)
g_print ("\tCompat: %s\n", mounts [i]->Compat [j]);
}
g_print ("< --------------- < Cameras > --------------- >\n");
for (i = 0; cameras [i]; i++)
{
g_print ("Camera: %s / %s %s%s%s\n",
cameras [i]->Variant ? "(" : "",
cameras [i]->Variant ?
lf_mlstr_get (cameras [i]->Variant) :
"",
cameras [i]->Variant ? ")" : "");
g_print ("\tCrop factor: %g\n", cameras [i]->CropFactor);
}
g_print ("< --------------- < Lenses > --------------- >\n");
for (i = 0; lenses [i]; i++)
{
g_print ("Lens: %s / %s\n",
g_print ("\tCrop factor: %g\n", lenses [i]->CropFactor);
g_print ("\tAspect ratio: %g\n", lenses [i]->AspectRatio);
g_print ("\tFocal: %g-%g\n", lenses [i]->MinFocal, lenses [i]->MaxFocal);
g_print ("\tAperture: %g-%g\n", lenses [i]->MinAperture, lenses [i]->MaxAperture);
g_print ("\tCenter: %g,%g\n", lenses [i]->CenterX, lenses [i]->CenterY);
if (lenses [i]->Mounts)
for (j = 0; lenses [i]->
Mounts [j]; j++)
}
g_print ("< ---< Saving database into one big file >--- >\n");
e = lf_db_save_file (ldb, "example-big.xml", mounts, cameras, lenses);
fprintf (stderr, "Failed writing to file, error code %d\n", e);
return 0;
}
const char * lf_mlstr_get(const lfMLstr str)
Get a string corresponding to current locale from a multi-language string.
lfError
Definition: lensfun.h:129
@ LF_NO_ERROR
Definition: lensfun.h:131
const lfLens *const * lf_db_get_lenses(lfDatabase *db)
lfError lf_db_load(lfDatabase *db)
const lfCamera *const * lf_db_get_cameras(lfDatabase *db)
const lfMount *const * lf_db_get_mounts(lfDatabase *db)
const char * lf_db_mount_name(const lfDatabase *db, const char *mount)
void lf_db_destroy(lfDatabase *db)
Destroy the database object.
Camera data. Unknown fields are set to NULL.
Definition: lensfun.h:355
A lens database object.
Definition: lensfun.h:1536
DEPRECATED char * HomeDataDir
Home lens database directory (deprecated). Replaced by lfDatabase::UserLocation.
Definition: lensfun.h:1538
Lens data. Unknown fields are set to NULL or 0.
Definition: lensfun.h:1011
DEPRECATED char ** Mounts
Definition: lensfun.h:1025
This structure contains everything specific to a camera mount.
Definition: lensfun.h:219
DEPRECATED char ** Compat
Definition: lensfun.h:227