diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-25 13:19:26 +0200 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-25 13:19:26 +0200 |
| commit | f1ad96ffe75beb6e7441d4a23a0f29e4e7f2e05a (patch) | |
| tree | 4c3e884811e480867e11dfb3eb29153e1845b377 /database | |
| parent | 3b79f0183dde8e2b2694dc26da836c75640d8c5d (diff) | |
| download | eurephia-f1ad96ffe75beb6e7441d4a23a0f29e4e7f2e05a.tar.gz eurephia-f1ad96ffe75beb6e7441d4a23a0f29e4e7f2e05a.tar.xz eurephia-f1ad96ffe75beb6e7441d4a23a0f29e4e7f2e05a.zip | |
Rewrote the eDBmkSortKeys() function to use the eDBfieldMap returned from eDBxmlMapping()
Diffstat (limited to 'database')
| -rw-r--r-- | database/eurephiadb_mapping.c | 17 | ||||
| -rw-r--r-- | database/eurephiadb_mapping.h | 2 | ||||
| -rw-r--r-- | database/sqlite/administration/certificates.c | 4 | ||||
| -rw-r--r-- | database/sqlite/administration/usercerts.c | 4 |
4 files changed, 15 insertions, 12 deletions
diff --git a/database/eurephiadb_mapping.c b/database/eurephiadb_mapping.c index 3a2513a..dbb44d7 100644 --- a/database/eurephiadb_mapping.c +++ b/database/eurephiadb_mapping.c @@ -352,9 +352,8 @@ eDBfieldMap *eDBxmlMapping(eurephiaCTX *ctx, eDBfieldMap *dbmap, const char *tbl * @return Returns a comma separated string with translated field names on success, otherwise NULL. * @remark The resulting pointer is pointing at a static char pointer and should not be freed. */ -char *eDBmkSortKeyString(eDBfieldMap *tfmap, const char *skeys_str) { - eDBfieldMap *sk_map = NULL, *ptr1 = NULL; - int i; +const char *eDBmkSortKeyString(eDBfieldMap *tfmap, const char *skeys_str) { + eDBfieldMap *sk_map = NULL, *ptr1 = NULL, *tfmp = NULL; char *cp = NULL, *tok = NULL, *delims = ","; static char sortkeys[8194]; @@ -378,10 +377,14 @@ char *eDBmkSortKeyString(eDBfieldMap *tfmap, const char *skeys_str) { // If we find the the field in the unified mapping table ... if( strcmp(tok, ptr1->field_name) == 0 ) { // look up the proper field name for the current database - for( i = 0; tfmap[i].field_type != FIELD_NONE; i++ ) { - if( ptr1->field_id == tfmap[i].field_id ) { - strncat(sortkeys, tfmap[i].field_name, (8192-strlen(sortkeys)-2)); - strcat(sortkeys,","); + for( tfmp = tfmap; tfmp != NULL; tfmp = tfmp->next ) { + if( ptr1->field_id == tfmp->field_id ) { + if( tfmp->table_alias != NULL ) { + append_str(sortkeys, tfmp->table_alias, 8192); + append_str(sortkeys, ".", 8192); + } + append_str(sortkeys, tfmp->field_name, 8192); + append_str(sortkeys, ",", 8192); } } } diff --git a/database/eurephiadb_mapping.h b/database/eurephiadb_mapping.h index 262231e..37c9f44 100644 --- a/database/eurephiadb_mapping.h +++ b/database/eurephiadb_mapping.h @@ -262,7 +262,7 @@ static eDBfieldMap eTblMap_fwprofiles[] = { void eDBfreeMapping(eDBfieldMap *p); eDBfieldMap *eDBxmlMapping(eurephiaCTX *ctx, eDBfieldMap *dbmap, const char *tblalias, xmlNode *fmap_n); -char *eDBmkSortKeyString(eDBfieldMap *tfmap, const char *skeys_str); +const char *eDBmkSortKeyString(eDBfieldMap *tfmap, const char *skeys_str); long int eDBmappingFieldsPresent(eDBfieldMap *map); const char *eDBmappingGetValue(eDBfieldMap *map, long field_id); diff --git a/database/sqlite/administration/certificates.c b/database/sqlite/administration/certificates.c index 53b50c2..e00de73 100644 --- a/database/sqlite/administration/certificates.c +++ b/database/sqlite/administration/certificates.c @@ -267,8 +267,8 @@ xmlDoc *eDBadminCertificate(eurephiaCTX *ctx, xmlDoc *qryxml) { fmap = eDBxmlMapping(ctx, tbl_sqlite_certs, NULL, fieldmap_n); if( strcmp(mode, "list") == 0 ) { - char *sortkeys = xmlGetNodeContent(root_n, "sortkeys"); - resxml = certificate_list(ctx, fmap, eDBmkSortKeyString(tbl_sqlite_certs, sortkeys)); + char *sortkeys = xmlGetNodeContent(root_n, "sortkeys"); + resxml = certificate_list(ctx, fmap, eDBmkSortKeyString(fmap, sortkeys)); } else if( strcmp(mode, "register") == 0 ) { resxml = certificate_add(ctx, fmap); } else if( strcmp(mode, "delete") == 0 ) { diff --git a/database/sqlite/administration/usercerts.c b/database/sqlite/administration/usercerts.c index 4387dcf..4573842 100644 --- a/database/sqlite/administration/usercerts.c +++ b/database/sqlite/administration/usercerts.c @@ -74,7 +74,7 @@ xmlDoc *usercerts_search(eurephiaCTX *ctx, eDBfieldMap *where_m, const char *sor xmlNode *link_root_n = NULL, *link_n = NULL, *tmp_n = NULL; dbresult *res = NULL; xmlChar tmp[2050]; - char *dbsort = NULL; + const char *dbsort = NULL; int i; DEBUG(ctx, 21, "Function call: usercerts_search(ctx, eDBfieldMap, '%s')", sortkeys); @@ -87,7 +87,7 @@ xmlDoc *usercerts_search(eurephiaCTX *ctx, eDBfieldMap *where_m, const char *sor } if( sortkeys != NULL ) { - dbsort = eDBmkSortKeyString(tbl_sqlite_usercerts, sortkeys); + dbsort = eDBmkSortKeyString(where_m, sortkeys); } res = sqlite_query_mapped(ctx, SQL_SELECT, |
