You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/09/30 06:23:11 UTC

[incubator-nuttx-apps] 02/02: nxstyle fixes.

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 1975f7c4852b063706b29897b9161d904362fe44
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Thu Sep 29 13:19:36 2022 +0300

    nxstyle fixes.
---
 include/graphics/tiff.h            | 11 +++++--
 netutils/thttpd/cgi-src/phf.c      | 20 ++++++-------
 netutils/thttpd/cgi-src/redirect.c | 61 +++++++++++++++++++-------------------
 netutils/thttpd/tdate_parse.c      | 25 ++++++++++++----
 netutils/thttpd/thttpd_strings.c   | 33 ++++++++++++++-------
 netutils/thttpd/timers.c           | 19 ++++++++----
 6 files changed, 104 insertions(+), 65 deletions(-)

diff --git a/include/graphics/tiff.h b/include/graphics/tiff.h
index eec234644..a857dd0fe 100644
--- a/include/graphics/tiff.h
+++ b/include/graphics/tiff.h
@@ -36,9 +36,11 @@
 /************************************************************************************
  * Pre-processor Definitions
  ************************************************************************************/
+
 /* Configuration ********************************************************************/
 
 /* TIFF File Format Definitions *****************************************************/
+
 /* Values for the IFD field type */
 
 #define IFD_FIELD_BYTE              1 /* 8-bit unsigned integer */
@@ -207,7 +209,9 @@
 /************************************************************************************
  * Public Types
  ************************************************************************************/
+
 /* TIFF File Format Structure *******************************************************/
+
 /* "A TIFF file begins with an 8-byte image file header that points to an
  *  image file directory (IFD). An image file directory contains information
  *  about the image, as well as pointers to the actual image data."
@@ -239,6 +243,7 @@ struct tiff_ifdentry_s
 #define SIZEOF_IFD_ENTRY 12
 
 /************************************************************************************/
+
 /* Structures needed to interface with the TIFF file creation library )and also
  * structures used only internally by the TIFF file creation library).
  */
@@ -381,7 +386,8 @@ int tiff_initialize(FAR struct tiff_info_s *info);
  *   the RowsPerStrip x ImageWidth values that were provided to tiff_initialize().
  *
  * Input Parameters:
- *   info    - A pointer to the caller allocated parameter passing/TIFF state instance.
+ *   info    - A pointer to the caller allocated parameter passing/TIFF state
+ *             instance.
  *   buffer  - A buffer containing a single row of data.
  *
  * Returned Value:
@@ -427,7 +433,8 @@ void tiff_abort(FAR struct tiff_info_s *info);
  * Name: tiff_put/get16/32
  *
  * Description:
- *   Put and get 16 and 32 values in the correct byte order at the specified position.
+ *   Put and get 16 and 32 values in the correct byte order at the specified
+ *   position.
  *
  * Input Parameters:
  *   dest - The location to store the multi-byte data (put only)
diff --git a/netutils/thttpd/cgi-src/phf.c b/netutils/thttpd/cgi-src/phf.c
index bd22845b2..9e065df91 100644
--- a/netutils/thttpd/cgi-src/phf.c
+++ b/netutils/thttpd/cgi-src/phf.c
@@ -67,15 +67,15 @@ int main(int argc, char *argv[])
 {
   fprintf(stderr, "phf CGI probe from %s\n", getenv("REMOTE_ADDR"));
 
-  printf("\
-Content-type: text/html\n\
-Status: 404/html\n\
-\n\
-<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD>\n\
-<BODY><H2>404 Not Found</H2>\n\
-The requested object does not exist on this server.\n\
-The link you followed is either outdated, inaccurate,\n\
-or the server has been instructed not to let you have it.\n\
-</BODY></HTML>\n");
+  printf("Content-type: text/html\n"
+         "Status: 404/html\n"
+         "\n"
+         "<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD>\n"
+         "<BODY><H2>404 Not Found</H2>\n"
+         "The requested object does not exist on this server.\n"
+         "The link you followed is either outdated, inaccurate,\n"
+         "or the server has been instructed not to let you have it.\n"
+         "</BODY></HTML>\n");
+
   return 0;
 }
