Browse Source

Remove the list_authorities function

Use the newly-added get_supports function to obtain a list of
available supports, then print them to stdout from the main program.
master
Damien Goutte-Gattat 5 years ago
parent
commit
a7b97f0efe
  1. 15
      src/gfsec-split.c
  2. 6
      src/scheme-file.c
  3. 4
      src/scheme-file.h
  4. 34
      src/scheme-gio.c
  5. 4
      src/scheme-gio.h
  6. 25
      src/scheme-libmtp.c
  7. 4
      src/scheme-libmtp.h
  8. 22
      src/scheme-module.c
  9. 4
      src/scheme-module.h

15
src/gfsec-split.c

@ -181,7 +181,20 @@ main(int argc, char **argv)
gfsec_scheme_module_init();
if ( list_mode ) {
gfsec_scheme_module_list_authorities(stdout);
gfsec_supports_list_t *list;
char *schemes[] = { "file", "uuid", "label", "mtp" };
int i;
list = gfsec_scheme_module_get_supports();
for ( i = 0; i < list->count; i++ ) {
printf("%s://%s/ %s\n",
schemes[list->supports[i].scheme],
list->supports[i].authority,
list->supports[i].description);
}
gfsec_support_destroy_list(list);
exit(EXIT_SUCCESS);
}

6
src/scheme-file.c

