client_passwords.c: style cleanup
authorArt Cancro <ajc@citadel.org>
Tue, 4 Jul 2023 17:35:27 +0000 (08:35 -0900)
committerArt Cancro <ajc@citadel.org>
Tue, 4 Jul 2023 17:35:27 +0000 (08:35 -0900)
textclient/client_passwords.c

index 59c9c04238912703a7863d0f6b30265666b7a558..f4e0a89fa3218a0ae887c07f0be8d7ed8ea91601 100644 (file)
@@ -1,15 +1,10 @@
 // Functions which allow the client to remember usernames and passwords for
 // various sites.
 //
-// Copyright (c) 1987-2016 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, and/or
 // disclosure are subject to the GNU General Purpose License version 3.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
 
 #include "textclient.h"
 
@@ -25,10 +20,8 @@ void determine_pwfilename(char *pwfile, size_t n) {
 }
 
 
-/*
- * Check the password file for a host/port match; if found, stuff the user
- * name and password into the user/pass buffers
- */
+// Check the password file for a host/port match; if found, stuff the user
+// name and password into the user/pass buffers
 void get_stored_password(char *host, char *port, char *username, char *password) {
 
        char pwfile[PATH_MAX];
@@ -45,8 +38,9 @@ void get_stored_password(char *host, char *port, char *username, char *password)
                return;
 
        fp = fopen(pwfile, "r");
-       if (fp == NULL)
+       if (fp == NULL) {
                return;
+       }
        while (fgets(buf64, sizeof buf64, fp) != NULL) {
                CtdlDecodeBase64(buf, buf64, sizeof(buf64));
                extract_token(hostbuf, buf, 0, '|', sizeof hostbuf);
@@ -65,9 +59,7 @@ void get_stored_password(char *host, char *port, char *username, char *password)
 }
 
 
-/*
- * Set (or clear) stored passwords.
- */
+// Set (or clear) stored passwords.
 void set_stored_password(char *host, char *port, char *username, char *password) {
 
        char pwfile[PATH_MAX];
@@ -81,12 +73,14 @@ void set_stored_password(char *host, char *port, char *username, char *password)
                return;
 
        oldfp = fopen(pwfile, "r");
-       if (oldfp == NULL)
+       if (oldfp == NULL) {
                oldfp = fopen("/dev/null", "r");
+       }
        unlink(pwfile);
        fp = fopen(pwfile, "w");
-       if (fp == NULL)
+       if (fp == NULL) {
                fp = fopen("/dev/null", "w");
+       }
        while (fgets(buf64, sizeof buf64, oldfp) != NULL) {
                CtdlDecodeBase64(buf, buf64, sizeof(buf64));
                extract_token(hostbuf, buf, 0, '|', sizeof hostbuf);
@@ -94,8 +88,7 @@ void set_stored_password(char *host, char *port, char *username, char *password)
                extract_token(ubuf, buf, 2, '|', sizeof ubuf);
                extract_token(pbuf, buf, 3, '|', sizeof pbuf);
 
-               if ((strcasecmp(hostbuf, host))
-                   || (strcasecmp(portbuf, port))) {
+               if ((strcasecmp(hostbuf, host)) || (strcasecmp(portbuf, port))) {
                        snprintf(buf, sizeof buf, "%s|%s|%s|%s|", hostbuf, portbuf, ubuf, pbuf);
                        CtdlEncodeBase64(buf64, buf, strlen(buf), BASE64_NO_LINEBREAKS);
                        fprintf(fp, "%s\n", buf64);
@@ -112,9 +105,7 @@ void set_stored_password(char *host, char *port, char *username, char *password)
 }
 
 
-/*
- * Set the password if the user wants to, clear it otherwise 
- */
+// Set the password if the user wants to, clear it otherwise 
 void offer_to_remember_password(CtdlIPC * ipc, char *host, char *port, char *username, char *password) {
 
        if (rc_remember_passwords) {