diff --git a/netutils/thttpd/cgi-src/redirect.c b/netutils/thttpd/cgi-src/redirect.c
index 3c9bd6bf4..42df5f650 100644
--- a/netutils/thttpd/cgi-src/redirect.c
+++ b/netutils/thttpd/cgi-src/redirect.c
@@ -68,7 +68,7 @@
  */
 
 /****************************************************************************
- * Public Functions
+ * Included Files
  ****************************************************************************/
 
 #include <stdio.h>
@@ -100,47 +100,48 @@ static void internal_error(char *reason)
 {
   char *title = "500 Internal Error";
 
-  printf("\
-Status: %s\n\
-Content-type: text/html\n\
-\n\
-<HTML><HEAD><TITLE>%s</TITLE></HEAD>\n\
-<BODY><H2>%s</H2>\n\
-Something unusual went wrong during a redirection request:\n\
-<BLOCKQUOTE>\n\
-%s\n\
-</BLOCKQUOTE>\n\
-</BODY></HTML>\n", title, title, title, reason);
+  printf("Status: %s\n"
+         "Content-type: text/html\n"
+         "\n"
+         "<HTML><HEAD><TITLE>%s</TITLE></HEAD>\n"
+         "<BODY><H2>%s</H2>\n"
+         "Something unusual went wrong during a redirection request:\n"
+         "<BLOCKQUOTE>\n"
+         "%s\n"
+         "</BLOCKQUOTE>\n"
+         "</BODY></HTML>\n",
+         title, title, title, reason);
 }
 
 static void not_found(char *script_name)
 {
   char *title = "404 Not Found";
 
-  printf("\
-Status: %s\n\
-Content-type: text/html\n\
-\n\
-<HTML><HEAD><TITLE>%s</TITLE></HEAD>\n\
-<BODY><H2>%s</H2>\n\
-The requested filename, %s, is set up to be redirected to another URL;\n\
-however, the new URL has not yet been specified.\n\
-</BODY></HTML>\n", title, title, title, script_name);
+  printf("Status: %s\n"
+         "Content-type: text/html\n"
+         "\n"
+         "<HTML><HEAD><TITLE>%s</TITLE></HEAD>\n"
+         "<BODY><H2>%s</H2>\n"
+         "The requested filename, %s, is set up to be redirected to another "
+         "URL;\n"
+         "however, the new URL has not yet been specified.\n"
+         "</BODY></HTML>\n",
+         title, title, title, script_name);
 }
 
 static void moved(char *script_name, char *url)
 {
   char *title = "Moved";
 
-  printf("\
-Location: %s\n\
-Content-type: text/html\n\
-\n\
-<HTML><HEAD><TITLE>%s</TITLE></HEAD>\n\
-<BODY><H2>%s</H2>\n\
-The requested filename, %s, has moved to a new URL:\n\
-<A HREF=\"%s\">%s</A>.\n\
-</BODY></HTML>\n", url, title, title, script_name, url, url);
+  printf("Location: %s\n"
+         "Content-type: text/html\n"
+         "\n"
+         "<HTML><HEAD><TITLE>%s</TITLE></HEAD>\n"
+         "<BODY><H2>%s</H2>\n"
+         "The requested filename, %s, has moved to a new URL:\n"
+         "<A HREF=\"%s\">%s</A>.\n"
+         "</BODY></HTML>\n",
+         url, title, title, script_name, url, url);
 }
 
 /****************************************************************************
diff --git a/netutils/thttpd/tdate_parse.c b/netutils/thttpd/tdate_parse.c
index a29246185..de3f8851d 100644
--- a/netutils/thttpd/tdate_parse.c
+++ b/netutils/thttpd/tdate_parse.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * apps/netutils/thttpd/timers.c
+ * apps/netutils/thttpd/tdate_parse.c
  * Parse string dates into internal form, stripped-down version
  *
  *   Copyright (C) 2009 Gregory Nutt. All rights reserved.
@@ -93,11 +93,14 @@ static int strlong_compare(const void *v1, const void *v2)
 #ifdef HAVE_DAY_OF_WEEK /* Day of week not yet supported by NuttX */
 static int strlong_search(char *str, struct strlong *tab, int n, long *lP)
 {
-  int i, h, l, r;
+  int i;
+  int h;
+  int l;
+  int r;
 
   l = 0;
   h = n - 1;
-  for (;;)
+  for (; ; )
     {
       i = (h + l) / 2;
       r = strcmp(str, tab[i].s);
@@ -135,6 +138,7 @@ static int scan_wday(char *str_wday, long *tm_wdayP)
     {"fri", 5}, {"friday", 5},
     {"sat", 6}, {"saturday", 6},
   };
+
   static int sorted = 0;
 
   if (!sorted)
@@ -143,6 +147,7 @@ static int scan_wday(char *str_wday, long *tm_wdayP)
             sizeof(struct strlong), strlong_compare);
       sorted = 1;
     }
