Classes | Macros | Typedefs | Enumerations | Functions | Variables
CORE: Newsreader base functionality

The core use a separate thread for the transport subsystem calls, otherwise it would block the UI while waiting for data. More...

Classes

struct  core_data
 Structure to transfer data between core and UI threads. More...
 
struct  core_range
 Article range linked list element. More...
 
struct  core_groupstate
 Group description. More...
 
struct  core_article_header
 Article header fields supported by core. More...
 
struct  core_hierarchy_element
 Node in article hierarchy. More...
 

Macros

#define MAIN_ERR_PREFIX   "CORE: "
 Message prefix for CORE module.
 
#define CORE_NEXUS_RETRIES   1U
 Number of retries for nexus operations. More...
 
#define CORE_HEADER_LINE_LENGTH   (size_t) 1024
 Sufficient for any RFC 5536 conformant header line. More...
 
#define CORE_CL_SECRET_FILE   ".cancelsecret"
 
#define CORE_UAGENT_RAW   0
 Do not parse for content in "User-Agent" header field. More...
 
#define CORE_GET_EMPTY_STRING(p)
 
#define CORE_GET_ERROR_STRING(p)
 
#define core_anum_t   nntp_anum_t
 Article number data type (value zero is always reserved) More...
 
#define core_groupdesc   nntp_groupdesc
 Group descriptor structure. More...
 
#define core_grouplabel   nntp_grouplabel
 Group label structure. More...
 
#define CORE_ANUM_T_MAX   NNTP_ANUM_T_MAX
 Article number limit. More...
 
#define CORE_TIME_T_MAX   ULONG_MAX
 Article number limit.
 

Typedefs

typedef unsigned long int core_time_t
 Time in seconds since the epoche (in terms of POSIX.1) More...
 

Enumerations

enum  core_nexus_state { CORE_NEXUS_CLOSED, CORE_NEXUS_ESTABLISHED }
 
enum  core_command {
  CORE_CMD_INVALID, CORE_CMD_GET_MOTD, CORE_CMD_GET_DISTRIB_PATS, CORE_CMD_GET_SUBSCRIPTIONS,
  CORE_CMD_RESET_GROUPSTATES, CORE_CMD_GET_GROUPLIST, CORE_CMD_GET_GROUPLABELS, CORE_CMD_GET_GROUPINFO,
  CORE_CMD_SET_GROUP, CORE_CMD_GET_OVERVIEW, CORE_CMD_GET_ARTICLE_BY_MID, CORE_CMD_GET_ARTICLE,
  CORE_CMD_GET_ARTICLE_HEADER, CORE_CMD_GET_ARTICLE_BODY, CORE_CMD_POST_ARTICLE, CORE_TERMINATE_NEXUS
}
 
enum  core_header_type { CORE_HT_UNSTRUCT, CORE_HT_STRUCT }
 
enum  core_header_id {
  CORE_HDR_EOH, CORE_HDR_MSGID, CORE_HDR_GROUPS, CORE_HDR_FROM,
  CORE_HDR_SUBJECT, CORE_HDR_DATE, CORE_HDR_OPT, CORE_HDR_SUPERS,
  CORE_HDR_FUP2, CORE_HDR_REPLY2, CORE_HDR_UAGENT, CORE_HDR_ORG,
  CORE_HDR_REFS, CORE_HDR_DIST, CORE_HDR_MIME, CORE_HDR_CT,
  CORE_HDR_CTE, CORE_HDR_CD, CORE_HDR_X_NEWSR, CORE_HDR_X_MAILER,
  CORE_HDR_X_PAGENT, CORE_HDR_LINES
}
 
enum  core_hierarchy_action {
  CORE_HIERARCHY_INIT, CORE_HIERARCHY_GETROOT, CORE_HIERARCHY_ADD, CORE_HIERARCHY_ADD_OVER,
  CORE_HIERARCHY_UPDATE
}
 Actions that the article hierarchy manager can handle. More...
 

Functions

const char ** core_extract_groups (const char *body)
 Extract groups from 'Newsgroups' header field (exported for UI) More...
 
int core_get_group_list (unsigned int cookie)
 Get list of available newsgroups (exported for UI) More...
 
int core_get_group_labels (unsigned int cookie)
 Get list of newsgroup labels (exported for UI) More...
 
int core_sort_group_list (void)
 Alphabetically sort group list (exported for UI) More...
 
int core_subscribe_group (const char *name)
 Store group subscription (exported for UI) More...
 
int core_unsubscribe_group (size_t *num, struct core_groupstate **list, size_t *index)
 Remove group from list (exported for UI) More...
 
int core_reset_group_states (unsigned int cookie)
 Reset states of subscribed groups (exported for UI) More...
 
int core_export_group_states (size_t num, struct core_groupstate *list)
 Store states of subscribed groups (exported for UI) More...
 
int core_update_subscribed_group_states (size_t *num, struct core_groupstate **list, size_t *index)
 Get states of subscribed groups (exported for UI) More...
 
void core_destroy_subscribed_group_states (size_t *num, struct core_groupstate **list)
 Destructor for subscribed group states (exported for UI) More...
 
int core_get_subscribed_group_info (const size_t *num, struct core_groupstate **list, unsigned int cookie)
 Get information about subscribed groups (exported for UI) More...
 
void core_destroy_subscribed_group_info (struct core_groupdesc **list)
 Destructor for subscribed group information (exported for UI) More...
 
int core_set_group (const char *name, unsigned int cookie)
 Set current group (exported for UI) More...
 
int core_get_motd (unsigned int cookie)
 Get message of the day (exported for UI) More...
 
int core_get_distribution (const char **dist, const char **groups)
 Get distribution suggestions (exported for UI) More...
 
int core_get_subscription_proposals (unsigned int cookie)
 Get subscription proposals (exported for UI) More...
 
int core_get_overview (struct core_range *range, unsigned int cookie)
 Get article header overview (exported for UI) More...
 
int core_get_article_by_mid (const char *mid, unsigned int cookie)
 Get complete article by Message-ID (exported for UI) More...
 
