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