From 0cbcbaca44d874922b726044a9cb67203b89b1de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Sun, 9 Jul 2017 15:15:29 +0200 Subject: [PATCH] Recgnize new box types by searchbox and findbox commands This is implemented by unifying string to data box type conversion. It seems server does not like the new types in searchbox requests. It probably recognized gross types only. We he have to wait for the new specification. --- src/data.c | 41 +++++++++++++++++++++++++++++++++++ src/data.h | 4 ++++ src/shigofumi.c | 67 ++++++++------------------------------------------------- 3 files changed, 54 insertions(+), 58 deletions(-) diff --git a/src/data.c b/src/data.c index a08df70..2668810 100644 --- a/src/data.c +++ b/src/data.c @@ -703,6 +703,47 @@ struct tm *datestring2tm(const char *string) { } +/* Convert string representation of box type to isds_DbType. Return false + * if the string was not recognized. Otherwise returns true. */ +int string2isds_DbType(isds_DbType *type, const char *string) { + if (!strcmp(string, "FO")) + *type = DBTYPE_FO; + else if (!strcmp(string, "PFO")) + *type = DBTYPE_PFO; + else if (!strcmp(string, "PFO_ADVOK")) + *type = DBTYPE_PFO_ADVOK; + else if (!strcmp(string, "PFO_AUDITOR")) + *type = DBTYPE_PFO_AUDITOR; + else if (!strcmp(string, "PFO_DANPOR")) + *type = DBTYPE_PFO_DANPOR; + else if (!strcmp(string, "PFO_INSSPR")) + *type = DBTYPE_PFO_INSSPR; + else if (!strcmp(string, "PO")) + *type = DBTYPE_PO; + else if (!strcmp(string, "PO_ZAK")) + *type = DBTYPE_PO_ZAK; + else if (!strcmp(string, "PO_REQ")) + *type = DBTYPE_PO_REQ; + else if (!strcmp(string, "OVM")) + *type = DBTYPE_OVM; + else if (!strcmp(string, "OVM_NOTAR")) + *type = DBTYPE_OVM_NOTAR; + else if (!strcmp(string, "OVM_EXEKUT")) + *type = DBTYPE_OVM_EXEKUT; + else if (!strcmp(string, "OVM_REQ")) + *type = DBTYPE_OVM_REQ; + else if (!strcmp(string, "OVM_FO")) + *type = DBTYPE_OVM_FO; + else if (!strcmp(string, "OVM_PFO")) + *type = DBTYPE_OVM_PFO; + else if (!strcmp(string, "OVM_PO")) + *type = DBTYPE_OVM_PO; + else + return 0; + return 1; +} + + /* Print formatted header if date value is defined. * @header is locale encoded header name */ void print_header_tm(const char *header, const struct tm *date) { diff --git a/src/data.h b/src/data.h index 59dcc3b..5e0a1c6 100644 --- a/src/data.h +++ b/src/data.h @@ -29,6 +29,10 @@ char *tm2string(const struct tm *date); * XXX: Not all ISO formats are supported */ struct tm *datestring2tm(const char *string); +/* Convert string representation of box type to isds_DbType. Return false + * if the string was not recognized. Otherwise returns true. */ +int string2isds_DbType(isds_DbType *type, const char *string); + /* Return static box state string or NULL if undefined */ const char *DbState2string(const long int *state); diff --git a/src/shigofumi.c b/src/shigofumi.c index b16cb9d..ab6fed6 100644 --- a/src/shigofumi.c +++ b/src/shigofumi.c @@ -1899,6 +1899,7 @@ static void shi_find_box_usage(const char *command) { " FO Private individual\n" " PFO Self-employed individual\n" " PFO_ADVOK Lawyer\n" +" PFO_AUDITOR Statutory auditor\n" " PFO_DANPOR Tax advisor\n" " PFO_INSSPR Insolvency administrator\n" " PO Organisation\n" @@ -2088,31 +2089,7 @@ static int shi_find_box(int argc, const char **argv) { retval = -1; goto leave; } - if (!strcmp(optarg, "FO")) - *criteria->dbType = DBTYPE_FO; - else if (!strcmp(optarg, "PFO")) - *criteria->dbType = DBTYPE_PFO; - else if (!strcmp(optarg, "PFO_ADVOK")) - *criteria->dbType = DBTYPE_PFO_ADVOK; - else if (!strcmp(optarg, "PFO_DANPOR")) - *criteria->dbType = DBTYPE_PFO_DANPOR; - else if (!strcmp(optarg, "PFO_INSSPR")) - *criteria->dbType = DBTYPE_PFO_INSSPR; - else if (!strcmp(optarg, "PO")) - *criteria->dbType = DBTYPE_PO; - else if (!strcmp(optarg, "PO_ZAK")) - *criteria->dbType = DBTYPE_PO_ZAK; - else if (!strcmp(optarg, "PO_REQ")) - *criteria->dbType = DBTYPE_PO_REQ; - else if (!strcmp(optarg, "OVM")) - *criteria->dbType = DBTYPE_OVM; - else if (!strcmp(optarg, "OVM_NOTAR")) - *criteria->dbType = DBTYPE_OVM_NOTAR; - else if (!strcmp(optarg, "OVM_EXEKUT")) - *criteria->dbType = DBTYPE_OVM_EXEKUT; - else if (!strcmp(optarg, "OVM_REQ")) - *criteria->dbType = DBTYPE_OVM_REQ; - else { + if (!string2isds_DbType(criteria->dbType, optarg)) { fprintf(stderr, _("%s: %s: Unknown box type\n"), argv[0], optarg); retval = -1; @@ -2312,6 +2289,12 @@ static void shi_search_box_usage(const char *command) { " OVM_NOTAR Notary\n" " OVM_EXEKUT Executor\n" " OVM_REQ Public authority based on request\n" +" OVM_FO Private individual listed in the public\n" +" authority index\n" +" OVM_PFO Self-employed individual listed in the public\n" +" authority index\n" +" OVM_PO Organisation listed in the public authority\n" +" index\n" "\n" "Pagination options:\n" " -p NUMBER request a page with this number (defaults to the first one)\n" @@ -2389,39 +2372,7 @@ static int shi_search_box(int argc, const char **argv) { target = FULLTEXT_IC; break; case 't': - if (!strcmp(optarg, "FO")) - type = DBTYPE_FO; - else if (!strcmp(optarg, "PFO")) - type = DBTYPE_PFO; - else if (!strcmp(optarg, "PFO_ADVOK")) - type = DBTYPE_PFO_ADVOK; - else if (!strcmp(optarg, "PFO_AUDITOR")) - type = DBTYPE_PFO_AUDITOR; - else if (!strcmp(optarg, "PFO_DANPOR")) - type = DBTYPE_PFO_DANPOR; - else if (!strcmp(optarg, "PFO_INSSPR")) - type = DBTYPE_PFO_INSSPR; - else if (!strcmp(optarg, "PO")) - type = DBTYPE_PO; - else if (!strcmp(optarg, "PO_ZAK")) - type = DBTYPE_PO_ZAK; - else if (!strcmp(optarg, "PO_REQ")) - type = DBTYPE_PO_REQ; - else if (!strcmp(optarg, "OVM")) - type = DBTYPE_OVM; - else if (!strcmp(optarg, "OVM_NOTAR")) - type = DBTYPE_OVM_NOTAR; - else if (!strcmp(optarg, "OVM_EXEKUT")) - type = DBTYPE_OVM_EXEKUT; - else if (!strcmp(optarg, "OVM_REQ")) - type = DBTYPE_OVM_REQ; - else if (!strcmp(optarg, "OVM_FO")) - type = DBTYPE_OVM_FO; - else if (!strcmp(optarg, "OVM_PFO")) - type = DBTYPE_OVM_PFO; - else if (!strcmp(optarg, "OVM_PO")) - type = DBTYPE_OVM_PO; - else { + if (!string2isds_DbType(&type, optarg)) { fprintf(stderr, _("%s: %s: Unknown box type\n"), argv[0], optarg); retval = -1; -- 2.11.4.GIT