int core_get_article (const core_anum_t *id, unsigned int cookie)
 Get complete article (exported for UI) More...
 
int core_get_article_header (const core_anum_t *id, unsigned int cookie)
 Get article header (exported for UI) More...
 
int core_get_article_body (const core_anum_t *id, unsigned int cookie)
 Get article body (exported for UI) More...
 
int core_post_article (const char *article, unsigned int cookie)
 Post article (exported for UI) More...
 
int core_check_already_read (struct core_groupstate *group, struct core_hierarchy_element *article)
 Check whether article was alread read (exported for UI) More...
 
void core_mark_as_read (struct core_groupstate *group, core_anum_t article)
 Mark article as read (exported for UI) More...
 
void core_mark_as_unread (struct core_groupstate *group, core_anum_t article)
 Mark article as unread (exported for UI) More...
 
const char * core_convert_canonical_to_posix (const char *s, int rcr, int rlf)
 Convert from canonical (RFC 822) to local (POSIX) form. More...
 
const char * core_convert_posix_to_canonical (const char *s)
 Convert from local (POSIX) to canonical (RFC 822) form. More...
 
int core_hierarchy_manager (struct core_hierarchy_element **hier, enum core_hierarchy_action action, core_anum_t anum,...)
 Manage article hierarchy in memory (exported for UI) More...
 
void core_create_hierarchy_from_overview (struct core_groupstate *group, struct core_range *range, const char *overview)
 Create article hierarchy from header overview (exported for UI) More...
 
const char * core_entity_parser (const char *entity, size_t len, struct core_article_header **e_h, size_t *e_len)
 Parse header of MIME multipart entity (exported for UI) More...
 
void core_destroy_entity_header (struct core_article_header **ehp)
 Destructor for MIME multipart entity header object (exported for UI) More...
 
const char * core_get_homedir (void)
 Get home directory of user (exported for UI) More...
 
const char * core_suggest_pathname (void)
 Suggest pathname to save something to a file (exported for UI) More...
 
const char * core_get_datetime (int force_utc)
 Get current date and time in RFC 5322 format (exported for UI) More...
 
const char * core_get_msgid (const char *fqdn)
 Get globally unique Message-ID (exported for UI) More...
 
const char * core_get_cancel_key (unsigned int scheme, const char *msgid)
 Create Cancel-Key for Message-ID (exported for UI) More...
 
const char * core_get_cancel_lock (unsigned int scheme, const char *mid)
 Create Cancel-Lock for Message-ID (exported for UI) More...
 
const char * core_get_signature (unsigned int *warnings)
 Get signature for outgoing messages (exported for UI) More...
 
const char * core_get_introduction (const char *ca, const char *ngl)
 Get introduction line for citation (exported for UI) More...
 
const char * core_convert_pathname_to_locale (const char *pathname)
 Convert pathname to codeset of locale (exported for UI) More...
 
int core_check_file_exist (const char *pathname)
 Check wheter file exists (exported for UI) More...
 
int core_save_to_file (const char *pathname, const char *s)
 Save string to text file (exported for UI) More...
 
const char * core_tmpfile_create (void)
 Create temporary file (exported for UI) More...
 
void core_tmpfile_delete (const char *pathname)
 Delete temporary file (exported for UI) More...
 
void core_disconnect (void)
 Close nexus (exported for UI)
 
void core_mutex_lock (void)
 Lock mutex for data object (exported for UI) More...
 
void core_mutex_unlock (void)
 Unlock mutex for data object (exported for UI) More...
 
int core_check_thread_ui (void)
 Check whether code is running in UI thread (exported for UI) More...
 
void core_free (void *p)
 Free an object allocated by core (exported for UI) More...
 
int core_init (void)
 Initialize core (exported for UI) More...
 
void core_exit (void)
 Shutdown core (exported for UI) More...
 

Variables

struct core_data data
 Global data object (shared by all threads)
 

Control flags for header parser (for internal use only)

The flags can be bitwise ORed together.

#define CORE_CFLAG_COMMENT   0x01U
 
#define CORE_CFLAG_QSTRING   0x02U
 
#define CORE_CFLAG_EWORD   0x04U
 

Group flag bits

#define CORE_GROUP_FLAG_ASCII   NNTP_GROUP_FLAG_ASCII
 

Hierarchy elements flag bits

#define CORE_HE_FLAG_OVER   1U
 

Signature warnings

#define CORE_SIG_FLAG_SEPARATOR   0x01U
 
#define CORE_SIG_FLAG_INVALID   0x02U
 
#define CORE_SIG_FLAG_NOTASCII   0x04U
 
#define CORE_SIG_FLAG_LENGTH   0x08U
 

Algorithms for Cancel-Lock scheme

#define CORE_CL_INVALID   0U
 
#define CORE_CL_SHA1   1U
 
#define CORE_CL_SHA256   2U
 

Detailed Description

The core use a separate thread for the transport subsystem calls, otherwise it would block the UI while waiting for data.

A nexus binds the core to a transport subsystem (like NNTP or UUCP).

Current limitations:

At least the following things must be (re)implemented for Unicode support at protocol level:

Attention
It is required that 'PID_MAX' is not larger than 'LONG_MAX' (must be checked by build system).

Macro Definition Documentation

◆ core_anum_t

#define core_anum_t   nntp_anum_t

Article number data type (value zero is always reserved)

This renames the data type nntp_anum_t .

Definition at line 24 of file core.h.

◆ CORE_ANUM_T_MAX

#define CORE_ANUM_T_MAX   NNTP_ANUM_T_MAX

Article number limit.

This renames the limit from the NNTP transport subsystem NNTP_ANUM_T_MAX .

Attention
This value must always be smaller or equal to ULONG_MAX because many older compilers do not provide a larger data type and many older stdio implementations can't handle larger data types. This means on all platforms where unsigned long is 32 bit wide this value is limited to 2^32 - 1.

Definition at line 180 of file core.h.

◆ CORE_CL_INVALID

#define CORE_CL_INVALID   0U

Invalid scheme

Definition at line 207 of file core.h.

◆ CORE_CL_SECRET_FILE

