GNUnet 0.21.1
gnunet-unindex.c File Reference

unindex files published on GNUnet More...

#include "platform.h"
#include "gnunet_fs_service.h"
Include dependency graph for gnunet-unindex.c:

Go to the source code of this file.

Functions

static void cleanup_task (void *cls)
 
static void shutdown_task (void *cls)
 
static void * progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 Called by FS client to give information about the progress of an operation. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 The main function to unindex content. More...
 

Variables

static int ret
 
static unsigned int verbose
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 
static struct GNUNET_FS_Handlectx
 
static struct GNUNET_FS_UnindexContextuc
 

Detailed Description

unindex files published on GNUnet

Author
Christian Grothoff
Krista Bennett
James Blackwell
Igor Wronsky

Definition in file gnunet-unindex.c.

Function Documentation

◆ cleanup_task()

static void cleanup_task ( void *  cls)
static

Definition at line 44 of file gnunet-unindex.c.

45{
47 ctx = NULL;
48}
static struct GNUNET_FS_Handle * ctx
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
Definition: fs_api.c:3310

References ctx, and GNUNET_FS_stop().

Referenced by progress_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Definition at line 52 of file gnunet-unindex.c.

53{
55
56 if (uc != NULL)
57 {
58 u = uc;
59 uc = NULL;
61 }
62}
static mp_limb_t u[(((256)+GMP_NUMB_BITS - 1)/GMP_NUMB_BITS)]
static struct GNUNET_FS_UnindexContext * uc
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
Definition: fs_unindex.c:838
Handle for controlling an unindexing operation.
Definition: fs_api.h:1351

References GNUNET_FS_unindex_stop(), u, and uc.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ progress_cb()

static void * progress_cb ( void *  cls,
const struct GNUNET_FS_ProgressInfo info 
)
static

Called by FS client to give information about the progress of an operation.

Parameters
clsclosure
infodetails about the event, specifying the event type and various bits about the event
Returns
client-context (for the next progress call for this operation; should be set to NULL for SUSPEND and STOPPED events). The value returned will be passed to future callbacks in the respective field in the GNUNET_FS_ProgressInfo struct.

Definition at line 79 of file gnunet-unindex.c.

80{
81 const char *s;
82
83 switch (info->status)
84 {
86 break;
87
89 if (verbose)
90 {
91 s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta,
93 fprintf (stdout,
94 _ ("Unindexing at %llu/%llu (%s remaining)\n"),
95 (unsigned long long) info->value.unindex.completed,
96 (unsigned long long) info->value.unindex.size,
97 s);
98 }
99 break;
100
102 fprintf (stderr,
103 _ ("Error unindexing: %s.\n"),
104 info->value.unindex.specifics.error.message);
106 break;
107
109 fprintf (stdout, "%s", _ ("Unindexing done.\n"));
111 break;
112
115 break;
116
117 default:
118 fprintf (stderr, _ ("Unexpected status: %d\n"), info->status);
119 break;
120 }
121 return NULL;
122}
#define info
static unsigned int verbose
static void cleanup_task(void *cls)
@ GNUNET_FS_STATUS_UNINDEX_PROGRESS
Notification that we made progress unindexing a file.
@ GNUNET_FS_STATUS_UNINDEX_START
Notification that we started to unindex a file.
@ GNUNET_FS_STATUS_UNINDEX_STOPPED
Notification that the unindexing of this file was stopped (final event for this action).
@ GNUNET_FS_STATUS_UNINDEX_COMPLETED
Notification that the unindexing of this file was completed.
@ GNUNET_FS_STATUS_UNINDEX_ERROR
Notification that we encountered an error unindexing a file.
@ GNUNET_YES
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1305
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:570
#define _(String)
GNU gettext support macro.
Definition: platform.h:178

References _, cleanup_task(), GNUNET_FS_STATUS_UNINDEX_COMPLETED, GNUNET_FS_STATUS_UNINDEX_ERROR, GNUNET_FS_STATUS_UNINDEX_PROGRESS, GNUNET_FS_STATUS_UNINDEX_START, GNUNET_FS_STATUS_UNINDEX_STOPPED, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, info, and verbose.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle c 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cconfiguration

Definition at line 134 of file gnunet-unindex.c.

138{
139 /* check arguments */
140 if ((args[0] == NULL) || (args[1] != NULL))
141 {
142 printf (_ ("You must specify one and only one filename for unindexing.\n"));
143 ret = -1;
144 return;
145 }
146 cfg = c;
148 "gnunet-unindex",
150 NULL,
153 if (NULL == ctx)
154 {
155 fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS");
156 ret = 1;
157 return;
158 }
159 uc = GNUNET_FS_unindex_start (ctx, args[0], NULL);
160 if (NULL == uc)
161 {
162 fprintf (stderr, "%s", _ ("Could not start unindex operation.\n"));
164 return;
165 }
167}
static const struct GNUNET_CONFIGURATION_Handle * cfg
static void shutdown_task(void *cls)
static int ret
static void * progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Called by FS client to give information about the progress of an operation.
struct GNUNET_FS_Handle * GNUNET_FS_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags,...)
Setup a connection to the file-sharing service.
Definition: fs_api.c:3244
struct GNUNET_FS_UnindexContext * GNUNET_FS_unindex_start(struct GNUNET_FS_Handle *h, const char *filename, void *cctx)
Unindex a file.
Definition: fs_unindex.c:796
@ GNUNET_FS_FLAGS_NONE
No special flags set.
@ GNUNET_FS_OPTIONS_END
Last option in the VARARG list.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1340

References _, consensus-simulation::args, cfg, ctx, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END, GNUNET_FS_start(), GNUNET_FS_stop(), GNUNET_FS_unindex_start(), GNUNET_SCHEDULER_add_shutdown(), progress_cb(), ret, shutdown_task(), and uc.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function to unindex content.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 178 of file gnunet-unindex.c.

179{
182
184 };
185
186 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
187 return 2;
188
189 ret = (GNUNET_OK ==
191 argc,
192 argv,
193 "gnunet-unindex [OPTIONS] FILENAME",
195 "Unindex a file that was previously indexed with gnunet-publish."),
196 options,
197 &run,
198 NULL))
199 ? ret
200 : 1;
201 GNUNET_free_nz ((void *) argv);
202 return ret;
203}
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:70
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
@ GNUNET_OK
#define GNUNET_free_nz(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:400
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1230
Definition of a command line option.

References gettext_noop, GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_verbose(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), options, ret, run(), and verbose.

Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Definition at line 32 of file gnunet-unindex.c.

Referenced by main(), and run().

◆ verbose

unsigned int verbose
static

Definition at line 34 of file gnunet-unindex.c.

Referenced by main(), and progress_cb().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Definition at line 36 of file gnunet-unindex.c.

Referenced by run().

◆ ctx

struct GNUNET_FS_Handle* ctx
static

Definition at line 38 of file gnunet-unindex.c.

Referenced by cleanup_task(), and run().

◆ uc