include/billigertelefonieren.h File Reference

main include file More...

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <netdb.h>
#include <time.h>

Include dependency graph for billigertelefonieren.h:

This graph shows which files directly or indirectly include this file:


Functions

size_t calculatePrefixSettingsLength (char *providers[PR_TYPES+1], int crlf)
 calculate the length for the prefix settings
int createPrefixSettings (char *providers[PR_TYPES+1], char *contents, int crlf)
 create prefix settings generated from the providers
int getAndUpdatePrefixGroups (struct sockaddr_in *serveraddr, char *providers[PR_TYPES+1], int bVerbose)
 find out which prefix groups are defined and redefine them
int loginOnBox (struct sockaddr_in *serveraddr)
 send the password to the fritz box since we want to login
int postSettingsToWebcm (struct sockaddr_in *serveraddr, char *providers[PR_TYPES+1])
 pass providers to webcm via a HTTP POST request
int runWebcmWithSettings (int function, char *url, char *contents, char *bigbuffer)
 pass providers to webcm via a pipe (emulates a HTTP request)
int secondsUntilNextFullHour (int *bMidnight)
 determine amount of seconds until the next full hour
int numberLength (int number)
 find out how long an integer would be in characters
int numberLengthTime (time_t number)
 find out how long an time_t would be in characters
unsigned int parseCount (char *string)
 how many elements do we have in a comma seperated list?
int parseCSLintoARRAY (char *string, PREFIXARRAY *array, int type)
 parse a comma seperated list into an array
int power (int base, unsigned int exponent)
 calculate the power of a base and a positive exponent
int todayIsHoliday ()
 find out if today is a holiday or a saturday
int httpInitialise (struct sockaddr_in *serveraddr, int purpose)
 initialise http transfer
int httpRequest (struct sockaddr_in *serveraddr, int function, char *url, char *contents, char *bigbuffer)
 download a page
int main (int argc, char **argv)
 main application function
int update (UPASS *ua)
 complete update procedure
int collectProviders (int *preselection, PROVIDERARRAY *providers, char *bigbuffer, int *count, int *length)
 download provider overview and collect provider ids.
int readRateInformation (int type, int weekend, char *providers[PR_TYPES-1])
 read rate information from config file
int updateRateInformation (struct sockaddr_in *serveraddr, int type, int weekend, int preselection, PROVIDERARRAY *providerids, int count, int length, char *providers[PR_TYPES-1], int bVerbose)
 get rate information and save it into a config file

Detailed Description

main include file

contains all function prototypes, macros and structures (c) 2005-2007 Markus Drescher last change: 28.11.07

---------------------------------------------------------------------------- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ----------------------------------------------------------------------------


Function Documentation

size_t calculatePrefixSettingsLength ( char *  providers[PR_TYPES+1],
int  crlf 
)

calculate the length for the prefix settings

calculatePrefixSettingsLength

Parameters:
providers the providers to use at the current time
crlf use (cr)lf
Returns:
length needed

int collectProviders ( int *  preselection,
PROVIDERARRAY *  providers,
char *  bigbuffer,
int *  count,
int *  length 
)

download provider overview and collect provider ids.

collectProviders

Parameters:
preselection pointer to an integer that will be filled with the preselection id
providers pointer to an PROVIDERARRAY struct that will be filled with the provider ids
bigbuffer result from httpRequest
count pointer to an integer that will contain the count of providers
length pointer to an integer that will contain the total length of provider ids
Returns:
-1 on failure, 0 if successful

int createPrefixSettings ( char *  providers[PR_TYPES+1],
char *  contents,
int  crlf 
)

create prefix settings generated from the providers

createPrefixSettings

Parameters:
providers the providers to use at the current time
contents result, the settings to be sent
crlf use (cr)lf
Returns:
FR_CP_ERR_SUCCESS, ...

int getAndUpdatePrefixGroups ( struct sockaddr_in *  serveraddr,
char *  providers[PR_TYPES+1],
int  bVerbose 
)

find out which prefix groups are defined and redefine them

getAndUpdatePrefixGroups

Parameters:
serveraddr internet address of the fritz box
providers the providers for the prefix groups
bVerbose be verbose in this function (printf!)
Returns:
FR_GU_ERR_SUCCESS, ...
Todo:
use local pipe access to webcm