#define CORE_CL_SECRET_FILE   ".cancelsecret"

File containing secret for SHA2-based Cancel-Locks/-Keys

Note
The minimum value for NAME_MAX defined by POSIX is 14 characters.

Definition at line 223 of file core.c.

◆ CORE_CL_SHA1

#define CORE_CL_SHA1   1U

SHA1

Definition at line 208 of file core.h.

◆ CORE_CL_SHA256

#define CORE_CL_SHA256   2U

SHA2-256

Definition at line 209 of file core.h.

◆ CORE_GET_EMPTY_STRING

#define CORE_GET_EMPTY_STRING (   p)
Value:
{ \
p = (char*) posix_malloc(1); \
if(NULL == p) { res = -1; } \
else { ((char*) p)[0] = 0; } \
}

Definition at line 1488 of file core.c.

◆ CORE_GET_ERROR_STRING

#define CORE_GET_ERROR_STRING (   p)
Value:
{ \
p = (char*) posix_malloc(34); \
if(NULL == p) { res = -1; } \
else { strcpy((char*) p, "[Missing or invalid header field]"); } \
}

Definition at line 1495 of file core.c.

◆ CORE_GROUP_FLAG_ASCII

#define CORE_GROUP_FLAG_ASCII   NNTP_GROUP_FLAG_ASCII

Name contains only ASCII characters

Definition at line 188 of file core.h.

◆ core_groupdesc

#define core_groupdesc   nntp_groupdesc

Group descriptor structure.

This renames the structure nntp_groupdesc .

Definition at line 30 of file core.h.

◆ core_grouplabel

#define core_grouplabel   nntp_grouplabel

Group label structure.

This renames the structure nntp_grouplabel .

Definition at line 36 of file core.h.

◆ CORE_HE_FLAG_OVER

#define CORE_HE_FLAG_OVER   1U

Node contains incomplete data from NNTP overview

Definition at line 194 of file core.h.

◆ CORE_HEADER_LINE_LENGTH

#define CORE_HEADER_LINE_LENGTH   (size_t) 1024

Sufficient for any RFC 5536 conformant header line.

The real limit defined in RFC 5536 is 998 characters.

Definition at line 207 of file core.c.

◆ CORE_NEXUS_RETRIES

#define CORE_NEXUS_RETRIES   1U

Number of retries for nexus operations.

Should be at least 1, otherwise the core module can't automatically recover after a nexus loss (e.g. disconnect from server).

Definition at line 201 of file core.c.

◆ CORE_SIG_FLAG_INVALID

#define CORE_SIG_FLAG_INVALID   0x02U

Character set is not UTF-8

Definition at line 200 of file core.h.

◆ CORE_SIG_FLAG_LENGTH

#define CORE_SIG_FLAG_LENGTH   0x08U

Length is too large

Definition at line 202 of file core.h.

◆ CORE_SIG_FLAG_NOTASCII

#define CORE_SIG_FLAG_NOTASCII   0x04U

Character set is not US-ASCII

Definition at line 201 of file core.h.

◆ CORE_SIG_FLAG_SEPARATOR

#define CORE_SIG_FLAG_SEPARATOR   0x01U

Separator "-- " is missing

Definition at line 199 of file core.h.

◆ CORE_UAGENT_RAW

#define CORE_UAGENT_RAW   0

Do not parse for content in "User-Agent" header field.

Set this to nonzero if you want to see the comments in the GUI.

Attention
The contents of comments can contain quoted-pair and encoded-word tokens. The header parser will not decode them and the data may not be readable for humans (e.g. Base64 encoding in encoded-word). Therefore this option is disabled by default.

Definition at line 235 of file core.c.

Typedef Documentation

◆ core_time_t

typedef unsigned long int core_time_t

Time in seconds since the epoche (in terms of POSIX.1)

