Changes in trunk/src/sh_database.c [18:30]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_database.c
r18 r30 40 40 #include "sh_error.h" 41 41 #include "sh_utils.h" 42 43 extern int safe_logger (int signal, int method, pid_t thepid);44 42 45 43 #undef FIL__ … … 227 225 typedef unsigned char uint8; 228 226 229 typedef struct 230 { 231 uint32 h[4]; 232 uint32 data[16]; 233 uint8 offset; 234 uint32 nblocks; 235 int count; 227 typedef 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]; 236 237 } md5Param; 237 238 238 239 239 … … 253 253 static int sh_persistent_dbconn = S_TRUE; 254 254 255 int sh_database_use_persistent (c har * str)255 int sh_database_use_persistent (const char * str) 256 256 { 257 257 return sh_util_flagval (str, &sh_persistent_dbconn); 258 258 } 259 259 260 static int insert_value (char * ptr, c har * str)260 static int insert_value (char * ptr, const char * str) 261 261 { 262 262 if (!ptr || !str) … … 276 276 277 277 278 int sh_database_set_database (c har * str)278 int sh_database_set_database (const char * str) 279 279 { 280 280 return insert_value (db_name, str); 281 281 } 282 int sh_database_set_table (c har * str)282 int sh_database_set_table (const char * str) 283 283 { 284 284 return insert_value (db_table, str); 285 285 } 286 int sh_database_set_host (c har * str)286 int sh_database_set_host (const char * str) 287 287 { 288 288 return insert_value (db_host, str); 289 289 } 290 int sh_database_set_user (c har * str)290 int sh_database_set_user (const char * str) 291 291 { 292 292 return insert_value (db_user, str); 293 293 } 294 int sh_database_set_password (c har * str)294 int sh_database_set_password (const char * str) 295 295 { 296 296 return insert_value (db_password, str); … … 568 568 oracle_doconnect: 569 569 570 if (!getenv("ORACLE_HOME")) 570 if (!getenv("ORACLE_HOME")) /* flawfinder: ignore */ 571 571 { 572 572 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN, … … 1194 1194 } 1195 1195 } 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 1230 1197 return end; 1231 1198 } … … 1482 1449 } 1483 1450 1484 int sh_database_add_to_hash (c har * str)1451 int sh_database_add_to_hash (const char * str) 1485 1452 { 1486 1453 int i; … … 1692 1659 static int enter_wrapper = 1; 1693 1660 1694 int set_enter_wrapper (c har * str)1661 int set_enter_wrapper (const char * str) 1695 1662 { 1696 1663 return sh_util_flagval(str, &enter_wrapper); 1697 1664 } 1698 1665 1666 /* recursively enter linked list of messages into database, last first 1667 */ 1668 int 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 1699 1705 int sh_database_insert (char * message) 1700 1706 { 1701 1707 dbins * db_entry; 1702 dbins * prev;1703 dbins * curr;1704 long id = 0;1705 #ifdef HOST_SWITCH1706 char * temp[64];1707 #endif1708 1708 1709 1709 SL_ENTER(_("sh_database_insert")); … … 1716 1716 (void) sh_database_parse (message, db_entry); 1717 1717 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 1727 1725 #endif 1728 strncpy(prev->host, curr->host, 64);1729 #ifdef HOST_SWITCH1730 strncpy(curr->host, temp, 64);1731 #endif1732 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.