+
   pound_case(str_wday);
   return strlong_search(str_wday, wday_tab,
                         sizeof(wday_tab) / sizeof(struct strlong), tm_wdayP);
@@ -166,6 +171,7 @@ static int scan_mon(char *str_mon, long *tm_monP)
     {"nov", 10}, {"november", 10},
     {"dec", 11}, {"december", 11},
   };
+
   static int sorted = 0;
 
   if (!sorted)
@@ -174,11 +180,13 @@ static int scan_mon(char *str_mon, long *tm_monP)
             sizeof(struct strlong), strlong_compare);
       sorted = 1;
     }
+
   pound_case(str_mon);
   return strlong_search(str_mon, mon_tab,
                         sizeof(mon_tab) / sizeof(struct strlong), tm_monP);
 }
 #endif
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -213,11 +221,13 @@ time_t tdate_parse(char *str)
       continue;
     }
 
-  /* And do the sscanfs.  WARNING: you can add more formats here, but be
+  /* And do the sscanfs. WARNING: you can add more formats here, but be
    * careful! You can easily screw up the parsing of existing formats when
-   * you add new ones.  The order is important. */
+   * you add new ones. The order is important.
+   */
 
   /* DD-mth-YY HH:MM:SS GMT */
+
   if (sscanf(cp, "%d-%400[a-zA-Z]-%d %d:%d:%d GMT",
              &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min,
              &tm_sec) == 6 && scan_mon(str_mon, &tm_mon))
@@ -231,6 +241,7 @@ time_t tdate_parse(char *str)
     }
 
   /* DD mth YY HH:MM:SS GMT */
+
   else if (sscanf(cp, "%d %400[a-zA-Z] %d %d:%d:%d GMT",
                   &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min,
                   &tm_sec) == 6 && scan_mon(str_mon, &tm_mon))
@@ -244,6 +255,7 @@ time_t tdate_parse(char *str)
     }
 
   /* HH:MM:SS GMT DD-mth-YY */
+
   else if (sscanf(cp, "%d:%d:%d GMT %d-%400[a-zA-Z]-%d",
                   &tm_hour, &tm_min, &tm_sec, &tm_mday, str_mon,
                   &tm_year) == 6 && scan_mon(str_mon, &tm_mon))
@@ -257,6 +269,7 @@ time_t tdate_parse(char *str)
     }
 
   /* HH:MM:SS GMT DD mth YY */
+
   else if (sscanf(cp, "%d:%d:%d GMT %d %400[a-zA-Z] %d",
                   &tm_hour, &tm_min, &tm_sec, &tm_mday, str_mon,
                   &tm_year) == 6 && scan_mon(str_mon, &tm_mon))
