#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>


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   | |
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. ----------------------------------------------------------------------------
| size_t calculatePrefixSettingsLength | ( | char * | providers[PR_TYPES+1], | |
| int | crlf | |||
| ) | 
calculate the length for the prefix settings
calculatePrefixSettingsLength
| providers | the providers to use at the current time | |
| crlf | use (cr)lf | 
| int collectProviders | ( | int * | preselection, | |
| PROVIDERARRAY * | providers, | |||
| char * | bigbuffer, | |||
| int * | count, | |||
| int * | length | |||
| ) | 
download provider overview and collect provider ids.
collectProviders
| 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 | 
| int createPrefixSettings | ( | char * | providers[PR_TYPES+1], | |
| char * | contents, | |||
| int | crlf | |||
| ) | 
create prefix settings generated from the providers
createPrefixSettings
| providers | the providers to use at the current time | |
| contents | result, the settings to be sent | |
| crlf | use (cr)lf | 
| int getAndUpdatePrefixGroups | ( | struct sockaddr_in * | serveraddr, | |
| char * | providers[PR_TYPES+1], | |||
| int | bVerbose | |||
| ) | 
find out which prefix groups are defined and redefine them
getAndUpdatePrefixGroups
| serveraddr | internet address of the fritz box | |
| providers | the providers for the prefix groups | |
| bVerbose | be verbose in this function (printf!) | 
| int httpInitialise | ( | struct sockaddr_in * | serveraddr, | |
| int | purpose | |||
| ) | 
initialise http transfer
httpInitialise
| *serveraddr | server address | |
| purpose | BT_GETRATES or FB_STOREPREFIXES | 
| int httpRequest | ( | struct sockaddr_in * | serveraddr, | |
| int | function, | |||
| char * | url, | |||
| char * | contents, | |||
| char * | bigbuffer | |||
| ) | 
download a page
httpRequest
| 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 | 
| int loginOnBox | ( | struct sockaddr_in * | serveraddr | ) | 
send the password to the fritz box since we want to login
loginOnBox
| serveraddr | internet address of the fritz box | 
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) | 
main application function
main
| argc | command line argument count | |
| argv | command line arguments | 
| int numberLength | ( | int | number | ) | 
find out how long an integer would be in characters
numberLength
| number | our integer to check | 
| int numberLengthTime | ( | time_t | number | ) | 
find out how long an time_t would be in characters
numberLengthTime
| number | our unsigned integer to check | 
| unsigned int parseCount | ( | char * | string | ) | 
how many elements do we have in a comma seperated list?
parseCount
| string | string to check for commas | 
| int parseCSLintoARRAY | ( | char * | string, | |
| PREFIXARRAY * | array, | |||
| int | type | |||
| ) | 
parse a comma seperated list into an array
parseCSLintoARRAY
| string | string to parse | |
| array | the array to be used for parsing | |
| type | provider type | 
| int postSettingsToWebcm | ( | struct sockaddr_in * | serveraddr, | |
| char * | providers[PR_TYPES+1] | |||
| ) | 
pass providers to webcm via a HTTP POST request
postSettingsToWebcm
| serveraddr | the address of our fritz box | |
| providers | the providers to use at the current time | 
| int power | ( | int | base, | |
| unsigned int | exponent | |||
| ) | 
calculate the power of a base and a positive exponent
power
| base | ||
| exponent | 
| int readRateInformation | ( | int | type, | |
| int | weekend, | |||
| char * | providers[PR_TYPES-1] | |||
| ) | 
read rate information from config file
readRateInformation
| type | which rates should be read | |
| weekend | TRUE: rates for weekend | |
| providers | the providers for the current time | 
| int runWebcmWithSettings | ( | int | function, | |
| char * | url, | |||
| char * | contents, | |||
| char * | bigbuffer | |||
| ) | 
pass providers to webcm via a pipe (emulates a HTTP request)
runWebcmWithSettings
| function | what should we do? | |
| url | url to download | |
| contents | contents to post | |
| bigbuffer | result | 
| int secondsUntilNextFullHour | ( | int * | bMidnight | ) | 
determine amount of seconds until the next full hour
secondsUntilNextFullHour
| bMidnight | out: will be returned if next hour is midnight or not | 
| int todayIsHoliday | ( | ) | 
find out if today is a holiday or a saturday
todayIsHoliday
| int update | ( | UPASS * | ua | ) | 
complete update procedure
update
| ua | update assignment struct | 
| 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
| 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 |