This is the core representation for POSIX time_t which is usually signed and even allowed to be a floating point type (what we don't want for performance reasons). Old compilers don't support 64 bit integer data types, therefore we use the largest mandatory (in terms of C90) unsigned integer type available. This gives at least additional 68 years beyond 2038 until "end of time" is reached for the cost that we can't use timestamps before the POSIX epoche (at this time Usenet was not invented yet and therefore this causes no problems).

In the case Usenet would still exist at that time, the limit can be increased by redefining this to uint64_t at the cost of losing compatibility to historical systems.

Definition at line 54 of file core.h.

Enumeration Type Documentation

◆ core_hierarchy_action

Actions that the article hierarchy manager can handle.

CORE_HIERARCHY_INIT must be the first action that is executed.

Enumerator
CORE_HIERARCHY_INIT 

Delete hierarchy and create a new empty one

CORE_HIERARCHY_GETROOT 

Get root node of article hierarchy

CORE_HIERARCHY_ADD 

Add article to hierarchy

CORE_HIERARCHY_ADD_OVER 

Add incomplete data (overview) to hierarchy

CORE_HIERARCHY_UPDATE 

Update element of hierarchy

Definition at line 156 of file core.h.

Function Documentation

◆ core_check_already_read()

int core_check_already_read ( struct core_groupstate group,
struct core_hierarchy_element article 
)

Check whether article was alread read (exported for UI)

Parameters
[in]groupGroup in which article resides
[in]articleHierarchy element assigned to article
Returns
  • 0 if article was not read yet
  • Positive value if article was already read

Definition at line 4741 of file core.c.

References core_hierarchy_element::anum, core_anum_t, core_range::first, core_groupstate::info, core_range::last, and core_range::next.

◆ core_check_file_exist()

int core_check_file_exist ( const char *  pathname)

Check wheter file exists (exported for UI)

Parameters
[in]pathnamePathname of file (UTF-8 encoded)
Note
The encoding of the pathname is converted to the encoding of the locale.
Returns
  • 0 on success (file exists)
  • Negative value on error

Definition at line 6340 of file core.c.

References core_convert_pathname_to_locale(), and fu_check_file().

◆ core_check_thread_ui()

int core_check_thread_ui ( void  )

Check whether code is running in UI thread (exported for UI)

Returns
  • 0 if not running in UI thread
  • 1 if running in UI thread
  • Negative value on error

Definition at line 6596 of file core.c.

Referenced by ts_lock_ui(), and ts_unlock_ui().

◆ core_convert_canonical_to_posix()

const char* core_convert_canonical_to_posix ( const char *  s,
int  rcr,
int  rlf 
)

Convert from canonical (RFC 822) to local (POSIX) form.

According to RFC 822 and RFC 2049 this function accepts plain text article content in canonical form and convert the CR+LF line breaks to local (POSIX, single LF) form. Single CR and LF characters are preserved by default (this can be overridden by rcr and rlf respectively).

Parameters
[in]sString to convert
[in]rcrInsert replacement character for single CR
[in]rlfInsert replacement character for single LF
Returns
  • Pointer to decoded data (a new memory block was allocated)
  • NULL on error

Definition at line 4966 of file core.c.

References enc_convert_canonical_to_posix().

◆ core_convert_pathname_to_locale()

const char* core_convert_pathname_to_locale ( const char *  pathname)

Convert pathname to codeset of locale (exported for UI)

Parameters
[in]pathnamePathname to convert (UTF-8 encoded)

On success the caller is responsible to free the memory allocated for the returned pathname.

Todo:
As target this function uses the codeset that was detected for the locale category LC_CTYPE by the FILTER module. The locale parsing code should be moved to the CORE module.
Returns
  • Pointer to (potentially converted) pathname on success
  • NULL on error

Definition at line 6249 of file core.c.

References filter_get_locale_ctype().

Referenced by core_check_file_exist(), and core_save_to_file().

◆ core_convert_posix_to_canonical()

const char* core_convert_posix_to_canonical ( const char *  s)

Convert from local (POSIX) to canonical (RFC 822) form.

According to RFC 822 and RFC 2049 this function accepts plain text article content in local (POSIX) form and convert the single LF line breaks to canonical (CR+LF) form. Single CR characters are removed.

Parameters
[in]sString to convert
Returns
  • Pointer to decoded data (a new memory block was allocated)
  • NULL on error

Definition at line 4986 of file core.c.

References enc_convert_posix_to_canonical().

◆ core_create_hierarchy_from_overview()

void core_create_hierarchy_from_overview ( struct core_groupstate group,
struct core_range range,
const char *  overview 
)

Create article hierarchy from header overview (exported for UI)

Parser for RFC 3977 conformant header overview data as provided by the function core_get_overview() .

Note
All articles in range that are missing in overview are marked as read.
Parameters
[in,out]groupGroup in which articles reside
[in]rangePointer to article number range
[in]overviewPointer to article header overview data

Definition at line 5116 of file core.c.

References core_anum_t, core_mutex_lock(), core_range::first, and nntp_get_over_newsgroups_index().

◆ core_destroy_entity_header()

void core_destroy_entity_header ( struct core_article_header **  ehp)

Destructor for MIME multipart entity header object (exported for UI)

Parameters
[in,out]ehpPointer to decoded header object of MIME multipart entity

Definition at line 5359 of file core.c.

◆ core_destroy_subscribed_group_info()

void core_destroy_subscribed_group_info ( struct core_groupdesc **  list)

Destructor for subscribed group information (exported for UI)

Parameters
[in,out]listPointer to array of group descriptors

This destructor is intended to destroy the object created by the function core_get_subscribed_group_info() .

If list is NULL , the function do nothing.

Definition at line 3732 of file core.c.

◆ core_destroy_subscribed_group_states()

void core_destroy_subscribed_group_states ( size_t *  num,
struct core_groupstate **  list 
)

Destructor for subscribed group states (exported for UI)

Parameters
[in]numPointer to number of groups
[in]listPointer to array of group state structures

This destructor is intended to destroy the object created by the function core_update_subscribed_group_states() .

If list is NULL , the function do nothing.

Definition at line 3641 of file core.c.

References group_destroy_list().

◆ core_entity_parser()

const char* core_entity_parser ( const char *  entity,
size_t  len,
struct core_article_header **  e_h,
size_t *  e_len 
)

Parse header of MIME multipart entity (exported for UI)

Parameters
[in]entityPointer to beginning of MIME multipart entity
[in]lenLength of MIME multipart entity
[out]e_hObject with decoded header of MIME multipart entity
[out]e_lenLength of MIME multipart entity content

On success the caller is responsible to free the memory allocated for the decoded header object. Use the function core_destroy_entity_header() to do this.

Returns
  • Pointer to beginning of MIME multipart entity content on success
  • NULL on error

Definition at line 5295 of file core.c.

◆ core_exit()

void core_exit ( void  )

Shutdown core (exported for UI)

Cancel the core thread and destroy the article hierarchy.

Note
It is allowed to call this function after core_init() had failed before.

Definition at line 6699 of file core.c.

◆ core_export_group_states()

int core_export_group_states ( size_t  num,
struct core_groupstate list 
)

Store states of subscribed groups (exported for UI)

Parameters
[in]numPointer to number of groups
[in]listPointer to array of group information structures
Returns
  • 0 on success
  • Negative value on error

Definition at line 3555 of file core.c.

References group_set_list().

◆ core_extract_groups()

const char** core_extract_groups ( const char *  body)

Extract groups from 'Newsgroups' header field (exported for UI)

Parameters
[in]bodyUnfolded body of Newsgroups header field

Because the parameter body is allowed to have arbitrary size, the result has arbitrary size too. The result array is terminated with a NULL entry.

Note
The caller is responsible to free the memory for the array.
Returns
  • Pointer to array of strings
  • NULL on error

Definition at line 3284 of file core.c.

◆ core_free()

void core_free ( void *  p)

Free an object allocated by core (exported for UI)

Use this function to release dynamic memory that was allocated by the core.

Parameters
[in]pPointer to object

Release the memory for the object pointed to by p.

Note
The pointer p is allowed to be NULL and no operation is performed in this case.

Definition at line 6625 of file core.c.

Referenced by core_save_to_file().

◆ core_get_article()

int core_get_article ( const core_anum_t id,
unsigned int  cookie 
)

Get complete article (exported for UI)

Parameters
[in]idArticle number
[in]cookieCallback cookie

The core will fetch the article with number id from a server (currently always the default one from the configuration config ). After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

Attention
id must be valid until ui_wakeup() is called.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to the buffer with the article. The field core_data::size contains the buffer size. If the server is available but doesn't contain the requested article, success is returned with a NULL pointer and zero size.

The caller is responsible to free the memory allocated for the buffer.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 4297 of file core.c.

References core_mutex_lock().

◆ core_get_article_body()

int core_get_article_body ( const core_anum_t id,
unsigned int  cookie 
)

Get article body (exported for UI)

Parameters
[in]idArticle number
[in]cookieCallback cookie

The core will fetch the article body with number id from a server (currently always the default one from the configuration config ). After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

Attention
id must be valid until ui_wakeup() is called.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to the buffer with the article body. The field core_data::size contains the buffer size. If the server is available but doesn't contain the requested article, success is returned with a NULL pointer and zero size.

The caller is responsible to free the memory allocated for the buffer.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 4421 of file core.c.

References core_mutex_lock().

◆ core_get_article_by_mid()

int core_get_article_by_mid ( const char *  mid,
unsigned int  cookie 
)

Get complete article by Message-ID (exported for UI)

Parameters
[in]midMessage-ID (with angle brackets)
[in]cookieCallback cookie

The core will fetch the article with Message-ID mid from a server (currently always the default one from the configuration config ). After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

Attention
mid must be valid until ui_wakeup() is called.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to the buffer with the article. The field core_data::size contains the buffer size. If the server is available but doesn't contain the requested article, success is returned with a NULL pointer and zero size.

The caller is responsible to free the memory allocated for the buffer.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 4235 of file core.c.

References core_mutex_lock().

◆ core_get_article_header()

int core_get_article_header ( const core_anum_t id,
unsigned int  cookie 
)

Get article header (exported for UI)

Parameters
[in]idArticle number
[in]cookieCallback cookie

The core will fetch the article header with number id from a server (currently always the default one from the configuration config ). After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

Attention
id must be valid until ui_wakeup() is called.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to the buffer with the article header. The field core_data::size contains the buffer size. If the server is available but doesn't contain the requested article, success is returned with a NULL pointer and zero size.

The caller is responsible to free the memory allocated for the buffer.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 4359 of file core.c.

References core_mutex_lock().

◆ core_get_cancel_key()

const char* core_get_cancel_key ( unsigned int  scheme,
const char *  msgid 
)

Create Cancel-Key for Message-ID (exported for UI)

Parameters
[in]schemeAlgorithm to use for "scheme"
[in]msgidMessage-ID of article that should correspond to Cancel-Key

This function creates a c-key element with with scheme and mid according to RFC 8315.

On success, the caller is responsible for releasing the memory allocated for the result.

Returns
  • Pointer to the buffer containing the created c-key element on success
  • NULL on error

Definition at line 5763 of file core.c.

References CONF_CANCELKEY, config, CORE_CL_SECRET_FILE, CORE_CL_SHA1, CORE_CL_SHA256, enc_free(), enc_mime_encode_base64(), fu_close_file(), fu_create_path(), fu_open_file(), fu_read_from_filedesc(), hmac_sha1_160(), HMAC_SHA1_160_LEN, hmac_sha2_256(), HMAC_SHA2_256_LEN, main_debug, MAIN_ERR_PREFIX, PRINT_ERROR, conf_entry_val::s, secure_cl_secret(), secure_clear_memory(), conf::val, xdg_append_to_path(), and xdg_get_confdir().

Referenced by core_get_cancel_lock().

◆ core_get_cancel_lock()

const char* core_get_cancel_lock ( unsigned int  scheme,
const char *  mid 
)

Create Cancel-Lock for Message-ID (exported for UI)

Parameters
[in]schemeAlgorithm to use for "scheme"
[in]midMessage-ID of article that should correspond to Cancel-Lock

This function creates a c-lock element with with scheme and mid according to RFC 8315.

On success, the caller is responsible for releasing the memory allocated for the result.

Returns
  • Pointer to the buffer containing the created c-lock element on success
  • NULL on error

Definition at line 5924 of file core.c.

References CORE_CL_SHA1, CORE_CL_SHA256, core_get_cancel_key(), digest_sha1_160(), DIGEST_SHA1_160_LEN, digest_sha2_256(), DIGEST_SHA2_256_LEN, enc_free(), enc_mime_encode_base64(), and PRINT_ERROR.

◆ core_get_datetime()

const char* core_get_datetime ( int  force_utc)

Get current date and time in RFC 5322 format (exported for UI)

Parameters
[in]force_utcForce usage of UTC time with unknown timezone

RFC 5322 recommends but not require to use the local time. If the POSIX.1-2001 API is available and force_utc is set to zero, then local time is used. Otherwise the returned date is UTC and marked with the unknown timezone information -0000 defined by RFC 5322.

If timestamp_comment option is enabled in configfile and force_utc is set to a nonzero value, a comment with the abbreviation of the timezone is appended (if the POSIX.1-2001 API or the X/Open XSI extension are provided by the operating system).

Note
On success, the caller is responsible to free the memory allocated for the result.
Returns
  • Pointer to result on success
  • NULL on error

Definition at line 5485 of file core.c.

References CONF_TS_COMMENT, CONF_TS_LTIME, config, and PRINT_ERROR.

◆ core_get_distribution()

int core_get_distribution ( const char **  dist,
const char **  groups 
)

Get distribution suggestions (exported for UI)

Parameters
[out]distSuggested distribution for groups
[in]groupsNewsgroup list (NULL for empty list is allowed)

The core will fetch distribution suggestions (if available) from a server (currently always the default one from the configuration config ) for groups . The result is the suggested content for the Distribution header field.

On success, the caller is responsible to free the memory allocated for the buffer.

Returns
  • Zero on success (Pointer to new memory buffer was written to dist)
  • Negative value for no suggestion and on error

Definition at line 3885 of file core.c.

References CONF_DIST_SUGG, config, core_mutex_lock(), data, nntp_get_distrib_pats(), and PRINT_ERROR.

◆ core_get_group_labels()

int core_get_group_labels ( unsigned int  cookie)

Get list of newsgroup labels (exported for UI)

Parameters
[in]cookieCallback cookie

The core will fetch the list with newsgroup labels that are available on the server (always the default one from the configuration config ). After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to a buffer with the array of group label structures. The field core_data::size contains the number of groups in the array. If the server is available but doesn't contain groups, success is returned with a NULL pointer and zero size.

The caller is responsible to free the memory allocated for the array and all of its elements.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 3376 of file core.c.

References core_mutex_lock().

◆ core_get_group_list()

int core_get_group_list ( unsigned int  cookie)

Get list of available newsgroups (exported for UI)

Parameters
[in]cookieCallback cookie

The core will fetch the list with all groups that are available on the server (always the default one from the configuration config ). After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to a buffer with the array of group descriptors. The field core_data::size contains the number of groups in the array. If the server is available but doesn't contain groups, success is returned with a NULL pointer and zero size.

The caller is responsible to free the memory allocated for the array and all of its elements.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 3317 of file core.c.

References core_mutex_lock().

◆ core_get_homedir()

const char* core_get_homedir ( void  )

Get home directory of user (exported for UI)

Note
On success, the caller is responsible to free the memory allocated for the result.
Returns
  • Pointer to result on success
  • NULL on error

Definition at line 5377 of file core.c.

References fu_check_path(), and ts_getenv().

Referenced by core_suggest_pathname().

◆ core_get_introduction()

const char* core_get_introduction ( const char *  ca,
const char *  ngl 
)

Get introduction line for citation (exported for UI)

Parameters
[in]caName of cited author
[in]nglNewsgroup list of the cited article

The result of this function is an introduction line string without linebreak at the end. The format is taken from the configuration config .

Note
On success, the caller is responsible to free the memory allocated for the result.
Returns
  • Pointer to result on success
  • NULL on error

Definition at line 6152 of file core.c.

References CONF_INTRO, config, MAIN_ERR_PREFIX, conf_entry_val::s, and conf::val.

◆ core_get_motd()

int core_get_motd ( unsigned int  cookie)

Get message of the day (exported for UI)

Parameters
[in]cookieCallback cookie

The core will fetch the message of the day from a server (currently always the default one from the configuration config ).

After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to the buffer with the message of the day. The field core_data::size contains the buffer size. If the server is available, but doesn't provide a message of the day, success is returned with a NULL pointer and zero size.

The caller is responsible to free the memory allocated for the buffer.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error or if not supported

Definition at line 3822 of file core.c.

◆ core_get_msgid()

const char* core_get_msgid ( const char *  fqdn)

Get globally unique Message-ID (exported for UI)

Parameters
[in]fqdnFully qualified domain name without root domain
Attention
fqdn must be specified without the (nameless) DNS root domain, this means there must be no trailing dot! fqdn must match the dot-atom syntax defined in RFC 5322 to be usable as id-right element of a Message-ID.

According to RFC 5536 the following rules are applied:

  • The Message-ID must not be more than 250 octets in length => We check this.
  • The Message-ID must be globally unique for all time => We use algorithm A3.
  • The id-right element should be a domain => We use FQDN w/o root domain.
  • Message-IDs should be unpredictable => We use a random field.

Description of Message-ID format created by algorithm A3:
date random_pid . A3 . program @ fqdn

The date field contains a modified base64 encoded POSIX timestamp (seconds since epoche) with 48bits.

The random and pid fields are combined into a modified base64 encoded value with 48bits. The first 16bits are random, they are added to deal with real world clocks that are often not synchronized with UTC and don't always run monotonic. They also make the Message-ID unpredictable as recommended by RFC 5536. The last 32bits are the 32 LSBs of the process identifier (PID). The function getpid() is used for this purpose. Both parts are combined to one value to make the length an integral multiple of octet triplets that can be base64 encoded without padding.

The modified base64 encoding uses the base64 alphabet with / (slash) replaced by - (minus).

The Ax field represents the algorithm used to create the message ID. If the algorithm is modified in the future, the number x should be incremented.

The program field contains the value of the variable CFG_NAME from the configuration file.

The fqdn field is taken from the parameter fqdn and is checked for valid dot-atom syntax according to RFC 5322.

Note
On success, the caller is responsible to free the memory allocated for the result.
Returns
  • Pointer to result on success
  • NULL on error

Definition at line 5629 of file core.c.

References enc_free(), enc_mime_encode_base64(), main_debug, MAIN_ERR_PREFIX, and PRINT_ERROR.

◆ core_get_overview()

int core_get_overview ( struct core_range range,
unsigned int  cookie 
)

Get article header overview (exported for UI)

Parameters
[in]rangePointer to article number range
[in]cookieCallback cookie

The core will fetch the article headers of range range from a server (currently always the default one from the configuration config ).

Attention
The range must be one contiguous range without holes. A list of ranges is not allowed here.

After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to the buffer with the article headers. The field core_data::size contains the buffer size. If the server is available but doesn't contain the requested articles, success is returned with a NULL pointer and zero size.

The caller is responsible to free the memory allocated for the buffer.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error or if not supported

Definition at line 4166 of file core.c.

◆ core_get_signature()

const char* core_get_signature ( unsigned int *  warnings)

Get signature for outgoing messages (exported for UI)

Parameters
[out]warningsPointer to location for result warning flags

Use the CORE_SIG_FLAG_xxx constants to decode warnings .

Note
It is allowed to pass NULL for warnings if the caller is not interested in this data.
On success, the caller is responsible to free the memory allocated for the result.
Returns
  • Pointer to result on success
  • NULL on error (nothing was written to warnings )

Definition at line 6034 of file core.c.

References CONF_SIGFILE, config, CORE_SIG_FLAG_INVALID, CORE_SIG_FLAG_LENGTH, CORE_SIG_FLAG_NOTASCII, CORE_SIG_FLAG_SEPARATOR, enc_ascii_check(), enc_uc_check_utf8(), fu_check_file(), fu_check_path(), fu_close_file(), fu_open_file(), fu_read_whole_file(), PRINT_ERROR, conf_entry_val::s, ts_getenv(), and conf::val.

◆ core_get_subscribed_group_info()

int core_get_subscribed_group_info ( const size_t *  num,
struct core_groupstate **  list,
unsigned int  cookie 
)

Get information about subscribed groups (exported for UI)

Parameters
[in]numPointer to number of groups in list
[in]listPointer to array of state structures
[in]cookieCallback cookie
Note
An empty list with num pointing to zero is allowed. The parameter list should point to NULL in this case.

The core will collect the information for the groups listed in list from the server (always the default one from the configuration config ). After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to an array of group descriptors with num entries (or is NULL for an empty group list).

The caller is responsible to free the memory allocated for the information object. The destructor function core_destroy_subscribed_group_info() should be used for this purpose.

Attention
Always call this function with all subscribed groups in list because the article header cache is deleted for all groups not found in list as a side effect.
Returns
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 3685 of file core.c.

References core_mutex_lock().

◆ core_get_subscription_proposals()

int core_get_subscription_proposals ( unsigned int  cookie)

Get subscription proposals (exported for UI)

Parameters
[in]cookieCallback cookie

The core will fetch the subscription proposals from a server (currently always the default one from the configuration config ).

Note
The data provided by this function is intended for initial population of a newsrc file.

After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to the buffer with the newsgroup list. The field core_data::size contains the buffer size. If the server is available, but doesn't provide a message of the day, success is returned with a NULL pointer and zero size.

The caller is responsible to free the memory allocated for the buffer.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error or if not supported

Definition at line 4103 of file core.c.

◆ core_hierarchy_manager()

int core_hierarchy_manager ( struct core_hierarchy_element **  hier,
enum core_hierarchy_action  action,
core_anum_t  anum,
  ... 
)

Manage article hierarchy in memory (exported for UI)

Parameters
[in,out]hierPointer to article hierarchy pointer
[in]actionWhat should be done
[in]anumArticle number

To use the default article hierarchy, hier shall be set to NULL .

The core provides a facility to create a hierarchy from articles that contain the header field "References". The UI can use it as follows:

First the hierarchy must be initialized with the action CORE_HIERARCHY_INIT (this automatically destroys the old hierarchy if one exist). All other parameters are ignored.

At any time after initialization, the root node of the current hierarchy can be read with the action CORE_HIERARCHY_GETROOT . anum must be zero and as additional parameter the address of a buffer must be supplied to which the root node is written on success. The data type must be core_hierarchy_element ** .

After an article header was fetched from the server, it can be added to the hierarchy with the action CORE_HIERARCHY_ADD . anum should be set to the number that the server has assigned to the article and, as additional parameter, a pointer to the raw article header must be provided. The data type must be const char * . The hierarchy manager will parse the article header, check it and extract all relevant information from it. With this information an article header object is created that is part of the hierarchy element object together with the article number, the parent and child article pointers.

The action CORE_HIERARCHY_ADD_OVER does the same, except that a flag is stored into the new node that indicates the incomplete data. This action is intended to add NNTP overview data.

Attention
For superseding to work, articles must be added in the correct order. In other words: The article that should be superseded must already be part of the hierarchy. In general this can easily achieved by adding the articles by number in ascending order.

The resulting hierarchy is a tree object that the UI can display without detailed knowledge of the article header format.

In some cases the data in the hierarchy elements is incomplete, e.g. if the hierarchy was created from NNTP overview data. It is possible to recreate single hierarchy elements with additional data in place, e.g. after the complete article was downloaded later. To update an existing hierarchy element, the action must be set to CORE_HIERARCHY_UPDATE . The parameters are the same as for CORE_HIERARCHY_ADD .

Returns
  • 0 on success
  • Negative value on error

Definition at line 5049 of file core.c.

◆ core_init()

int core_init ( void  )

Initialize core (exported for UI)

Spawn a new thread for the core.

Returns
  • 0 on success
  • Negative value on error

Definition at line 6641 of file core.c.

◆ core_mark_as_read()

void core_mark_as_read ( struct core_groupstate group,
core_anum_t  article 
)

Mark article as read (exported for UI)

Parameters
[in,out]groupGroup in which article resides
[in]articleArticle number

Definition at line 4766 of file core.c.

References core_anum_t, core_range::first, group_article_range_constructor(), core_groupstate::info, core_range::last, core_groupstate::name, and core_range::next.

◆ core_mark_as_unread()

void core_mark_as_unread ( struct core_groupstate group,
core_anum_t  article 
)

Mark article as unread (exported for UI)

Parameters
[in,out]groupGroup in which article resides
[in]articleArticle number

Definition at line 4871 of file core.c.

References core_anum_t, core_range::first, group_article_range_constructor(), group_article_range_destructor(), core_groupstate::info, core_range::last, core_groupstate::name, and core_range::next.

◆ core_mutex_lock()

void core_mutex_lock ( void  )

Lock mutex for data object (exported for UI)

You need to own the mutex before every access to the global object data to synchronize the threads.

Attention
Unlock the mutex again as soon as possible after the access!

Definition at line 6562 of file core.c.

Referenced by core_create_hierarchy_from_overview(), core_get_article(), core_get_article_body(), core_get_article_by_mid(), core_get_article_header(), core_get_distribution(), core_get_group_labels(), core_get_group_list(), core_get_subscribed_group_info(), core_reset_group_states(), and core_set_group().

◆ core_mutex_unlock()

void core_mutex_unlock ( void  )

Unlock mutex for data object (exported for UI)

Call this function after the access to the global object data is complete.

Definition at line 6578 of file core.c.

◆ core_post_article()

int core_post_article ( const char *  article,
unsigned int  cookie 
)

Post article (exported for UI)

Parameters
[in]articlePointer to Unicode article in RFC 5536 canonical form
[in]cookieCallback cookie

This function will check whether the article contains non-ASCII characters. If this is the case in the header, the article is rejected (this is forbidden by RFC 5536).

If the body contains non-ASCII characters, the body is converted to ISO 8859 if possible (this is recommended by RFC 2046, can be disabled with the force_unicode option in configfile). Two fields are appended to the header indicating a transfer encoding of 8bit and a content type of text/plain. For the content type, a parameter for the actual character set is appended. A second parameter is appended that indicates fixed format (according to RFC 3676).

If injection via external inews is configured, the result is never 1 and success (or error) derived from the exit status is returned immediately. The parameter cookie is not used in this case.

Otherwise the core will post the article pointed to by article to the server (currently always the default one from the configuration config ). After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

Note
The article is copied immediately, the data where article points to must not be valid until the operation is complete.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error).

Returns
  • 0 indicates success (from injection delegation to external inews)
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 4495 of file core.c.

References CONF_FORCE_UNICODE, config, enc_ascii_check(), enc_convert_to_8bit(), enc_convert_to_utf8_nfc(), ENC_CS_UTF_8, enc_free(), and PRINT_ERROR.

◆ core_reset_group_states()

int core_reset_group_states ( unsigned int  cookie)

Reset states of subscribed groups (exported for UI)

Parameters
[in]cookieCallback cookie

Closes the current server nexus and delete all group states. This function must be called after the server has been changed and the mapping from Message-IDs to article numbers is no longer valid. After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error).

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 3512 of file core.c.

References core_mutex_lock().

◆ core_save_to_file()

int core_save_to_file ( const char *  pathname,
const char *  s 
)

Save string to text file (exported for UI)

Parameters
[in]pathnamePathname of file (UTF-8 encoded)
[in]sString to convert

If the file pathname does not exist, it is created.

Note
The encoding of the pathname is converted to the encoding of the locale.
Returns
  • 0 on success
  • Negative value on error

Definition at line 6370 of file core.c.

References core_convert_pathname_to_locale(), core_free(), fu_assign_stream(), fu_close_file(), and fu_open_file().

◆ core_set_group()

int core_set_group ( const char *  name,
unsigned int  cookie 
)

