Commit 00b3735e authored by denis's avatar denis

switched compiler to C99, code cleanup (-Wall -pedantic -Wextra) :))

parent ac269e0f
Pipeline #1736460 skipped
......@@ -8,4 +8,4 @@ DB_PASSWORD=slayer1
DB_NAME= dvd_archiv
# Ichimoku analysis related settings
ICHI_DAYS_TO_ANALYZE=20
ICHI_DAYS_TO_ANALYZE=10
CC = gcc
CC = c99
SRCPATH = $(wildcard src/*.c)
OBJPATH = $(addprefix build/,$(notdir $(SRCPATH:.c=.o)))
INCLUDES = -I/usr/include/mysql
LIBS = -L/usr/lib/mysql -lmysqlclient -lm
CFLAGS = -lm -Wall -O2 -L/usr/lib/mysql/ -lmysqlclient
CFLAGS = -lm -Wall -O2 -L/usr/lib/mysql/ -lmysqlclient -pedantic -Wextra
all:ichinscratchy
......@@ -11,7 +11,7 @@ ichinscratchy: $(OBJPATH)
$(CC) -o $@ $^ $(LIBS)
build/%.o: src/%.c
$(CC) -c $(INCLUDES) -o $@ $<
$(CC) $(CFLAGS) -c $(INCLUDES) -o $@ $<
clean:
rm -f $(OBJPATH)
......
......@@ -43,7 +43,7 @@ void print_2d_array(float** p, int N, int M) {
for(i = 0 ; i < N ; i++)
{
for(j = 0 ; j < M ; j++)
printf("| %f |", i, j, p[i][j]);
printf("| %f |", p[i][j]);
printf("\n");
}
}
......@@ -46,7 +46,7 @@ void connect_mysql_database(char *host, char *username, char *password, char *db
long unsigned int *flags_i=NULL;
/* typecast pointers */
port_i = (int *) port;
port_i = (unsigned int *) port;
flags_i = (long unsigned int *) flags;
/* make sure import of local csv files is allowed, done via
......@@ -84,7 +84,7 @@ void close_mysql_connection()
// ToDo: Error handling!
void mysql_getquotes(char *symbol, char *nr_days, float **res)
{
unsigned long row_nr=0, rows=0;
unsigned long row_nr=0;
MYSQL_ROW row;
MYSQL_RES *result;
......@@ -93,7 +93,8 @@ void mysql_getquotes(char *symbol, char *nr_days, float **res)
/* prepare statement in query:
SELECT open,high,low,close FROM (SELECT * FROM quotes_daily
WHERE symbol='XYZ' ORDER BY date DESC LIMIT xy)
sub ORDER BY date ASC
sub ORDER BY date ASC
*/
/* first part of query statement*/
char *select1 ="SELECT open,high,low,close FROM (SELECT * from quotes_daily WHERE symbol='";
......@@ -183,7 +184,6 @@ void mysql_getquotes(char *symbol, char *nr_days, float **res)
void mysql_updatequotes(char *symbol)
{
char *query1, *query2, *tmp, *string1;
MYSQL_RES *result;
/* First delete last 2 database entries
useful if data is pulled in more than once a day, in this case
......
......@@ -16,13 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#define malloc(size) \
//malloc(size);\
//if( (size) = NULL)\
//{\
//fprintf(stdout, "Out of memory!\n");\
//return;\
//}
void check_mysql_error();
void connect_mysql_database(char *host, char *username, char *password, char *dbname, char *port, char *socket, char *flags);
void close_mysql_connection();
......
......@@ -25,12 +25,10 @@
#include "arrays.h"
int main (int argc, char *argv[]) {
int main ()
{
struct parameters parms;
char *result;
float **daily_quotes;
int i=0;
init_parameters (&parms);
fprintf (stdout, "Reading config file...");
......@@ -51,7 +49,7 @@ int main (int argc, char *argv[]) {
/* convert int ICHI_DAYS_TO_ANALYZE to string
(mysql_query in mysql_getquotes expects string) */
char daystr[0];
char daystr[1];
sprintf(daystr, "%d", parms.ICHI_DAYS_TO_ANALYZE);
/* create 2d array to store quotes */
......@@ -64,7 +62,7 @@ int main (int argc, char *argv[]) {
/* Query database for last quotes */
fprintf(stdout,"Querying...");
mysql_getquotes("DOW", daystr, daily_quotes);
mysql_getquotes("DOW", daystr, daily_quotes); // ToDo: Error handling!
fprintf(stdout, "done!\n");
/* display result (quote matrix) */
......
......@@ -19,6 +19,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment