Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 1f2e8284 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

here is the updator.out

parent ae5a44b2
Branches
Étiquettes
1 requête de fusion!6Resolve "Liste des commandes"
......@@ -5,13 +5,15 @@ LDFLAGS = `pkg-config --libs mpv` -pthread -ldl
EXE = bin/player.out
CLIENT = bin/client.out
UPDATOR = bin/update.out
FILES = socket.c mpv.c thread_pool.c server.c database.c sqlite3.c db/utils.c db/update.c
OBJ = $(FILES:%.c=obj/%.o)
SRC = $(FILES:%.c=src/%.c)
all: prepare $(EXE) $(CLIENT)
all: prepare $(EXE) $(CLIENT) $(UPDATOR)
prepare:
......@@ -44,4 +46,8 @@ $(CLIENT): $(OBJ) obj/client_main.o
$(CC) -o $@ obj/client_main.o obj/socket.o $(LDFLAGS)
$(UPDATOR): $(OBJ) obj/db/update_main.o
$(CC) -o $@ obj/db/update_main.o obj/db/update.o obj/db/utils.o obj/sqlite3.o $(LDFLAGS)
.PHONY: clean style prepare
#include "db/update.h"
#include "sqlite3.h"
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
int main(int argc, char ** argv)
{
struct stat path_stat;
if (argc != 2)
{ return 1; }
char * arg1 = argv[1];
char * arg2 = argv[2];
size_t len1 = strlen(arg1);
size_t len2 = strlen(arg2);
/* Get the sqlite database */
if ((len1 - 5 > 0) && strncmp(arg1 + (len1 - 5), ".sqlt", 5) == 0)
{
stat(arg1, &path_stat);
if (! S_ISREG(path_stat.st_mode))
{ return 10; }
}
/* Get the root of the kara base, can't be `/` */
if (len2 < 2)
{ return 21; }
stat(arg2, &path_stat);
if (! S_ISDIR(path_stat.st_mode))
{ return 20; }
/* Open the sqlite database */
sqlite3 * db = NULL;
if ( sqlite3_open(arg1, &db) )
{ return 50; }
int sta = lektor_db_update(db, arg2);
if (sta != 0)
{ return 60; }
sqlite3_close(db);
return 0;
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter