Skip to content

Commit

Permalink
INEWS_changeApprovalStatus() and INEWS_changeDeletionStatus() now suc…
Browse files Browse the repository at this point in the history
…ceed without going to the network if their respective flags are already set.

Renamed a parameter to fix problems with C++ compilers.
  • Loading branch information
vogon committed Oct 18, 2002
1 parent 585316f commit 79b6253
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libinews/IcculusNews.h
Expand Up @@ -149,7 +149,7 @@ extern Sint8 INEWS_submitArticle(char *title, char *body);
Sint8 INEWS_changeApprovalStatus(Uint32 aid, bool approve);

/* change the deletion status of article aid */
Sint8 INEWS_changeDeletionStatus(Uint32 aid, bool delete);
Sint8 INEWS_changeDeletionStatus(Uint32 aid, bool deleteflag);

/* free the memory dynamically allocated by a call to INEWS_digest */
extern void INEWS_freeDigest(ArticleInfo **digest);
Expand Down
2 changes: 1 addition & 1 deletion libinews/internals.h
Expand Up @@ -95,7 +95,7 @@ Sint8 INEWS_changeQueue(int qid);
ArticleInfo **INEWS_digest(int offset, int n);
Sint8 INEWS_submitArticle(char *title, char *body);
Sint8 INEWS_changeApprovalStatus(Uint32 aid, bool approve);
Sint8 INEWS_changeDeletionStatus(Uint32 aid, bool delete);
Sint8 INEWS_changeDeletionStatus(Uint32 aid, bool deleteflag);
void INEWS_disconnect();

Sint8 __read_line(char *str, int max_sz);
Expand Down
25 changes: 22 additions & 3 deletions libinews/net.c
Expand Up @@ -357,7 +357,7 @@ ArticleInfo **INEWS_digest(int offset, int n) {
if (offset > 0)
sprintf(off_str, "%i", offset);
else
sprintf(off_str, "-", offset);
sprintf(off_str, "-");

sprintf(tempstring, "DIGEST %s %i\n", off_str, n);

Expand Down Expand Up @@ -533,6 +533,7 @@ Sint8 INEWS_submitArticle(char *title, char *body) {

Sint8 INEWS_changeApprovalStatus(Uint32 aid, bool approve) {
char tempstring[256];
ArticleInfo **artinfo;

if (!serverstate.connected) {
__inews_errno = ERR_DISCONNECTED;
Expand All @@ -544,6 +545,17 @@ Sint8 INEWS_changeApprovalStatus(Uint32 aid, bool approve) {
goto end_failure;
}

artinfo = INEWS_digest(aid + 1, 1);
if (artinfo[0]->approved == approve) {
INEWS_freeDigest(artinfo);
goto end_success;
} else if (artinfo[0]->deleted) {
INEWS_freeDigest(artinfo);
__inews_errno = ERR_GENERIC;
goto end_failure;
} else INEWS_freeDigest(artinfo);


memset(tempstring, 0, 256);

if (approve) {
Expand Down Expand Up @@ -593,8 +605,9 @@ Sint8 INEWS_changeApprovalStatus(Uint32 aid, bool approve) {
FUNC_END(0, -1);
}

Sint8 INEWS_changeDeletionStatus(Uint32 aid, bool delete) {
Sint8 INEWS_changeDeletionStatus(Uint32 aid, bool deleteflag) {
char tempstring[256];
ArticleInfo **artinfo;

if (!serverstate.connected) {
__inews_errno = ERR_DISCONNECTED;
Expand All @@ -606,9 +619,15 @@ Sint8 INEWS_changeDeletionStatus(Uint32 aid, bool delete) {
goto end_failure;
}

artinfo = INEWS_digest(aid + 1, 1);
if (artinfo[0]->deleted == deleteflag) {
INEWS_freeDigest(artinfo);
goto end_success;
} else INEWS_freeDigest(artinfo);

memset(tempstring, 0, 256);

if (delete) {
if (deleteflag) {
sprintf(tempstring, "DELETE %i\n", aid);
} else {
sprintf(tempstring, "UNDELETE %i\n", aid);
Expand Down

0 comments on commit 79b6253

Please sign in to comment.