@@ -335,6 +348,6 @@ time_t tdate_parse(char *str)
 
   return mktime(&tm);
 #else
-  return 0; // for now
+  return 0; /* For now. */
 #endif
 }
diff --git a/netutils/thttpd/thttpd_strings.c b/netutils/thttpd/thttpd_strings.c
index fc48d18a6..5e0e79687 100644
--- a/netutils/thttpd/thttpd_strings.c
+++ b/netutils/thttpd/thttpd_strings.c
@@ -7,8 +7,8 @@
  *
  * Derived from the file of the same name in the original THTTPD package:
  *
- *   Copyright © 1995,1998,1999,2000,2001 by Jef Poskanzer <je...@mail.acme.com>.
- *   All rights reserved.
+ *   Copyright © 1995,1998,1999,2000,2001 by Jef Poskanzer
+ *   <je...@mail.acme.com>. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -68,7 +68,8 @@ const char err302form[]  = "The actual URL is '%s'.\n";
 const char err304title[] = "Not Modified";
 
 const char httpd_err400title[]  = "Bad Request";
-const char httpd_err400form[]   = "Your request has bad syntax or is inherently impossible to satisfy.\n";
+const char httpd_err400form[]   = "Your request has bad syntax or is "
+                                  "inherently impossible to satisfy.\n";
 
 #ifdef CONFIG_THTTPD_AUTH_FILE
 const char err401title[] = "Unauthorized";
@@ -77,23 +78,29 @@ const char err401form[]  = "Authorization required for the URL '%s'.\n";
 
 const char err403title[] = "Forbidden";
 #ifndef EXPLICIT_ERROR_PAGES
-const char err403form[]  = "You do not have permission to get URL '%s' from this server.\n";
+const char err403form[]  = "You do not have permission to get URL '%s' from "
+                           "this server.\n";
 #endif
 
 const char err404title[] = "Not Found";
-const char err404form[]  = "The requested URL '%s' was not found on this server.\n";
+const char err404form[]  = "The requested URL '%s' was not found on this "
+                           "server.\n";
 
 const char httpd_err408title[]  = "Request Timeout";
-const char httpd_err408form[]   = "No request appeared within a reasonable time period.\n";
+const char httpd_err408form[]   = "No request appeared within a reasonable "
+                                  "time period.\n";
 
 const char err500title[] = "Internal Error";
-const char err500form[]  = "There was an unusual problem serving the requested URL '%s'.\n";
+const char err500form[]  = "There was an unusual problem serving the "
+                           "requested URL '%s'.\n";
 
 const char err501title[] = "Not Implemented";
-const char err501form[]  = "The requested method '%s' is not implemented by this server.\n";
+const char err501form[]  = "The requested method '%s' is not implemented by "
+                           "this server.\n";
 
 const char httpd_err503title[] = "Service Temporarily Overloaded";
-const char httpd_err503form[]  = "The requested URL '%s' is temporarily overloaded.  Please try again later.\n";
+const char httpd_err503form[]  = "The requested URL '%s' is temporarily "
+                                 "overloaded. Please try again later.\n";
 
 /* HTML strings */
 
@@ -102,7 +109,8 @@ const char html_html[]      = "<HTML>\r\n";
 const char html_endhtml[]   = "</HTML>\r\n";
 const char html_hdtitle[]   = "<HEAD><TITLE>";
 const char html_titlehd[]   = "</TITLE></HEAD>\r\n";
-const char html_body[]      = "<BODY BGCOLOR=\"#99cc99\" TEXT=\"#000000\" LINK=\"#2020ff\" VLINK=\"#4040cc\">\r\n";
+const char html_body[]      = "<BODY BGCOLOR=\"#99cc99\" TEXT=\"#000000\" "
+                              "LINK=\"#2020ff\" VLINK=\"#4040cc\">\r\n";
 const char html_endbody[]   = "</BODY>\r\n";
 const char html_hdr2[]      = "<H2>";
 const char html_endhdr2[]   = "</H2>";
