Browse Source

comentários agent

dev
Rodgger 2 years ago
parent
commit
6ab110a9c6
  1. 51
      src/agent/agent_db.c

51
src/agent/agent_db.c

@ -1,20 +1,18 @@
/***
* _____ _ _ _____
* / ____(_) | | |_ _|
* | (___ _ _ __ ___ _ __ | | ___ ___ | | _ __
* \___ \| | '_ ` _ \| '_ \| |/ _ \/ __| | | | '_ \
* ____) | | | | | | | |_) | | __/\__ \ _| |_| |_) |
* |_____/|_|_| |_| |_| .__/|_|\___||___/ |_____| .__/
* | \/ | | | | |
* | \ / | __ _ _ __ |_|_ _ __ _ ___ _ __ |_|
* | |\/| |/ _` | '_ \ / _` |/ _` |/ _ \ '__|
* | | | | (_| | | | | (_| | (_| | __/ |
* |_| |_|\__,_|_| |_|\__,_|\__, |\___|_|
* __/ |
* |___/
*
* .----------------. .----------------. .----------------. .----------------.
* | .--------------. || .--------------. || .--------------. || .--------------. |
* | | __ | || | ____ ____ | || | _____ | || | ________ | |
* | | / \ | || ||_ \ / _|| || | |_ _| | || | |_ ___ `. | |
* | | / /\ \ | || | | \/ | | || | | | | || | | | `. \ | |
* | | / ____ \ | || | | |\ /| | | || | | | | || | | | | | | |
* | | _/ / \ \_ | || | _| |_\/_| |_ | || | _| |_ | || | _| |___.' / | |
* | ||____| |____|| || ||_____||_____|| || | |_____| | || | |________.' | |
* | | | || | | || | | || | | |
* | '--------------' || '--------------' || '--------------' || '--------------' |
* '----------------' '----------------' '----------------' '----------------'
*
* Copyright (C) 2022 Simples IP.
* Author: dgger Bruno <rodgger.silva@simplesip.com>
* Maintainers: Rodgger Bruno <rodgger.silva@simplesip.com>
*
*/
@ -24,7 +22,7 @@
#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){
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){
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){
MYSQL_STMT *stmt = NULL;
@ -85,7 +86,7 @@ struct s_table_agent *get_agents_all_db(stmt_t type_stmt){
/* column id */
table_agent_next->id = *(unsigned long long *)bind_result[0].buffer;
/* columns status */
/* column matricula */
if(bind_result[1].is_null_value == 0){
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 ){
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;
}
/* columns status */
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 ){
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 ){
MYSQL_STMT *stmt = NULL;
@ -225,6 +234,10 @@ fail:
return -1;
}
/* Deletar agente na tabela agent */
int delete_agents_db(stmt_t type_stmt, unsigned long long int id){
MYSQL_STMT *stmt = NULL;

Loading…
Cancel
Save