mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-27 17:43:38 +00:00
Most CSV import code has been moved to their own functions.
This commit is contained in:
parent
f549af8005
commit
2eff3ffb66
2 changed files with 34 additions and 6 deletions
4
snac.h
4
snac.h
|
@ -404,6 +404,10 @@ void verify_links(snac *user);
|
||||||
|
|
||||||
void export_csv(snac *user);
|
void export_csv(snac *user);
|
||||||
int migrate_account(snac *user);
|
int migrate_account(snac *user);
|
||||||
|
|
||||||
|
void import_blocked_accounts_csv(snac *user, const char *fn);
|
||||||
|
void import_following_accounts_csv(snac *user, const char *fn);
|
||||||
|
void import_list_csv(snac *user, const char *fn);
|
||||||
void import_csv(snac *user);
|
void import_csv(snac *user);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
36
utils.c
36
utils.c
|
@ -670,13 +670,11 @@ void export_csv(snac *user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void import_csv(snac *user)
|
void import_blocked_accounts_csv(snac *user, const char *fn)
|
||||||
/* import CSV files from Mastodon */
|
/* imports a Mastodon CSV file of blocked accounts */
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
const char *fn;
|
|
||||||
|
|
||||||
fn = "blocked_accounts.csv";
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
snac_log(user, xs_fmt("Importing from %s...", fn));
|
snac_log(user, xs_fmt("Importing from %s...", fn));
|
||||||
|
|
||||||
|
@ -704,8 +702,14 @@ void import_csv(snac *user)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snac_log(user, xs_fmt("Cannot open file %s", fn));
|
snac_log(user, xs_fmt("Cannot open file %s", fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void import_following_accounts_csv(snac *user, const char *fn)
|
||||||
|
/* imports a Mastodon CSV file of accounts to follow */
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
fn = "following_accounts.csv";
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
snac_log(user, xs_fmt("Importing from %s...", fn));
|
snac_log(user, xs_fmt("Importing from %s...", fn));
|
||||||
|
|
||||||
|
@ -757,8 +761,14 @@ void import_csv(snac *user)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snac_log(user, xs_fmt("Cannot open file %s", fn));
|
snac_log(user, xs_fmt("Cannot open file %s", fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void import_list_csv(snac *user, const char *fn)
|
||||||
|
/* imports a Mastodon CSV file list */
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
fn = "lists.csv";
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
snac_log(user, xs_fmt("Importing from %s...", fn));
|
snac_log(user, xs_fmt("Importing from %s...", fn));
|
||||||
|
|
||||||
|
@ -808,6 +818,20 @@ void import_csv(snac *user)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snac_log(user, xs_fmt("Cannot open file %s", fn));
|
snac_log(user, xs_fmt("Cannot open file %s", fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void import_csv(snac *user)
|
||||||
|
/* import CSV files from Mastodon */
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
const char *fn;
|
||||||
|
|
||||||
|
import_blocked_accounts_csv(user, "blocked_accounts.csv");
|
||||||
|
|
||||||
|
import_following_accounts_csv(user, "following_accounts.csv");
|
||||||
|
|
||||||
|
import_list_csv(user, "lists.csv");
|
||||||
|
|
||||||
fn = "bookmarks.csv";
|
fn = "bookmarks.csv";
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
|
|
Loading…
Reference in a new issue