@@ -125,6 +133,7 @@ static int hexit(char nibble)
     {
       return nibble - 'A' + 10;
     }
+
   return 0;
 }
 
@@ -132,7 +141,7 @@ static int hexit(char nibble)
  * Public Functions
  ****************************************************************************/
 
-/* Copies and decodes a string.  It's ok for from and to to be the same string. */
+/* Copies and decodes a string. "from" and "to" can be the same string. */
 
 void httpd_strdecode(char *to, char *from)
 {
@@ -148,6 +157,7 @@ void httpd_strdecode(char *to, char *from)
           *to = *from;
         }
     }
+
   *to = '\0';
 }
 
@@ -173,6 +183,7 @@ void httpd_strencode(char *to, int tosize, char *from)
           tolen += 3;
         }
     }
+
   *to = '\0';
 }
 #endif /* CONFIG_THTTPD_GENERATE_INDICES */
diff --git a/netutils/thttpd/timers.c b/netutils/thttpd/timers.c
index 46b250a6b..074e12942 100644
--- a/netutils/thttpd/timers.c
+++ b/netutils/thttpd/timers.c
@@ -92,6 +92,7 @@ static void l_add(Timer *tmr)
   if (tmr2 == NULL)
     {
       /* The list is empty. */
+
       timers[h] = tmr;
       tmr->prev = tmr->next = NULL;
     }
@@ -120,6 +121,7 @@ static void l_add(Timer *tmr)
                    tmr->time.tv_usec <= tmr2->time.tv_usec))
                 {
                   /* Found it. */
+
                   tmr2prev->next = tmr;
                   tmr->prev = tmr2prev;
                   tmr->next = tmr2;
@@ -227,6 +229,7 @@ Timer *tmr_create(struct timeval *now, TimerProc *timer_proc,
       tmr->time.tv_sec  += tmr->time.tv_usec / 1000000L;
       tmr->time.tv_usec %= 1000000L;
     }
+
   tmr->hash = hash(tmr);
 
   /* Add the new timer to the proper active list. */
@@ -239,14 +242,15 @@ long tmr_mstimeout(struct timeval *now)
 {
   int h;
   int gotone;
-  long msecs, m;
+  long msecs;
+  long m;
   register Timer *tmr;
 
   gotone = 0;
   msecs  = 0;
 
-  /* Since the lists are sorted, we only need to look at the  * first timer on
-   * each one.
+  /* Since the lists are sorted, we only need to look at the first timer
+   * on each one.
    */
 
   for (h = 0; h < HASH_SIZE; ++h)
@@ -293,12 +297,13 @@ void tmr_run(struct timeval *now)
         {
           next = tmr->next;
 
-          /* Since the lists are sorted, as soon as we find a timer  * that isn'tmr
-           * ready yet, we can go on to the next list
+          /* Since the lists are sorted, as soon as we find a timer that
+           * isn't ready yet, we can go on to the next list.
            */
 
           if (tmr->time.tv_sec > now->tv_sec ||
-              (tmr->time.tv_sec == now->tv_sec && tmr->time.tv_usec > now->tv_usec))
+              (tmr->time.tv_sec == now->tv_sec &&
+               tmr->time.tv_usec > now->tv_usec))
             {
               break;
             }
@@ -315,6 +320,7 @@ void tmr_run(struct timeval *now)
                   tmr->time.tv_sec += tmr->time.tv_usec / 1000000L;
                   tmr->time.tv_usec %= 1000000L;
                 }
+
               l_resort(tmr);
             }
           else
@@ -361,5 +367,6 @@ void tmr_destroy(void)
           tmr_cancel(timers[h]);
         }
     }
+
   tmr_cleanup();
 }