int httpInitialise ( struct sockaddr_in *  serveraddr,
int  purpose 
)

initialise http transfer

httpInitialise

Parameters:
*serveraddr server address
purpose BT_GETRATES or FB_STOREPREFIXES
Returns:
0 for success, -1 on error

int httpRequest ( struct sockaddr_in *  serveraddr,
int  function,
char *  url,
char *  contents,
char *  bigbuffer 
)

download a page

httpRequest

Parameters:
serveraddr pointer to the server address
function what should we do?
url url to download, only needed for BT_GETRATES
contents contents to post, only needed for FB_STOREPREFIXES
bigbuffer result
Returns:
0 for success, -1 on error

int loginOnBox ( struct sockaddr_in *  serveraddr  ) 

send the password to the fritz box since we want to login

loginOnBox

Parameters:
serveraddr internet address of the fritz box
Returns:
FR_LI_ERR_SUCCESS, ...
Todo:
use local pipe access to webcm, check if password was valid.

int main ( int  argc,
char **  argv 
)

main application function

main

Parameters:
argc command line argument count
argv command line arguments
Returns:
0 on success, 1 on error

int numberLength ( int  number  ) 

find out how long an integer would be in characters

numberLength

Parameters:
number our integer to check
Returns:
length of the number

int numberLengthTime ( time_t  number  ) 

find out how long an time_t would be in characters

numberLengthTime

Parameters:
number our unsigned integer to check
Returns:
length of the number

unsigned int parseCount ( char *  string  ) 

how many elements do we have in a comma seperated list?

parseCount

Parameters:
string string to check for commas
Returns:
count of elements

int parseCSLintoARRAY ( char *  string,
PREFIXARRAY *  array,
int  type 
)

parse a comma seperated list into an array

parseCSLintoARRAY

Parameters:
string string to parse
array the array to be used for parsing
type provider type
Returns:
-1 for failure, else: count of array elements

int postSettingsToWebcm ( struct sockaddr_in *  serveraddr,
char *  providers[PR_TYPES+1] 
)

pass providers to webcm via a HTTP POST request

postSettingsToWebcm

Parameters:
serveraddr the address of our fritz box
providers the providers to use at the current time
Returns:
FR_PS_ERR_SUCCESS, ...

int power ( int  base,
unsigned int  exponent 
)

calculate the power of a base and a positive exponent

power

Parameters:
base 
exponent 
Returns:
result

int readRateInformation ( int  type,
int  weekend,
char *  providers[PR_TYPES-1] 
)

read rate information from config file

readRateInformation

Parameters:
type which rates should be read
weekend TRUE: rates for weekend
providers the providers for the current time
Returns:
PR_RR_ERR_SUCCESS on success
Todo:
include costs as well

int runWebcmWithSettings ( int  function,
char *  url,
char *  contents,
char *  bigbuffer 
)

pass providers to webcm via a pipe (emulates a HTTP request)

runWebcmWithSettings

Parameters:
function what should we do?
url url to download
contents contents to post
bigbuffer result
Returns:
0 for success, -1 for ...

int secondsUntilNextFullHour ( int *  bMidnight  ) 

determine amount of seconds until the next full hour

secondsUntilNextFullHour

Parameters:
bMidnight out: will be returned if next hour is midnight or not
Returns:
seconds

int todayIsHoliday (  ) 

find out if today is a holiday or a saturday

todayIsHoliday

Returns:
TRUE if today is a holiday/saturday, FALSE if not

int update ( UPASS *  ua  ) 

complete update procedure

update

Parameters:
ua update assignment struct
Returns:
0 on success, -1 for failure

int updateRateInformation ( struct sockaddr_in *  serveraddr,
int  type,
int  weekend,
int  preselection,
PROVIDERARRAY *  providerids,
int  count,
int  length,
char *  providers[PR_TYPES-1],
int  bVerbose 
)

get rate information and save it into a config file

updateRateInformation

Parameters:
serveraddr internet address of billigertelefonieren
type which rates should be updated
weekend TRUE: rates for weekend
preselection the preselected preselection rate
providerids pointer to an providerarray containing provider ids
count provider count
length total length of the provider ids
providers the wanted providers
bVerbose be verbose
Returns:
PR_UR_ERR_SUCCESS on success, errors see billigertelefonieren.h
Todo:
include costs as well

SourceForge.net Logo