Changeset 27 for trunk/src/sh_database.c
- Timestamp:
- Apr 6, 2006, 8:55:51 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_database.c
r22 r27 1192 1192 } 1193 1193 } 1194 #if 0 1195 /* apparently slower, see gyule.7 */ 1196 len = (long) strlen(val); 1197 1198 if ((val[0] != '\0') && (*size > 2)) 1199 { 1200 if (flag == 1) 1201 { 1202 *end = ','; ++end; 1203 *end = '\''; ++end; (*size) -= 2; 1204 *end = '\0'; 1205 1206 if ((long) *size > (len+2)) 1207 { 1208 (void) sl_strlcat(end, val, (size_t) *size); 1209 end += len; (*size) -= len; 1210 *end = '\''; ++end; (*size) -= 1; 1211 } 1212 *end = '\0'; 1213 } 1214 else 1215 { 1216 *end = ','; ++end; (*size) -= 1; 1217 *end = '\0'; 1218 1219 if ((long) *size > (len+1)) 1220 { 1221 (void) sl_strlcat(end, val, (size_t) *size); 1222 end += len; (*size) -= len; 1223 } 1224 *end = '\0'; 1225 } 1226 } 1227 #endif 1194 1228 1195 return end; 1229 1196 } … … 1695 1662 } 1696 1663 1664 /* recursively enter linked list of messages into database, last first 1665 */ 1666 int sh_database_insert_rec (dbins * curr, unsigned int depth) 1667 { 1668 long id = 0; 1669 dbins * prev; 1670 1671 SL_ENTER(_("sh_database_insert_rec")); 1672 1673 if (curr->next) 1674 { 1675 prev = curr->next; 1676 sl_strlcpy(prev->host, curr->host, 64); 1677 id = sh_database_insert_rec (curr->next, (depth + 1)); 1678 } 1679 1680 if (id != 0) /* this is a server wrapper */ 1681 { 1682 if (enter_wrapper != 0) 1683 { 1684 id = sh_database_entry (curr, id); 1685 } 1686 } 1687 else 1688 { 1689 /* 1690 * id = -1 is the client message; log_ref will be NULL 1691 */ 1692 if (depth > 0) /* this is a client message */ 1693 id = sh_database_entry (curr, -1); 1694 else /* this is a generic server message */ 1695 id = sh_database_entry (curr, 0); 1696 } 1697 1698 SH_FREE(curr); 1699 1700 SL_RETURN(id, _("sh_database_insert")); 1701 } 1702 1697 1703 int sh_database_insert (char * message) 1698 1704 { 1699 1705 dbins * db_entry; 1700 dbins * prev;1701 dbins * curr;1702 long id = 0;1703 #ifdef HOST_SWITCH1704 char * temp[64];1705 #endif1706 1706 1707 1707 SL_ENTER(_("sh_database_insert")); … … 1714 1714 (void) sh_database_parse (message, db_entry); 1715 1715 1716 /* Enter the list into the database. Actually, the list can only have 1717 * two entries at most. 1718 */ 1719 curr = db_entry; 1720 if (curr->next) 1721 { 1722 prev = curr->next; 1723 #ifdef HOST_SWITCH 1724 strncpy(temp, prev->host, 64); 1716 /* recursively enter the linked list into the database 1717 */ 1718 (void) sh_database_insert_rec (db_entry, 0); 1719 1720 SL_RETURN(0, _("sh_database_insert")); 1721 } 1722 1725 1723 #endif 1726 strncpy(prev->host, curr->host, 64);1727 #ifdef HOST_SWITCH1728 strncpy(curr->host, temp, 64);1729 #endif1730 id = sh_database_entry (prev, -1);1731 SH_FREE(prev);1732 }1733 1734 if (id != 0) /* this is a server wrapper */1735 {1736 if (enter_wrapper != 0)1737 (void) sh_database_entry (curr, id);1738 }1739 else /* this is a generic server message */1740 {1741 (void) sh_database_entry (curr, 0);1742 }1743 SH_FREE(curr);1744 1745 SL_RETURN(0, _("sh_database_insert"));1746 }1747 1748 #endif
Note:
See TracChangeset
for help on using the changeset viewer.