@ -71,12 +71,6 @@ gfsec_scheme_file_put_file(gfsec_scheme_t scheme,
return GFSEC_SCHEME_STATUS_ERROR;
}
void
gfsec_scheme_file_lst_auth(FILE *f)
{
fprintf(f, "file:// Local filesystem\n");
}
int
gfsec_scheme_file_get_supports(gfsec_supports_list_t *list)
{

4
src/scheme-file.h

@ -19,7 +19,6 @@
#ifndef ICP20160821_SCHEME_FILE_H
#define ICP20160821_SCHEME_FILE_H
#include <stdio.h>
#include "schemes.h"
#include "support.h"
@ -41,9 +40,6 @@ gfsec_scheme_file_put_file(gfsec_scheme_t,
unsigned char *,
size_t);
void
gfsec_scheme_file_lst_auth(FILE *);
int
gfsec_scheme_file_get_supports(gfsec_supports_list_t *);

34
src/scheme-gio.c

@ -293,40 +293,6 @@ gfsec_scheme_gio_put_file(gfsec_scheme_t scheme,
return rc;
}
void
gfsec_scheme_gio_lst_auth(FILE *f)
{
GVolumeMonitor *volmon;
GList *volumes, *l;
volmon = g_volume_monitor_get();
volumes = g_volume_monitor_get_volumes(volmon);
for ( l = volumes; l != NULL; l = l->next ) {
char *label, *uuid;
GVolume *volume;
volume = G_VOLUME(l->data);
label = g_volume_get_name(volume);
uuid = g_volume_get_uuid(volume);
if ( label ) {
fprintf(f, "label://%s GIO volume\n", label);
free(label);
}
if ( uuid ) {
fprintf(f, "uuid://%s GIO volume\n", uuid);
free(uuid);
}
g_object_unref(l->data);
}
g_list_free(volumes);
g_object_unref(volmon);
}
int
gfsec_scheme_gio_get_supports(gfsec_supports_list_t *list)
{

4
src/scheme-gio.h

@ -19,7 +19,6 @@
#ifndef ICP20160207_SCHEME_GIO_H
#define ICP20160207_SCHEME_GIO_H
#include <stdio.h>
#include "schemes.h"
#include "support.h"
@ -41,9 +40,6 @@ gfsec_scheme_gio_put_file(gfsec_scheme_t,
unsigned char *,
size_t);
void
gfsec_scheme_gio_lst_auth(FILE *);
int
gfsec_scheme_gio_get_supports(gfsec_supports_list_t *);

25
src/scheme-libmtp.c

@ -387,31 +387,6 @@ gfsec_scheme_libmtp_put_file(gfsec_scheme_t scheme,
return rc;
}
void
gfsec_scheme_libmtp_lst_auth(FILE *f)
{
LIBMTP_raw_device_t *raw_devices;
LIBMTP_mtpdevice_t *device;
int i, n;
if ( LIBMTP_Detect_Raw_Devices(&raw_devices, &n) != 0 )
return;
for ( i = 0, device = NULL; i < n && device == NULL; i++ ) {
char *serial, *name;
device = LIBMTP_Open_Raw_Device_Uncached(&(raw_devices[i]));
serial = LIBMTP_Get_Serialnumber(device);
name = LIBMTP_Get_Friendlyname(device);
fprintf(f, "mtp://%s %s\n", serial, name);
free(serial);
free(name);
LIBMTP_Release_Device(device);
}
}
int
gfsec_scheme_libmtp_get_supports(gfsec_supports_list_t *list)
{

4
src/scheme-libmtp.h

@ -19,7 +19,6 @@
#ifndef ICP20160207_SCHEME_LIBMTP_H
#define ICP20160207_SCHEME_LIBMTP_H
#include <stdio.h>
#include "schemes.h"
#include "support.h"
@ -41,9 +40,6 @@ gfsec_scheme_libmtp_put_file(gfsec_scheme_t,
unsigned char *,
size_t);
void
gfsec_scheme_libmtp_lst_auth(FILE *);
int
gfsec_scheme_libmtp_get_supports(gfsec_supports_list_t *);

22
src/scheme-module.c

@ -41,15 +41,12 @@ typedef int (*fn_put_file)(gfsec_scheme_t,
unsigned char *,
size_t);
typedef void (*fn_lst_auth)(FILE *);
typedef int (*fn_get_supp)(gfsec_supports_list_t *);
typedef struct module {
int present;
fn_get_file get_file;
fn_put_file put_file;
fn_lst_auth lst_auth;
fn_get_supp get_supp;
} module_t;
@ -68,7 +65,6 @@ gfsec_scheme_module_init(void)
mods[n].get_file = gfsec_scheme_file_get_file;
mods[n].put_file = gfsec_scheme_file_put_file;
mods[n].lst_auth = gfsec_scheme_file_lst_auth;
mods[n].get_supp = gfsec_scheme_file_get_supports;
mods[n++].present = 1;
@ -76,7 +72,6 @@ gfsec_scheme_module_init(void)
LIBMTP_Init();
mods[n].get_file = gfsec_scheme_libmtp_get_file;
mods[n].put_file = gfsec_scheme_libmtp_put_file;
mods[n].lst_auth = gfsec_scheme_libmtp_lst_auth;
mods[n].get_supp = gfsec_scheme_libmtp_get_supports;
mods[n++].present = 1;
#endif
@ -84,7 +79,6 @@ gfsec_scheme_module_init(void)
#ifdef HAVE_GIO
mods[n].get_file = gfsec_scheme_gio_get_file;
mods[n].put_file = gfsec_scheme_gio_put_file;
mods[n].lst_auth = gfsec_scheme_gio_lst_auth;
mods[n].get_supp = gfsec_scheme_gio_get_supports;
mods[n++].present = 1;
#endif
@ -172,22 +166,6 @@ gfsec_scheme_module_put_file(gfsec_scheme_t scheme,
return rc;
}
/**
* List currently available authorities reported by all modules.
*
* @param f The stream to write into.
*/
void
gfsec_scheme_module_list_authorities(FILE *f)
{
module_t *mod;
for ( mod = modules; mod->present; mod++ ) {
if ( mod->lst_auth )
mod->lst_auth(f);
}
}
/**
* Get a list of currently available supports.
*

4
src/scheme-module.h

@ -20,7 +20,6 @@
#define ICP20160820_SCHEME_MODULE_H
#include <stdlib.h>
#include <stdio.h>
#include "schemes.h"
#include "support.h"
@ -52,9 +51,6 @@ gfsec_scheme_module_put_file(gfsec_scheme_t,
unsigned char *,
size_t);
void
gfsec_scheme_module_list_authorities(FILE *);
gfsec_supports_list_t *
gfsec_scheme_module_get_supports(void);

Loading…
Cancel
Save