![]() |
![]() |
![]() |
NNTPGrab Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
NZBCreatorGroup; enum NZBCreatorSearchOnlyIn; NZBCreatorSearchOpts; NZBCreatorFile; NZBCreatorCollection; NZBCreatorSearchResult; #define NG_CALLBACK (f) void (*NGCallback) (void
); #define NGFileMonitor NGList; typedef NGRegex; typedef NGType; void nntpgrab_utils_perform_base_initialization (void
); NGRegex * nntpgrab_utils_regex_compile (const char *regex
); void nntpgrab_utils_regex_free (NGRegex *re
); const char ** nntpgrab_utils_regex_match (NGRegex *re
,const char *line
); void nntpgrab_utils_regex_matches_free (const char **matches
); ngboolean nntpgrab_utils_strip_subject (const char *subject
,char **subject_without_partnum
,int *file_num
,int *total_files
,char **filename
,char **extension
,NNTPFileType *file_type
,int *par2_startnum
,int *num_par2_blocks
,int *part_num
,int *total_parts
); NNTPFileType nntpgrab_utils_get_file_type_of_filename (const char *filename
); void nntpgrab_utils_calculate_file_size (nguint64 file_size
,char *file_size_str
,int file_size_str_len
); int nntpgrab_utils_calculate_estimated_time_remaining (int bytes_received1
,int bytes_received2
,int bytes_received3
,int bytes_received4
,int bytes_received5
,int bytes_received6
,int bytes_received7
,int bytes_received8
,int bytes_received9
,int bytes_received10
,nguint64 file_size
); void nntpgrab_utils_get_readable_time_remaining (int estimated_time_remaining
,char *time_remaining_str
,int time_remaining_str_len
); void nntpgrab_utils_get_readable_finished_time (int estimated_time_remaining
,char *time_remaining_str
,int time_remaining_str_len
); void nntpgrab_utils_sanitize_text (char *text
,int length
); void nntpgrab_utils_strip_nzb_extension (char *filename
); void nntpgrab_utils_sanitize_collection_name (char *collection_name
); ngboolean nntpgrab_utils_extract_par2set_name_from_par2_filename (const char *par2filename
,char *par2set
,int par2set_length
); ngboolean nntpgrab_utils_get_folder_listing (const char *parent
,NGList **folders
); void nntpgrab_utils_free_folder_listing (NGList *folders
); NNTPGrabNZB * nntpgrab_utils_parse_nzb_file (const char *contents
,char **errmsg
); void nntpgrab_utils_nzb_file_free (NNTPGrabNZB *nzbfile
); NGList * nntpgrab_utils_nzbcreator_get_all_groups (char **errmsg
); void nntpgrab_utils_nzbcreator_free_groups (NGList *groups
); NZBCreatorSearchResult * nntpgrab_utils_nzbcreator_perform_search (NZBCreatorSearchOpts opts
,char **errmsg
); void nntpgrab_utils_nzbcreator_free_result (NZBCreatorSearchResult *result
); char * nntpgrab_utils_nzbcreator_generate_NZB (NGList *file_ids
,char **errmsg
); NGFileMonitor * nntpgrab_utils_monitor_directory (const char *path
,char **errmsg
); void nntpgrab_utils_cancel_directory_monitor (NGFileMonitor *monitor
); void ng_free (void *data
); NGList * ng_list_append (NGList *list
,void *data
); NGList * ng_list_prepend (NGList *list
,void *data
); NGList * ng_list_remove (NGList *list
,void *data
); unsigned int ng_list_length (NGList *list
); void ng_list_free (NGList *list
); #define ng_list_previous (list) #define ng_list_next (list) void ng_signal_connect (void *instance
,const char *signal_name
,NGCallback cb_handler
,void *data
); void ng_signal_handlers_disconnect_by_func (void *instance
,NGCallback cb_handler
,void *data
); void ng_signal_handlers_block_by_func (void *instance
,NGCallback cb_handler
,void *data
); void ng_signal_handlers_unblock_by_func (void *instance
,NGCallback cb_handler
,void *data
); void ng_event_handler_loop_run (void
); void ng_event_handler_loop_quit (void
); int ng_event_handler_loop_depth (void
);
typedef enum _nzbcreator_search_only_in { NZBCREATOR_SEARCH_ONLY_IN_SUBJECTS, NZBCREATOR_SEARCH_ONLY_IN_FILENAMES, NZBCREATOR_SEARCH_ONLY_IN_POSTERS } NZBCreatorSearchOnlyIn;
typedef struct { char query[64]; char username[64]; char password[64]; NZBCreatorSearchOnlyIn search_only_in; int max_age; ngint64 minimal_file_size; ngint64 maximal_file_size; int percentage_complete; int group_to_search; NNTPFileType file_type; } NZBCreatorSearchOpts;
The search query | |
The username which will be used to perform the search query (unused in NNTPGrab 0.7) | |
The password which will be used to perform the search query (unused in NNTPGrab 0.7) | |
NZBCreatorSearchOnlyIn |
Indicate what type of data needs to be searched |
The maximum age of search results (in days) | |
The minimum size of files in bytes | |
The maximum size of files in bytes | |
Only return results which are this percentage complete (0 to 100) | |
Limit searching to one specific groups (see the group_id field from NZBCreatorGroup)
|
|
NNTPFileType |
Only search files of this type |
typedef struct { ngint64 file_id; char subject[256]; char poster[256]; int num_parts_found; int num_parts_expected; NNTPFileType file_type; ngint64 file_size; time_t stamp; int complete_percentage; } NZBCreatorFile;
An identifier for this file | |
The subject of this file | |
The poster of this file | |
The number of parts which are found which belong to this file | |
The number of parts which are expected which belong to this file | |
NNTPFileType |
The type of this file |
The size of this file in bytes | |
The stamp of the first part of this file | |
The percentage which indicates how complete this file is |
typedef struct { char collection_name[256]; char short_collection_name[256]; char newsgroup[256]; ngint64 total_file_size; time_t stamp; NGList *files; // List of NZBCreatorFile* instances } NZBCreatorCollection;
The name of the collection (most frequently this is the subject of the first file in the collection) | |
An abbreviated version of collection_name
|
|
The newsgroup in which all the files from this collection are poster | |
The total size in bytes of this collection | |
The stamp of the first part of the first file in this collection | |
NGList * |
A list containing the files belonging to this collection. [element-type NZBCreatorFile] |
typedef struct { int number_of_hits; int number_of_results; NGList *collections; // List of NZBCreatorCollection* instances } NZBCreatorSearchResult;
The number of hits which were found for the given query | |
The number of files which were found and are part of the collections
|
|
NGList * |
A list containing all returned collections. [element-type NZBCreatorCollection] |
void nntpgrab_utils_perform_base_initialization
(void
);
Perform the initialization of the GLib system. Needs to be called before any other NNTPGrab function in non-GLib-based frontends
NGRegex * nntpgrab_utils_regex_compile (const char *regex
);
Compile a regular expression
|
The (perl-compatible) regular expression which needs to be compiled |
Returns : |
A compiled regular expression |
void nntpgrab_utils_regex_free (NGRegex *re
);
Free a compiled regular expression
|
The compiled regular expression |
const char ** nntpgrab_utils_regex_match (NGRegex *re
,const char *line
);
Perform a match against a compiled regular expression
|
The compiled regular expression |
|
The data which need to be matched against the compiled regular expression |
Returns : |
A NULL-terminated array of matches items (needs to be free'd using nntpgrab_utils_regex_matches_free() )
|
void nntpgrab_utils_regex_matches_free (const char **matches
);
Free an array of matched items
ngboolean nntpgrab_utils_strip_subject (const char *subject
,char **subject_without_partnum
,int *file_num
,int *total_files
,char **filename
,char **extension
,NNTPFileType *file_type
,int *par2_startnum
,int *num_par2_blocks
,int *part_num
,int *total_parts
);
Strip a subject into useable pieces of data
All the parameters (except subject) can be NULL to ignore them
All the char* parameters need to be free'd using ng_free()
Returns : |
TRUE is the strip was successfull |
NNTPFileType nntpgrab_utils_get_file_type_of_filename
(const char *filename
);
Find out the file type of a given filename If the file type couldn't be found out, the value NNTP_FILE_TYPE_UNKNOWN will be returned
|
The filename whose file type needs to be found out |
Returns : |
The file type (as an enumeration) |
void nntpgrab_utils_calculate_file_size (nguint64 file_size
,char *file_size_str
,int file_size_str_len
);
Transform a file size into a human readable notation
|
The file size which needs to be transformed |
|
Pointer to the location where the result needs to be saved. [out] |
|
The maximum length of the file_size_str buffer |
int nntpgrab_utils_calculate_estimated_time_remaining (int bytes_received1
,int bytes_received2
,int bytes_received3
,int bytes_received4
,int bytes_received5
,int bytes_received6
,int bytes_received7
,int bytes_received8
,int bytes_received9
,int bytes_received10
,nguint64 file_size
);
Calculate the estimated time remaining to complete the given file size The bytes_received parameters can be retrieved from the signalhandler for the signal "traffic-monitor-update"
|
The number of bytes received in now() - 10
|
|
The number of bytes received in now() - 9
|
|
The number of bytes received in now() - 8
|
|
The number of bytes received in now() - 7
|
|
The number of bytes received in now() - 6
|
|
The number of bytes received in now() - 5
|
|
The number of bytes received in now() - 4
|
|
The number of bytes received in now() - 3
|
|
The number of bytes received in now() - 2
|
|
The number of bytes received in now() - 1
|
|
The file size in bytes |
Returns : |
The number of seconds in which the given file_size can be downloaded
|
void nntpgrab_utils_get_readable_time_remaining (int estimated_time_remaining
,char *time_remaining_str
,int time_remaining_str_len
);
Transform a estimated time remaining into a human readable value for the time remaining
|
The estimated time remaining (in seconds) |
|
Pointer to the location where the human readable notation (like '3 minutes and 10 seconds') can be saved. [out] |
|
The maximum length of the time_remaining_str buffer |
void nntpgrab_utils_get_readable_finished_time (int estimated_time_remaining
,char *time_remaining_str
,int time_remaining_str_len
);
Transform a estimated time remaining into a human readable value for the expected time to finish
|
The estimated time remaining (in seconds) |
|
Pointer to the location where the human readable notation (like 'Friday February 6 2009 - 22:15') can be saved. [out] |
|
The maximum length of the time_remaining_str buffer |
void nntpgrab_utils_sanitize_text (char *text
,int length
);
Check whether the given text contains invalid UTF-8 characters and if they're found, replace them with something more sane
|
The text which need to be sanitized. [inout] |
|
The length of the text |
void nntpgrab_utils_strip_nzb_extension (char *filename
);
Remove the extension from a filename
|
The filename whose extension need to be stripped. [inout] |
void nntpgrab_utils_sanitize_collection_name
(char *collection_name
);
Remove forbidden characters from the collection name
|
The collection name which need to be sanitized. [inout] |
ngboolean nntpgrab_utils_extract_par2set_name_from_par2_filename (const char *par2filename
,char *par2set
,int par2set_length
);
Extract the name of a PAR2 set out of a PAR2 filename
|
The filename of the PAR2 file which needs to be extracted |
|
Pointer to a location where the result can be saved. [out] |
|
Size of the par2set length |
Returns : |
TRUE of success (par2set will be set), FALSE on failure |
ngboolean nntpgrab_utils_get_folder_listing (const char *parent
,NGList **folders
);
Retrieves a list containing all the sub-folders which are in the given folder
|
The name of the directory whose sub-folders should be retrieved. If NULL, all available drives will be returned (when the host is running Windows) |
|
Pointer to a NGList*. The list of sub-folders will be placed in this field. This list needs to be free'd using the function nntpgrab_config_free_folder_listing() . [out][element-type NNTPGrabFolder]
|
Returns : |
TRUE on sucess, FALSE if the given directory isn't found or readable |
void nntpgrab_utils_free_folder_listing (NGList *folders
);
Free a list of sub-folders
|
A list containing subfolders as returned by the function nntpgrab_config_get_folder_listing()
|
NNTPGrabNZB * nntpgrab_utils_parse_nzb_file (const char *contents
,char **errmsg
);
Parse the contents of a NZB file and put the information in a structure
|
The contents of the NZB file |
|
Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree() . Can be NULL to ignore errors. [out][allow-none]
|
Returns : |
A structure containing information about the NZB file. Needs to be free'd using the function nntpgrab_utils_nzb_file_free() . If the value NULL is returned, an error occured and errmsg will be set
|
void nntpgrab_utils_nzb_file_free (NNTPGrabNZB *nzbfile
);
Free a structure containing details about a NZB file
|
The structure containing information about the NZB file |
NGList * nntpgrab_utils_nzbcreator_get_all_groups
(char **errmsg
);
Retrieve a list of all the usenet groups which are indexed by the NZBCreator service
Returns : |
A list of all the indexed usenet groups. Needs to be free'd using nntpgrab_utils_nzbcreator_free_groups() . If an error occures, the value NULL will be returned and errmsg will be set. [element-type NZBCreatorGroup]
|
void nntpgrab_utils_nzbcreator_free_groups
(NGList *groups
);
Free the list of usenet groups which are indexed by the NZBCreator service
|
A list of all the indexed usenet groups |
NZBCreatorSearchResult * nntpgrab_utils_nzbcreator_perform_search (NZBCreatorSearchOpts opts
,char **errmsg
);
Perform a search using the NZBCreator service
|
A structure containing information about the requested search |
|
Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree() . Can be NULL to ignore errors. [allow-none][out]
|
Returns : |
A structure containing the search results. Needs to be free'd using nntpgrab_utils_nzbcreator_free_result() . If an error occurs, the value NULL will be returned and errmsg will be set. [element-type NZBCreatorSearchResults]
|
void nntpgrab_utils_nzbcreator_free_result
(NZBCreatorSearchResult *result
);
Free the NZBCreator search results
|
The NZBCreator search results |
char * nntpgrab_utils_nzbcreator_generate_NZB (NGList *file_ids
,char **errmsg
);
Generate a NZB file based on a list of file ID's
|
A list containing file ID's of all the files which needs to be retrieved. [element-type int] |
|
Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree() . Can be NULL to ignore errors. [allow-none][out]
|
Returns : |
The contents of the NZB file containing all the details of the given file_ids. Needs to be free'd using ng_free() . If an error occurs, the value NULL will be returned and errmsg will be set
|
NGFileMonitor * nntpgrab_utils_monitor_directory (const char *path
,char **errmsg
);
Start the monitoring of a directory
The NGFileMonitor is an GObject where the event 'changed' can be caught using ng_signal_connect()
|
The directory which needs to be monitored for changes |
|
Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree() . Can be NULL to ignore errors. [allow-none][out]
|
Returns : |
An instance of a NGFileMonitor or NULL in case an error occured (errmsg will be set) |
void nntpgrab_utils_cancel_directory_monitor
(NGFileMonitor *monitor
);
Cancel the monitoring of a directory
|
The instance of the NGFileMonitor which needs to be stopped |
void ng_free (void *data
);
Free data allocated by NNTPGrab functions
|
The data which needs to be free'd |
NGList * ng_list_append (NGList *list
,void *data
);
Append an item to a list
Returns : |
The (possibly) new start of the list |
NGList * ng_list_prepend (NGList *list
,void *data
);
Insert an item to the beginning of a list
|
The list where the item needs to be added to (can be NULL to create a new list) |
|
The item which needs to be added |
Returns : |
The (possibly) new start of the list |
NGList * ng_list_remove (NGList *list
,void *data
);
Remove an item from a list
Note that if data
isn't part of the list, this function will do nothing
Returns : |
The (possibly) new start of the list |
unsigned int ng_list_length (NGList *list
);
Retrieve the length of a list
|
The list of which the length must be returned |
Returns : |
The length of the list |
void ng_list_free (NGList *list
);
Free a list Note that this function only free's the list itself, NOT the items which were in it!
|
The list which needs to be free'd |
#define ng_list_previous(list) ((list) ? (((NGList *)(list))->prev) : NULL)
|
The list of which the previous item needs to be retrieved
Returns: The previous item in list or NULL when there's no previous item
|
#define ng_list_next(list) ((list) ? (((NGList *)(list))->next) : NULL)
|
The list of which the next item needs to be retrieved
Returns: The next item in list or NULL when there's no next item
|
void ng_signal_connect (void *instance
,const char *signal_name
,NGCallback cb_handler
,void *data
);
Register a signal handler The file nntpgrab_core/marshall.list contains a list of known signals and callback function prototypes for the NNTPGrabCore
|
The instance of an GObject, for example NNTPGrabCore or NNTPGrabAutoImport |
|
The name of the signal for which a signaler handler needs to be registered |
|
The function which need to be called every time the given signal is emit |
|
Data used as extra argument in the callback functions |
void ng_signal_handlers_disconnect_by_func (void *instance
,NGCallback cb_handler
,void *data
);
void ng_signal_handlers_block_by_func (void *instance
,NGCallback cb_handler
,void *data
);
Temporary disable a signal handler for a given callback function
|
The instance of an GObject, for example NNTPGrabCore or NNTPGrabAutoImport |
|
The callback function which need to be temporary blocked |
|
The callback data used for the given cb_handler |
void ng_signal_handlers_unblock_by_func (void *instance
,NGCallback cb_handler
,void *data
);
void ng_event_handler_loop_run (void
);
Start the event handler loop. This function waits for incoming events and passes these on to all the registered event handlers
This function only returns as soon as the function ng_event_handler_loop_quit()
is called from an event handler or another thread
This function doesn't need to be used for the GTK+ frontend as it is equivalent to gtk_main()
void ng_event_handler_loop_quit (void
);
Stop the event handler loop
This function doesn't need to be used for the GTK+ frontend as it is equivalent to gtk_main_quit()