Changeset 30352 for trunk/ippTools/src/regtool.c
- Timestamp:
- Jan 24, 2011, 1:42:59 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/regtool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/regtool.c
r30290 r30352 50 50 51 51 static bool updatebyqueryMode(pxConfig *config); 52 53 static bool checkstatusMode(pxConfig *config); 52 54 53 55 static bool exportrunMode(pxConfig *config); … … 90 92 MODECASE(REGTOOL_MODE_FINISHCOMPRESSEXP, finishcompressexpMode); 91 93 MODECASE(REGTOOL_MODE_CLEARDUPEXP, cleardupexpMode); 94 MODECASE(REGTOOL_MODE_CHECKSTATUS, checkstatusMode); 92 95 MODECASE(REGTOOL_MODE_EXPORTRUN, exportrunMode); 93 96 MODECASE(REGTOOL_MODE_IMPORTRUN, importrunMode); … … 179 182 return true; 180 183 } 184 185 186 181 187 182 188 static bool checkburntoolimfileMode(pxConfig *config) … … 1877 1883 } 1878 1884 1885 static bool checkstatusMode(pxConfig *config) 1886 { 1887 PS_ASSERT_PTR_NON_NULL(config,false); 1888 1889 // required 1890 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 1891 // Conditionally required 1892 PXOPT_LOOKUP_STR(dateobs_begin, config->args, "-dateobs_begin", false, false); 1893 PXOPT_LOOKUP_STR(dateobs_end, config->args, "-dateobs_end", false, false); 1894 PXOPT_LOOKUP_STR(date, config->args, "-date", false, false); 1895 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1896 1897 psString query = pxDataGet("regtool_checkstatus.sql"); 1898 if (!query) { 1899 psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement"); 1900 return false; 1901 } 1902 psString rep = psStringCopy(query); 1903 psFree(query); 1904 query = rep; 1905 psStringSubstitute(&class_id,"ota","XY"); 1906 psStringSubstitute(&query,class_id,"@CLASS_ID@"); 1907 1908 if (!date) { 1909 if (!dateobs_begin || !dateobs_end) { 1910 psError(PXTOOLS_ERR_CONFIG, false, "Either -date or -dateobs_begin -dateobs_end is required"); 1911 psFree(query); 1912 return false; 1913 } 1914 psStringAppend(&query," AND summitExp.dateobs >= '%s' AND summitExp.dateobs <= '%s' ", 1915 dateobs_begin,dateobs_end); 1916 } 1917 else { 1918 psStringAppend(&query," AND summitExp.dateobs >= '%sT00:00:00' AND summitExp.dateobs <= '%sT23:59:59' ", 1919 date,date); 1920 } 1921 1922 psStringAppend(&query," ORDER BY summitExp.dateobs "); 1923 1924 if (!p_psDBRunQuery(config->dbh, query)) { 1925 // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms) 1926 psError(PXTOOLS_ERR_PROG, false, "database error"); 1927 psFree(query); 1928 return false; 1929 } 1930 psFree(query); 1931 1932 psArray *output = p_psDBFetchResult(config->dbh); 1933 if (!output) { 1934 psErrorCode err = psErrorCodeLast(); 1935 switch (err) { 1936 case PS_ERR_DB_CLIENT: 1937 psError(PXTOOLS_ERR_SYS, false, "database error"); 1938 case PS_ERR_DB_SERVER: 1939 psError(PXTOOLS_ERR_PROG, false, "database error"); 1940 default: 1941 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1942 } 1943 1944 return false; 1945 } 1946 if (!psArrayLength(output)) { 1947 psTrace("regtool", PS_LOG_INFO, "no rows found"); 1948 return true; 1949 } 1950 1951 if (!ippdbPrintMetadatas(stdout, output, "regCheckStatus", !simple)) { 1952 psError(PXTOOLS_ERR_PROG, false, "failed to print array"); 1953 psFree(output); 1954 return false; 1955 } 1956 1957 psFree(output); 1958 1959 return(true); 1960 } 1961 1879 1962 bool exportrunMode(pxConfig *config) 1880 1963 {
Note:
See TracChangeset
for help on using the changeset viewer.
