auto commit 1
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
auto-commit.txt
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#include <jansson.h>
|
||||||
|
|
||||||
int fetch_neocities_info() {
|
int fetch_neocities_info() {
|
||||||
const char *user = getenv("NEOCITIES_USER");
|
const char *user = getenv("NEOCITIES_USER");
|
||||||
const char *pass = getenv("NEOCITIES_PASS");
|
const char *pass = getenv("NEOCITIES_PASS");
|
||||||
|
const char *enc = getenv("NEOCITIES_PASS_ENC");
|
||||||
if (!user || !pass) {
|
if (!user || !pass) {
|
||||||
fprintf(stderr, "Variáveis NEOCITIES_USER ou NEOCITIES_PASS não definidas!\n");
|
fprintf(stderr, "You're not logged!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
src/login.sh
16
src/login.sh
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BASHRC="$HOME/.bashrc"
|
||||||
|
|
||||||
|
read -p "Username: " NEOCITIES_USER
|
||||||
|
read -p "Password: " NEOCITIES_PASS
|
||||||
|
|
||||||
|
# Remove linhas existentes se houver
|
||||||
|
sed -i '/^NEOCITIES_USER=/d' "$BASHRC"
|
||||||
|
sed -i '/^NEOCITIES_PASS=/d' "$BASHRC"
|
||||||
|
|
||||||
|
# Adiciona no final
|
||||||
|
echo "NEOCITIES_USER=\"$NEOCITIES_USER\"" >> "$BASHRC"
|
||||||
|
echo "NEOCITIES_PASS=\"$NEOCITIES_PASS\"" >> "$BASHRC"
|
||||||
|
|
||||||
|
echo "Successfully logged in. Saved on $HOME/.bashrc"
|
||||||
|
|||||||
29
src/main.c
29
src/main.c
@@ -2,7 +2,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <jansson.h>
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
@@ -28,13 +27,31 @@ size_t write_callback(void *data, size_t size, size_t nmemb, void *userdata) {
|
|||||||
return chunk_size;
|
return chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
typedef int (*cmd_func_t)(void);
|
||||||
printf("\nNeocities C CLI\n");
|
|
||||||
|
|
||||||
if (argc < 2 || strcmp(argv[1], "--info") != 0) {
|
typedef struct {
|
||||||
printf("\nnothing to do.\n");
|
const char *name;
|
||||||
|
cmd_func_t func;
|
||||||
|
} command_entry;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
command_entry commands[] = {
|
||||||
|
{"--info", fetch_neocities_info},
|
||||||
|
{"--upload", upload_func}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("No command provided.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetch_neocities_info();
|
for (size_t i = 0; i < sizeof(commands)/sizeof(commands[0]); i++) {
|
||||||
|
if (strcmp(argv[1], commands[i].name) == 0) {
|
||||||
|
return commands[i].func();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Unknown command.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,16 @@
|
|||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
|
#include <stddef.h> // para size_t
|
||||||
|
|
||||||
extern const char *user;
|
extern const char *user;
|
||||||
extern const char *pass;
|
extern const char *pass;
|
||||||
|
|
||||||
|
struct response {
|
||||||
|
char *data;
|
||||||
|
size_t len;
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t write_callback(void *ptr, size_t size, size_t nmemb, void *userdata);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user