remove lots of useless checks of the result of ast_strdupa
[asterisk/asterisk.git] / apps / app_sayunixtime.c
old mode 100755 (executable)
new mode 100644 (file)
index 0abce7b..4739d97
  *
  */
 
-/*
+/*! \file
+ *
+ * \brief SayUnixTime application
  *
- * SayUnixTime application
+ * \author Tilghman Lesher <app_sayunixtime__200309@the-tilghman.com>
  * 
+ * \ingroup applications
  */
 
 #include <stdio.h>
@@ -53,8 +56,7 @@ static char *sayunixtime_descrip =
 "  timezone: timezone, see /usr/share/zoneinfo for a list.\n"
 "              defaults to machine default.\n"
 "  format:   a format the time is to be said in.  See voicemail.conf.\n"
-"              defaults to \"ABdY 'digits/at' IMp\"\n"
-"  Returns 0 or -1 on hangup.\n";
+"              defaults to \"ABdY 'digits/at' IMp\"\n";
 static char *datetime_descrip =
 "DateTime([unixtime][|[timezone][|format]])\n"
 "  unixtime: time, in seconds since Jan 1, 1970.  May be negative.\n"
@@ -62,8 +64,7 @@ static char *datetime_descrip =
 "  timezone: timezone, see /usr/share/zoneinfo for a list.\n"
 "              defaults to machine default.\n"
 "  format:   a format the time is to be said in.  See voicemail.conf.\n"
-"              defaults to \"ABdY 'digits/at' IMp\"\n"
-"  Returns 0 or -1 on hangup.\n";
+"              defaults to \"ABdY 'digits/at' IMp\"\n";
 
 STANDARD_LOCAL_USER;
 
@@ -91,26 +92,21 @@ static int sayunixtime_exec(struct ast_channel *chan, void *data)
        } 
 
        if (data) {
-               s = data;
-               s = ast_strdupa(s);
-               if (s) {
-                       timec = strsep(&s,"|");
-                       if ((timec) && (*timec != '\0')) {
-                               long timein;
-                               if (sscanf(timec,"%ld",&timein) == 1) {
-                                       unixtime = (time_t)timein;
-                               }
+               s = ast_strdupa(data);
+               timec = strsep(&s,"|");
+               if ((timec) && (*timec != '\0')) {
+                       long timein;
+                       if (sscanf(timec,"%ld",&timein) == 1) {
+                               unixtime = (time_t)timein;
                        }
+               }
+               if (s) {
+                       zone = strsep(&s,"|");
+                       if (zone && (*zone == '\0'))
+                               zone = NULL;
                        if (s) {
-                               zone = strsep(&s,"|");
-                               if (zone && (*zone == '\0'))
-                                       zone = NULL;
-                               if (s) {
-                                       format = s;
-                               }
+                               format = s;
                        }
-               } else {
-                       ast_log(LOG_ERROR, "Out of memory error\n");
                }
        }