Main Page | Class List | File List | File Members

modDB.c File Reference

Functions to read lens profile information from profile files. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "../include/clens.h"

Functions

long instrrev (char *str2, char *str1)
 Find the last occurance of str1 in str2.

char * trim (char *str)
 Trim white space from str.

void substr (char *destStr, char *srcStr, int offset, int len)
 Copy len characters from srcStr to destStr starting from offset.

int lhs (char *str, char *key)
 If key matches the beginning of str, copy the value (ie the rest of the string minus key) to the global. variable rhs.

void sortCoefs (long lb, long ub)
 Sort the global array of coefficients, coef[], within a region defined by lb and ub.

void insertCam (CamNode *pCam)
 Insert a camera into the linked list of cameras such that cameras are alphabetized by make within models and models are in the same order as in "profile.txt".

void insertLns (LnsNode *pLns)
 Insert a lens into the linked list of lenses such that lenses belonging to the same group are together.

int check (int b, char *s)
 Utility function to print error messages from parsing the profile files.

long processDbFile (char *s)
 Function to parse profile files. The Lens, Camera, and group linked lists are created here, and the coef[] array is populated.

long processDbIndex (char *s)
 Parse the lines in the master profile file, "profile.txt".

long readDataBase ()
 Read lens calibration data from profile files.

CamNode * findCamera (char *exifMake, char *exifModel)
 Look for a camera in the linked list of supported cameras.

int inGroups (LnsNode *thisLens, CamNode *thisCamera)
 Look for a lens in the list of lens groups compatable with the camera.

LnsNode * findLens (char *lens, CamNode *camera)
 Look for a lens in the linked list of supported lenses. The lens is checked to make sure it has been calibrated for the camera passed in.

LnsNode * findLenses (CamNode *camera)
 Create a linked list of all calibrated lenses for the input camera.


Variables

prefType pref
 Data structure to hold program preferences.

CamNode * pCamHdr = NULL
 Points to the first camera in the linked list of supported cameras.

LnsNode * pLnsHdr = NULL
 Points to the first lens in the linked list of supported lenses.

CamNode pCurCam
 Current camera being read in from profiles.

LnsNode pCurLns
 Current lens being read in from profiles.

CoefType coef [10000]
 Array of lens correction coefficient data types.

long coefIndex
 Next available slot in coef[]. Holds the total number of lens correction coefficients after all profiles are read.

char * fileList [500]
 Array to hold the filenames contained in profile.txt.

long fileIndex
 Next available slot in fileList[].

char * fileName
 Current profile file name being read from.

int line
 Holds the value of the current line of being read in profile.txt.

char rhs [256]
 String to hold the right hand side of a parsed line.

const long PROCESS_VOID = 0
 State value for parsing profile files.

const long PROCESS_CAM = 1
 State value for parsing profile files.

const long PROCESS_LENS = 2
 State value for parsing profile files.


Detailed Description

Functions to read lens profile information from profile files.

Author:
Tim Jacobs (ported from Thoms Niemann's PTLens code)
Date:
2004.11.13
Full description here.

Function Documentation

int check int  b,
char *  s
 

Utility function to print error messages from parsing the profile files.

Returns:
The value of b passed in
Parameters:
b Indicates if an error message needs to be printed
s The string identifying a missing element in the profile file

CamNode* findCamera char *  exifMake,
char *  exifModel
 

Look for a camera in the linked list of supported cameras.

Returns:
pointer to camera node if successfull, NULL otherwise
Parameters:
exifMake The camera make as found in the jpeg EXIF data
exifModel The camera model as found in the jpeg EXIF data

LnsNode* findLens char *  lens,
CamNode *  camera
 

Look for a lens in the linked list of supported lenses. The lens is checked to make sure it has been calibrated for the camera passed in.

Returns:
pointer to the lens node if successful, NULL otherwise
Parameters:
lens The lens to look for
camera The camera model as found in the jpeg EXIF data

LnsNode* findLenses CamNode *  camera  ) 
 

Create a linked list of all calibrated lenses for the input camera.

Returns:
pointer to the first lens node if lenses found, NULL otherwise
Parameters:
camera A pointer to the camera node in the linked list

int inGroups LnsNode *  thisLens,
CamNode *  thisCamera
 

Look for a lens in the list of lens groups compatable with the camera.

Returns:
0 if unseccessful, 1 otherwise
Parameters:
thisLens The lens to look for
thisCamera The camera model as found in the jpeg EXIF data

void insertCam CamNode *  pCam  ) 
 

Insert a camera into the linked list of cameras such that cameras are alphabetized by make within models and models are in the same order as in "profile.txt".

Parameters:
pCam The camera to insert

void insertLns LnsNode *  pLns  ) 
 

Insert a lens into the linked list of lenses such that lenses belonging to the same group are together.

Parameters:
pLns The lens to insert

long instrrev char *  str2,
char *  str1
 

Find the last occurance of str1 in str2.

Returns:
The position in str2 of the last occurance of str1. 0 if not found
Parameters:
str2 The string to search
str1 The substring to look for in str1

int lhs char *  str,
char *  key
 

If key matches the beginning of str, copy the value (ie the rest of the string minus key) to the global. variable rhs.

Returns:
0 if key not found, 1 otherwise
Parameters:
str The string possibly containing key and value
key The key to look for

long processDbFile char *  s  ) 
 

Function to parse profile files. The Lens, Camera, and group linked lists are created here, and the coef[] array is populated.

Returns:
0 if line parsed successfully, 1 otherwise
Parameters:
s A line from a profile file

long processDbIndex char *  s  ) 
 

Parse the lines in the master profile file, "profile.txt".

Returns:
0 if line parsed successfully, 1 otherwise
Parameters:
s A line from "profile.txt"

long readDataBase  ) 
 

Read lens calibration data from profile files.

Returns:
0 if successfull, 1 otherwise

void sortCoefs long  lb,
long  ub
 

Sort the global array of coefficients, coef[], within a region defined by lb and ub.

Parameters:
lb The lower bound (inclusive) for the sort region
ub The upper bound (inclusive) for the sort region

void substr char *  destStr,
char *  srcStr,
int  offset,
int  len
 

Copy len characters from srcStr to destStr starting from offset.

Parameters:
destStr The destination string
srcStr The source string
offset The offset in srcStr from which to start copying
len The number of characters to copy to destStr

char* trim char *  str  ) 
 

Trim white space from str.

Returns:
The input string (str) minus any white space from either end
Parameters:
str The input string


Generated on Sun Nov 14 15:28:24 2004 for clens by doxygen 1.3.6