Set current group (exported for UI)

Parameters
[in]nameGroup name
[in]cookieCallback cookie

The core will configure the server (always the default one from the configuration config ) to the current group name . After the operation was successfully started, the function returns (with the value 1). After the operation has completed, the core thread calls the function ui_wakeup() with cookie as parameter.

The UI can extract the result of the operation from the core_data object field core_data::result (0 on success, negative on error). On success the field core_data::data points to the buffer with the group descriptor. The field core_data::size is set to one.

The caller is responsible to free the memory allocated for the buffer.

Returns
  • 1 indicates that the operation is in progress
  • Negative value on error

Definition at line 3763 of file core.c.

References core_mutex_lock().

◆ core_sort_group_list()

int core_sort_group_list ( void  )

Alphabetically sort group list (exported for UI)

Returns
  • 0 on success
  • Negative value on error

Definition at line 3416 of file core.c.

References group_sort_list().

◆ core_subscribe_group()

int core_subscribe_group ( const char *  name)

Store group subscription (exported for UI)

Parameters
[in]nameGroup name to add
Note
The group name must have US-ASCII encoding or otherwise articles would be not RFC 5536 conformant.
Returns
  • 0 on success
  • Negative value on error

Definition at line 3436 of file core.c.

References enc_ascii_check(), group_add(), core_groupstate::info, core_groupstate::name, and PRINT_ERROR.

