|
|
@ -1,20 +1,18 @@ |
|
|
|
/***
|
|
|
|
/***
|
|
|
|
* _____ _ _ _____
|
|
|
|
* .----------------. .----------------. .----------------. .----------------.
|
|
|
|
* / ____(_) | | |_ _|
|
|
|
|
* | .--------------. || .--------------. || .--------------. || .--------------. | |
|
|
|
* | (___ _ _ __ ___ _ __ | | ___ ___ | | _ __
|
|
|
|
* | | __ | || | ____ ____ | || | _____ | || | ________ | | |
|
|
|
* \___ \| | '_ ` _ \| '_ \| |/ _ \/ __| | | | '_ \
|
|
|
|
* | | / \ | || ||_ \ / _|| || | |_ _| | || | |_ ___ `. | | |
|
|
|
* ____) | | | | | | | |_) | | __/\__ \ _| |_| |_) | |
|
|
|
* | | / /\ \ | || | | \/ | | || | | | | || | | | `. \ | | |
|
|
|
* |_____/|_|_| |_| |_| .__/|_|\___||___/ |_____| .__/
|
|
|
|
* | | / ____ \ | || | | |\ /| | | || | | | | || | | | | | | | |
|
|
|
* | \/ | | | | |
|
|
|
|
* | | _/ / \ \_ | || | _| |_\/_| |_ | || | _| |_ | || | _| |___.' / | | |
|
|
|
* | \ / | __ _ _ __ |_|_ _ __ _ ___ _ __ |_|
|
|
|
|
* | ||____| |____|| || ||_____||_____|| || | |_____| | || | |________.' | | |
|
|
|
* | |\/| |/ _` | '_ \ / _` |/ _` |/ _ \ '__|
|
|
|
|
* | | | || | | || | | || | | | |
|
|
|
* | | | | (_| | | | | (_| | (_| | __/ |
|
|
|
|
* | '--------------' || '--------------' || '--------------' || '--------------' | |
|
|
|
* |_| |_|\__,_|_| |_|\__,_|\__, |\___|_|
|
|
|
|
* '----------------' '----------------' '----------------' '----------------'
|
|
|
|
* __/ |
|
|
|
|
|
|
|
|
* |___/
|
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* Copyright (C) 2022 Simples IP. |
|
|
|
* Copyright (C) 2022 Simples IP. |
|
|
|
* Author: Ródgger Bruno <rodgger.silva@simplesip.com> |
|
|
|
* Maintainers: Rodgger Bruno <rodgger.silva@simplesip.com> |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
@ -24,7 +22,7 @@ |
|
|
|
#include <agent/agent.h> |
|
|
|
#include <agent/agent.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* valores tabela agent */ |
|
|
|
/* Adcionar nova linha no resultado da query */ |
|
|
|
int add_table_agent(struct s_table_agent **A, struct s_table_agent *next){ |
|
|
|
int add_table_agent(struct s_table_agent **A, struct s_table_agent *next){ |
|
|
|
|
|
|
|
|
|
|
|
while(*A){ |
|
|
|
while(*A){ |
|
|
@ -37,7 +35,8 @@ int add_table_agent(struct s_table_agent **A, struct s_table_agent *next){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* liberar ponteiro da tabela */ |
|
|
|
|
|
|
|
|
|
|
|
/* Liberar os resultados da query */ |
|
|
|
int free_table_agent(struct s_table_agent *A){ |
|
|
|
int free_table_agent(struct s_table_agent *A){ |
|
|
|
|
|
|
|
|
|
|
|
if(A == NULL) |
|
|
|
if(A == NULL) |
|
|
@ -54,6 +53,8 @@ int free_table_agent(struct s_table_agent *A){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* obter todos os agentes no banco de dados */ |
|
|
|
struct s_table_agent *get_agents_all_db(stmt_t type_stmt){ |
|
|
|
struct s_table_agent *get_agents_all_db(stmt_t type_stmt){ |
|
|
|
|
|
|
|
|
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
@ -85,7 +86,7 @@ struct s_table_agent *get_agents_all_db(stmt_t type_stmt){ |
|
|
|
/* column id */ |
|
|
|
/* column id */ |
|
|
|
table_agent_next->id = *(unsigned long long *)bind_result[0].buffer; |
|
|
|
table_agent_next->id = *(unsigned long long *)bind_result[0].buffer; |
|
|
|
|
|
|
|
|
|
|
|
/* columns status */ |
|
|
|
/* column matricula */ |
|
|
|
if(bind_result[1].is_null_value == 0){ |
|
|
|
if(bind_result[1].is_null_value == 0){ |
|
|
|
newstrncpy(&table_agent_next->matricula, bind_result[1].buffer); |
|
|
|
newstrncpy(&table_agent_next->matricula, bind_result[1].buffer); |
|
|
|
} |
|
|
|
} |
|
|
@ -108,6 +109,9 @@ fail: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Buscar agente de um matrícula no banco de dados */ |
|
|
|
struct s_table_agent *get_agents_db( stmt_t type_stmt, const char *matricula ){ |
|
|
|
struct s_table_agent *get_agents_db( stmt_t type_stmt, const char *matricula ){ |
|
|
|
|
|
|
|
|
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
@ -151,7 +155,6 @@ struct s_table_agent *get_agents_db( stmt_t type_stmt, const char *matricula ){ |
|
|
|
table_agent_next->name = NULL; |
|
|
|
table_agent_next->name = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* columns status */ |
|
|
|
/* columns status */ |
|
|
|
newstrncpy(&table_agent_next->status, bind_result[2].buffer); |
|
|
|
newstrncpy(&table_agent_next->status, bind_result[2].buffer); |
|
|
|
|
|
|
|
|
|
|
@ -171,6 +174,9 @@ fail: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Atualizar dados do agent no banco de dados */ |
|
|
|
int update_agents_db( stmt_t type_stmt, const char *name, const char *status, unsigned long long int id ){ |
|
|
|
int update_agents_db( stmt_t type_stmt, const char *name, const char *status, unsigned long long int id ){ |
|
|
|
|
|
|
|
|
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
@ -199,6 +205,9 @@ fail: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Inseri um novo agente */ |
|
|
|
int insert_agents_db( stmt_t type_stmt, const char *name, const char *matricula, const char *status ){ |
|
|
|
int insert_agents_db( stmt_t type_stmt, const char *name, const char *matricula, const char *status ){ |
|
|
|
|
|
|
|
|
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
@ -225,6 +234,10 @@ fail: |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Deletar agente na tabela agent */ |
|
|
|
int delete_agents_db(stmt_t type_stmt, unsigned long long int id){ |
|
|
|
int delete_agents_db(stmt_t type_stmt, unsigned long long int id){ |
|
|
|
|
|
|
|
|
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
|
MYSQL_STMT *stmt = NULL; |
|
|
|