void SMSDSQL_Time2String(GSM_SMSDConfig * Config, time_t timestamp, char *static_buff, size_t size) { struct tm *timestruct; const char *driver_name; driver_name = SMSDSQL_SQLName(Config); if (timestamp == -2) { strcpy(static_buff, "0000-00-00 00:00:00"); } else if (strcasecmp(driver_name, "pgsql") == 0 || strcasecmp(driver_name, "native_pgsql") == 0) { timestruct = gmtime(×tamp); strftime(static_buff, size, "%Y-%m-%d %H:%M:%S GMT", timestruct); } else if (strcasecmp(driver_name, "access") == 0) { timestruct = gmtime(×tamp); strftime(static_buff, size, "'%Y-%m-%d %H:%M:%S'", timestruct); } else if (strcasecmp(driver_name, "mysql") == 0 || strcasecmp(driver_name, "native_mysql") == 0) { timestruct = localtime(×tamp); strftime(static_buff, size, "%Y-%m-%d %H:%M:%S", timestruct); } else if (strcasecmp(Config->driver, "odbc") == 0) { timestruct = gmtime(×tamp); strftime(static_buff, size, "{ ts '%Y-%m-%d %H:%M:%S' }", timestruct); } else { timestruct = localtime(×tamp); strftime(static_buff, size, "%Y-%m-%d %H:%M:%S", timestruct); } }
static const char *SMSDSQL_LimitClause(GSM_SMSDConfig * Config, const char *count) { const char *driver_name; static char result[100]; driver_name = SMSDSQL_SQLName(Config); if (strcasecmp(driver_name, "access") == 0) { return limit_clause_access; } else { strcpy(result, limit_clause_fallback); strcat(result, " "); strcat(result, count); return result; } }
static const char *SMSDSQL_EscapeChar(GSM_SMSDConfig * Config) { const char *driver_name; driver_name = SMSDSQL_SQLName(Config); if (strcasecmp(driver_name, "mysql") == 0 || strcasecmp(driver_name, "native_mysql") == 0) { return escape_char_mysql; } else if (strcasecmp(driver_name, "pgsql") == 0 || strcasecmp(driver_name, "native_pgsql") == 0) { return escape_char_pgsql; } else if (strncasecmp(driver_name, "sqlite", 6) == 0) { return escape_char_sqlite; } else if (strcasecmp(driver_name, "freetds") == 0 || strcasecmp(driver_name, "mssql") == 0 || strcasecmp(driver_name, "sybase") == 0) { return escape_char_freetds; } else if (strcasecmp(Config->driver, "odbc") == 0) { return escape_char_odbc; } else { return escape_char_fallback; } }
static const char *SMSDSQL_NowPlus(GSM_SMSDConfig * Config, int seconds) { const char *driver_name; static char result[100]; driver_name = SMSDSQL_SQLName(Config); if (strcasecmp(driver_name, "mysql") == 0 || strcasecmp(driver_name, "native_mysql") == 0) { sprintf(result, now_plus_mysql, seconds); } else if (strcasecmp(driver_name, "pgsql") == 0 || strcasecmp(driver_name, "native_pgsql") == 0) { sprintf(result, now_plus_pgsql, seconds); } else if (strncasecmp(driver_name, "sqlite", 6) == 0) { sprintf(result, now_plus_sqlite, seconds); } else if (strcasecmp(driver_name, "freetds") == 0) { sprintf(result, now_plus_freetds, seconds); } else if (strcasecmp(driver_name, "access") == 0) { sprintf(result, now_plus_access, seconds); } else if (strcasecmp(driver_name, "odbc") == 0) { sprintf(result, now_plus_odbc, seconds); } else { sprintf(result, now_plus_fallback, seconds); } return result; }