◆ core_suggest_pathname()

const char* core_suggest_pathname ( void  )

Suggest pathname to save something to a file (exported for UI)

Intended as suggestion for "save as" file selection dialogs.

This implementation uses the program name and the date to create the filename. The users home directory is used as path.

Note
On success, the caller is responsible to free the memory allocated for the result.
Returns
  • Pointer to result on success
  • NULL on error

Definition at line 5411 of file core.c.

References core_get_homedir(), and PRINT_ERROR.

◆ core_tmpfile_create()

const char* core_tmpfile_create ( void  )

Create temporary file (exported for UI)

On success the caller is responsible to free the memory allocated for the returned pathname. Use the function core_tmpfile_delete() to delete the file and free the memory block allocated for the pathname.

Note
This function uses the value of the environment variable $TMPDIR for the directory. If not set, /tmp is used instead.
Returns
  • Pointer to pathname of created file
  • NULL on error

Definition at line 6415 of file core.c.

◆ core_tmpfile_delete()

void core_tmpfile_delete ( const char *  pathname)

Delete temporary file (exported for UI)

Parameters
[in]pathnamePathname of file to delete
Attention
This function automatically free the memory allocated for pathname . This function should only be used with pathnames that are created with the function core_tmpfile_create() .

Definition at line 6530 of file core.c.

