Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_database.c

    r18 r30  
    4040#include "sh_error.h"
    4141#include "sh_utils.h"
    42 
    43 extern int safe_logger (int signal, int method, pid_t thepid);
    4442
    4543#undef  FIL__
     
    227225typedef unsigned char uint8;
    228226
    229 typedef struct
    230 {
    231         uint32 h[4];
    232         uint32 data[16];
    233         uint8  offset;
    234         uint32  nblocks;
    235         int  count;
     227typedef struct md5_ctx
     228{
     229  uint32 A;
     230  uint32 B;
     231  uint32 C;
     232  uint32 D;
     233
     234  uint32 total[2];
     235  uint32 buflen;
     236  char buffer[128];
    236237} md5Param;
    237 
    238238
    239239
     
    253253static int  sh_persistent_dbconn = S_TRUE;
    254254
    255 int sh_database_use_persistent (char * str)
     255int sh_database_use_persistent (const char * str)
    256256{
    257257  return sh_util_flagval (str, &sh_persistent_dbconn);
    258258}
    259259
    260 static int insert_value (char * ptr, char * str)
     260static int insert_value (char * ptr, const char * str)
    261261{
    262262  if (!ptr || !str)
     
    276276 
    277277
    278 int sh_database_set_database (char * str)
     278int sh_database_set_database (const char * str)
    279279{
    280280  return insert_value (db_name, str);
    281281}
    282 int sh_database_set_table (char * str)
     282int sh_database_set_table (const char * str)
    283283{
    284284  return insert_value (db_table, str);
    285285}
    286 int sh_database_set_host (char * str)
     286int sh_database_set_host (const char * str)
    287287{
    288288  return insert_value (db_host, str);
    289289}
    290 int sh_database_set_user (char * str)
     290int sh_database_set_user (const char * str)
    291291{
    292292  return insert_value (db_user, str);
    293293}
    294 int sh_database_set_password (char * str)
     294int sh_database_set_password (const char * str)
    295295{
    296296  return insert_value (db_password, str);
     
    568568 oracle_doconnect:
    569569
    570   if (!getenv("ORACLE_HOME"))
     570  if (!getenv("ORACLE_HOME")) /* flawfinder: ignore */
    571571    {
    572572      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
     
    11941194        }
    11951195    }
    1196 #if 0
    1197   /* apparently slower, see gyule.7 */
    1198   len = (long) strlen(val);
    1199 
    1200   if ((val[0] != '\0') && (*size > 2))
    1201     {
    1202       if (flag == 1)
    1203         {
    1204           *end = ',';  ++end;
    1205           *end = '\''; ++end; (*size) -= 2;
    1206           *end = '\0';
    1207        
    1208           if ((long) *size > (len+2))
    1209             {
    1210               (void) sl_strlcat(end, val, (size_t) *size);
    1211               end   += len; (*size) -= len;
    1212               *end = '\''; ++end;  (*size) -= 1;
    1213             }
    1214           *end = '\0';
    1215         }
    1216       else
    1217         {
    1218           *end = ',';  ++end; (*size) -= 1;
    1219           *end = '\0';
    1220        
    1221           if ((long) *size > (len+1))
    1222             {
    1223               (void) sl_strlcat(end, val, (size_t) *size);
    1224               end   += len; (*size) -= len;
    1225             }
    1226           *end = '\0';
    1227         }
    1228     }
    1229 #endif
     1196
    12301197  return end;
    12311198}
     
    14821449}
    14831450
    1484 int sh_database_add_to_hash  (char * str)
     1451int sh_database_add_to_hash  (const char * str)
    14851452{
    14861453  int i;
     
    16921659static int enter_wrapper = 1;
    16931660
    1694 int set_enter_wrapper (char * str)
     1661int set_enter_wrapper (const char * str)
    16951662{
    16961663  return sh_util_flagval(str, &enter_wrapper);
    16971664}
    16981665
     1666/* recursively enter linked list of messages into database, last first
     1667 */
     1668int sh_database_insert_rec (dbins * curr, unsigned int depth)
     1669{
     1670  long    id = 0;
     1671  dbins * prev;
     1672
     1673  SL_ENTER(_("sh_database_insert_rec"));
     1674
     1675  if (curr->next)
     1676    {
     1677      prev = curr->next;
     1678      sl_strlcpy(prev->host, curr->host, 64);
     1679      id = sh_database_insert_rec (curr->next, (depth + 1));
     1680    }
     1681
     1682  if (id != 0)                       /* this is a server wrapper          */
     1683    {
     1684      if (enter_wrapper != 0)
     1685        {
     1686          id = sh_database_entry (curr, id);
     1687        }
     1688    }
     1689  else
     1690    {
     1691      /*
     1692       * id = -1 is the client message; log_ref will be NULL
     1693       */
     1694      if (depth > 0)                  /* this is a client message         */
     1695        id = sh_database_entry (curr, -1);
     1696      else                            /* this is a generic server message */
     1697        id = sh_database_entry (curr, 0);
     1698    }
     1699
     1700  SH_FREE(curr);
     1701
     1702  SL_RETURN(id, _("sh_database_insert"));
     1703}
     1704
    16991705int sh_database_insert (char * message)
    17001706{
    17011707  dbins * db_entry;
    1702   dbins * prev;
    1703   dbins * curr;
    1704   long    id = 0;
    1705 #ifdef HOST_SWITCH
    1706   char  * temp[64];
    1707 #endif
    17081708
    17091709  SL_ENTER(_("sh_database_insert"));
     
    17161716  (void) sh_database_parse (message, db_entry);
    17171717
    1718   /* Enter the list into the database. Actually, the list can only have
    1719    * two entries at most.
    1720    */
    1721   curr = db_entry;
    1722   if (curr->next)
    1723     {
    1724       prev = curr->next;
    1725 #ifdef HOST_SWITCH
    1726       strncpy(temp, prev->host,       64);
     1718  /* recursively enter the linked list into the database
     1719   */
     1720  (void) sh_database_insert_rec (db_entry, 0);
     1721
     1722  SL_RETURN(0, _("sh_database_insert"));
     1723}
     1724
    17271725#endif
    1728       strncpy(prev->host, curr->host, 64);
    1729 #ifdef HOST_SWITCH
    1730       strncpy(curr->host, temp,       64);
    1731 #endif
    1732       id = sh_database_entry (prev, -1);
    1733       SH_FREE(prev);
    1734     }
    1735 
    1736   if (id != 0)                       /* this is a server wrapper          */
    1737     {
    1738       if (enter_wrapper != 0)
    1739         (void) sh_database_entry (curr, id);
    1740     }
    1741   else                                /* this is a generic server message */
    1742     {
    1743       (void) sh_database_entry (curr, 0);
    1744     }
    1745   SH_FREE(curr);
    1746 
    1747   SL_RETURN(0, _("sh_database_insert"));
    1748 }
    1749 
    1750 #endif
Note: See TracChangeset for help on using the changeset viewer.