References fu_unlink_file().

◆ core_unsubscribe_group()

int core_unsubscribe_group ( size_t *  num,
struct core_groupstate **  list,
size_t *  index 
)

Remove group from list (exported for UI)

Parameters
[in,out]numPointer to number of groups in list
[in,out]listPointer to array of group state structures
[in]indexIndex of group to unsubscribe in list
Returns
  • 0 on success
  • Negative value on error

Definition at line 3468 of file core.c.

References group_article_range_destructor(), core_groupstate::info, and core_groupstate::name.

◆ core_update_subscribed_group_states()

int core_update_subscribed_group_states ( size_t *  num,
struct core_groupstate **  list,
size_t *  index 
)

Get states of subscribed groups (exported for UI)

The states which articles where already read are taken from the groupfile. The last viewed articles of the groups are preserved. The index is updated to match the new group list.

Parameters
[in,out]numPointer to number of groups in list
[in,out]listPointer to array of group state structures
[in,out]indexPointer to index of current group in list

The caller is responsible to free the memory allocated for the information object. The destructor function core_destroy_subscribed_group_states() should be used for this purpose.

Returns
  • 0 on success
  • Negative value on error

Definition at line 3581 of file core.c.

References group_destroy_list(), group_get_list(), core_groupstate::last_viewed, and core_groupstate::name.


Generated at 2024-04-27 using  doxygen