@zowe/db2-for-zowe-cli 6.1.17 → 6.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/lib/Db2PluginLifeCycle.d.ts +11 -9
- package/lib/Db2PluginLifeCycle.js +18 -13
- package/lib/Db2PluginLifeCycle.js.map +1 -1
- package/node_modules/adm-zip/adm-zip.js +32 -6
- package/node_modules/adm-zip/headers/entryHeader.js +13 -1
- package/node_modules/adm-zip/methods/inflater.js +33 -3
- package/node_modules/adm-zip/package.json +2 -2
- package/node_modules/adm-zip/util/errors.js +3 -0
- package/node_modules/adm-zip/util/utils.js +102 -14
- package/node_modules/adm-zip/zipEntry.js +43 -18
- package/node_modules/adm-zip/zipFile.js +10 -0
- package/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +236 -73
- package/node_modules/axios/dist/axios.js +1308 -357
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +1443 -403
- package/node_modules/axios/dist/esm/axios.js +1443 -403
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +1483 -348
- package/node_modules/axios/index.d.cts +24 -1
- package/node_modules/axios/index.d.ts +22 -1
- package/node_modules/axios/lib/adapters/fetch.js +136 -30
- package/node_modules/axios/lib/adapters/http.js +277 -74
- package/node_modules/axios/lib/adapters/xhr.js +172 -16
- package/node_modules/axios/lib/core/Axios.js +87 -27
- package/node_modules/axios/lib/core/AxiosError.js +59 -0
- package/node_modules/axios/lib/core/AxiosHeaders.js +17 -4
- package/node_modules/axios/lib/core/InterceptorManager.js +118 -8
- package/node_modules/axios/lib/core/assertParamsAcyclic.js +49 -0
- package/node_modules/axios/lib/core/buildFullPath.js +1 -13
- package/node_modules/axios/lib/core/createMultipartBody.js +37 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +28 -2
- package/node_modules/axios/lib/core/mergeConfig.js +183 -120
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/defaults/transitional.js +1 -0
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/AxiosTransformStream.js +11 -2
- package/node_modules/axios/lib/helpers/Http2Sessions.js +4 -1
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
- package/node_modules/axios/lib/helpers/composeSignals.js +6 -3
- package/node_modules/axios/lib/helpers/cookies.js +30 -6
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +34 -7
- package/node_modules/axios/lib/helpers/formDataToBlob.js +113 -0
- package/node_modules/axios/lib/helpers/formDataToJSON.js +25 -1
- package/node_modules/axios/lib/helpers/fromDataURI.js +11 -4
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +4 -9
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +2 -1
- package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
- package/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
- package/node_modules/axios/lib/helpers/resolveConfig.js +20 -5
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +197 -6
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +14 -21
- package/node_modules/axios/lib/utils.js +192 -20
- package/node_modules/axios/package.json +1 -2
- package/node_modules/follow-redirects/README.md +27 -1
- package/node_modules/follow-redirects/index.js +11 -6
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/fs-extra/README.md +0 -1
- package/node_modules/fs-extra/lib/empty/index.js +4 -2
- package/node_modules/fs-extra/lib/util/stat.js +12 -2
- package/node_modules/fs-extra/package.json +1 -1
- package/node_modules/ibm_db/APIDocumentation.md +2883 -2024
- package/node_modules/ibm_db/LICENSE +23 -23
- package/node_modules/ibm_db/README.md +735 -735
- package/node_modules/ibm_db/binding.gyp +99 -98
- package/node_modules/ibm_db/installer/driverInstall.js +984 -958
- package/node_modules/ibm_db/installer/ifx.sh +38 -38
- package/node_modules/ibm_db/installer/setenv.sh +23 -23
- package/node_modules/ibm_db/installer/testODBCConnection.bat +51 -51
- package/node_modules/ibm_db/installer/testODBCConnection.sh +61 -61
- package/node_modules/ibm_db/lib/climacros.js +431 -431
- package/node_modules/ibm_db/lib/odbc.js +4293 -3487
- package/node_modules/ibm_db/lib/simple-queue.js +41 -41
- package/node_modules/ibm_db/package.json +70 -70
- package/node_modules/ibm_db/src/odbc.cpp +1495 -1396
- package/node_modules/ibm_db/src/odbc.h +477 -473
- package/node_modules/ibm_db/src/odbc_connection.cpp +1762 -1612
- package/node_modules/ibm_db/src/odbc_connection.h +228 -215
- package/node_modules/ibm_db/src/odbc_result.cpp +1547 -1547
- package/node_modules/ibm_db/src/odbc_result.h +152 -152
- package/node_modules/ibm_db/src/odbc_statement.cpp +2047 -861
- package/node_modules/ibm_db/src/odbc_statement.h +257 -135
- package/node_modules/ibm_db/src/strptime.c +389 -389
- package/node_modules/ibm_db/src/strptime.h +46 -46
- package/node_modules/ibm_db/test/README +23 -23
- package/node_modules/ibm_db/test/bench-insert.js +62 -62
- package/node_modules/ibm_db/test/bench-insertBatch10.js +74 -74
- package/node_modules/ibm_db/test/bench-insertBatch100.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch1000.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch10000.js +75 -75
- package/node_modules/ibm_db/test/bench-prepare-bind-execute-closeSync.js +60 -60
- package/node_modules/ibm_db/test/bench-prepare-bind-executeNonQuery.js +53 -53
- package/node_modules/ibm_db/test/bench-prepare-bindSync-execute-closeSync.js +50 -50
- package/node_modules/ibm_db/test/bench-prepare-bindSync-executeNonQuery.js +48 -48
- package/node_modules/ibm_db/test/bench-prepare-execute-closeSync.js +51 -51
- package/node_modules/ibm_db/test/bench-prepare-executeNonQuery.js +47 -47
- package/node_modules/ibm_db/test/bench-prepare-not.js +43 -43
- package/node_modules/ibm_db/test/bench-query-fetch.js +59 -59
- package/node_modules/ibm_db/test/bench-query-fetchAll.js +49 -49
- package/node_modules/ibm_db/test/bench-query-fetchAllSync.js +43 -43
- package/node_modules/ibm_db/test/bench-query.js +40 -40
- package/node_modules/ibm_db/test/bench-querySync-fetchArray.js +28 -28
- package/node_modules/ibm_db/test/bench-querySync.js +29 -29
- package/node_modules/ibm_db/test/common.d.ts +10 -10
- package/node_modules/ibm_db/test/common.js +127 -127
- package/node_modules/ibm_db/test/config.json +7 -7
- package/node_modules/ibm_db/test/config.zos.json +4 -4
- package/node_modules/ibm_db/test/data/sample1.txt +9 -9
- package/node_modules/ibm_db/test/data/trc.fmt +30114 -30114
- package/node_modules/ibm_db/test/nodeEE-leak-huge-query.js +152 -152
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-multiple-connections.js +148 -148
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-pool-connections.js +154 -154
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query.js +133 -133
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall-multiple-connections.js +174 -174
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall.js +169 -169
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query-multiple-connections.js +159 -159
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query.js +148 -148
- package/node_modules/ibm_db/test/odbc-bench.c +123 -123
- package/node_modules/ibm_db/test/perfTest.js +53 -53
- package/node_modules/ibm_db/test/quick-example.sh +30 -30
- package/node_modules/ibm_db/test/quick-example.ts +80 -80
- package/node_modules/ibm_db/test/run-bench.js +96 -96
- package/node_modules/ibm_db/test/run-nodeEE.js +132 -132
- package/node_modules/ibm_db/test/run-tests.js +132 -138
- package/node_modules/ibm_db/test/sql-cli.js +28 -28
- package/node_modules/ibm_db/test/test-all-data-types.js +109 -109
- package/node_modules/ibm_db/test/test-array-insert.js +178 -178
- package/node_modules/ibm_db/test/test-async-await.js +105 -105
- package/node_modules/ibm_db/test/test-attributes.js +34 -34
- package/node_modules/ibm_db/test/test-bad-pool-connection-prepare-execute.js +57 -57
- package/node_modules/ibm_db/test/test-basic-test.js +138 -138
- package/node_modules/ibm_db/test/test-binary-array-insert.js +73 -73
- package/node_modules/ibm_db/test/test-blob-from-file.js +90 -90
- package/node_modules/ibm_db/test/test-blob-insert.js +144 -144
- package/node_modules/ibm_db/test/test-blob-stream-insert.js +321 -299
- package/node_modules/ibm_db/test/test-blob-to-file.js +370 -370
- package/node_modules/ibm_db/test/test-block-fetch.js +364 -364
- package/node_modules/ibm_db/test/test-blocking-issue210.js +123 -123
- package/node_modules/ibm_db/test/test-call-async.js +64 -64
- package/node_modules/ibm_db/test/test-call-stmt.js +53 -53
- package/node_modules/ibm_db/test/test-cancel.js +703 -0
- package/node_modules/ibm_db/test/test-chinese-char.js +59 -59
- package/node_modules/ibm_db/test/test-connection.js +306 -0
- package/node_modules/ibm_db/test/test-date.js +32 -32
- package/node_modules/ibm_db/test/test-dbclob.js +93 -93
- package/node_modules/ibm_db/test/test-decimals.js +135 -135
- package/node_modules/ibm_db/test/test-describe-metadata.js +148 -0
- package/node_modules/ibm_db/test/test-executeFile.js +167 -167
- package/node_modules/ibm_db/test/test-executeFileSync.js +85 -85
- package/node_modules/ibm_db/test/test-fetch-apis.js +146 -146
- package/node_modules/ibm_db/test/test-fetchN.js +130 -130
- package/node_modules/ibm_db/test/test-getinfo.js +197 -197
- package/node_modules/ibm_db/test/test-ibm-db-issue14.js +58 -58
- package/node_modules/ibm_db/test/test-ibm-db-issue17.js +54 -54
- package/node_modules/ibm_db/test/test-ibm-db-issue18.js +54 -54
- package/node_modules/ibm_db/test/test-issue-1059-fetchAll-undefined.js +67 -67
- package/node_modules/ibm_db/test/test-issue-1080-array-blob-insert.js +40 -0
- package/node_modules/ibm_db/test/test-issue-54.js +39 -39
- package/node_modules/ibm_db/test/test-issue-get-column-value-2.js +44 -44
- package/node_modules/ibm_db/test/test-issue211.js +80 -80
- package/node_modules/ibm_db/test/test-issue253.js +39 -39
- package/node_modules/ibm_db/test/test-max-pool-size.js +96 -96
- package/node_modules/ibm_db/test/test-memory-leaks-new-objects.js +32 -32
- package/node_modules/ibm_db/test/test-multi-open-query-close.js +75 -75
- package/node_modules/ibm_db/test/test-param-put-data.js +713 -0
- package/node_modules/ibm_db/test/test-pool-idle-connection.js +72 -72
- package/node_modules/ibm_db/test/test-pool-operations.js +325 -0
- package/node_modules/ibm_db/test/test-pool-stale-connections.js +111 -111
- package/node_modules/ibm_db/test/test-pool-uncommited.js +33 -33
- package/node_modules/ibm_db/test/test-prepare-execute.js +339 -0
- package/node_modules/ibm_db/test/test-prepareSync-multiple-execution.js +93 -93
- package/node_modules/ibm_db/test/test-primary-foreign-keys.js +246 -0
- package/node_modules/ibm_db/test/test-procedures.js +243 -0
- package/node_modules/ibm_db/test/test-promise-all-data-types.js +42 -42
- package/node_modules/ibm_db/test/test-query-operations.js +405 -0
- package/node_modules/ibm_db/test/test-quick-example.js +25 -25
- package/node_modules/ibm_db/test/test-row-array-insert.js +167 -167
- package/node_modules/ibm_db/test/test-sp-array.js +54 -54
- package/node_modules/ibm_db/test/test-sp-dbc-6000.js +88 -88
- package/node_modules/ibm_db/test/test-sp-memleak.js +136 -136
- package/node_modules/ibm_db/test/test-sp-resultset-execute.js +269 -269
- package/node_modules/ibm_db/test/test-sp-resultset.js +228 -228
- package/node_modules/ibm_db/test/test-transactions.js +261 -0
- package/node_modules/ibm_db/test/test-typescript.js +48 -48
- package/node_modules/ibm_db/test/test-xml-datatype.js +70 -70
- package/node_modules/ibm_db/test/testWebApp.js +56 -56
- package/node_modules/ibm_db/test/trace +51 -51
- package/node_modules/ibm_db/test/typescript-apis-test.js +978 -978
- package/node_modules/ibm_db/test/webapp.html +17 -17
- package/node_modules/ibm_db/test/webapp.js +79 -79
- package/node_modules/ibm_db/typescript/README.md +28 -28
- package/node_modules/ibm_db/typescript/dist/Database.d.ts +26 -0
- package/node_modules/ibm_db/typescript/dist/ODBCStatement.d.ts +93 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/index.js +62 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/package.json +37 -0
- package/node_modules/which-typed-array/CHANGELOG.md +14 -0
- package/node_modules/which-typed-array/README.md +0 -2
- package/node_modules/which-typed-array/index.d.ts +288 -11
- package/node_modules/which-typed-array/index.js +6 -7
- package/node_modules/which-typed-array/package.json +12 -11
- package/package.json +10 -11
- package/node_modules/ibm_db/test/disabled/test-binding-statement-rebinding.js +0 -59
- package/node_modules/ibm_db/test/disabled/test-open-dont-close.js +0 -12
- package/node_modules/ibm_db/test/disabled/test-param-select-with-booleans-only.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-decimals-only.js +0 -20
- package/node_modules/ibm_db/test/disabled/test-param-select-with-null.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-nulls-mixed.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-mixed.js +0 -22
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-only.js +0 -24
- package/node_modules/ibm_db/test/disabled/test-param-select-with-strings-only.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-closeSync.js +0 -62
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-error.js +0 -49
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-long-string.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-executeNonQuery.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-execute-closeSync.js +0 -46
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-executeNonQuery.js +0 -50
- package/node_modules/ibm_db/test/disabled/test-prepare.js +0 -34
- package/node_modules/ibm_db/test/disabled/test-prepareSync.js +0 -29
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAll.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAllSync.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-querySync-select-unicode.js +0 -20
- package/node_modules/ibm_db/test/test-affected-rows.js +0 -55
- package/node_modules/ibm_db/test/test-bad-connection-string.js +0 -30
- package/node_modules/ibm_db/test/test-binding-connection-timeOut.js +0 -31
- package/node_modules/ibm_db/test/test-binding-statement-executeSync.js +0 -84
- package/node_modules/ibm_db/test/test-binding-transaction-commit.js +0 -79
- package/node_modules/ibm_db/test/test-binding-transaction-commitSync.js +0 -53
- package/node_modules/ibm_db/test/test-closed.js +0 -14
- package/node_modules/ibm_db/test/test-connection-object.js +0 -16
- package/node_modules/ibm_db/test/test-describe-column.js +0 -92
- package/node_modules/ibm_db/test/test-describe-database.js +0 -18
- package/node_modules/ibm_db/test/test-describe-table.js +0 -31
- package/node_modules/ibm_db/test/test-domains-open.js +0 -19
- package/node_modules/ibm_db/test/test-global-open-close.js +0 -11
- package/node_modules/ibm_db/test/test-instantiate-one-and-end.js +0 -9
- package/node_modules/ibm_db/test/test-multi-open-close.js +0 -45
- package/node_modules/ibm_db/test/test-multi-openSync-closeSync.js +0 -52
- package/node_modules/ibm_db/test/test-open-close.js +0 -29
- package/node_modules/ibm_db/test/test-open-connectTimeout.js +0 -33
- package/node_modules/ibm_db/test/test-openSync.js +0 -31
- package/node_modules/ibm_db/test/test-pool-close.js +0 -120
- package/node_modules/ibm_db/test/test-pool-connect.js +0 -36
- package/node_modules/ibm_db/test/test-pool-rollbackTransaction.js +0 -35
- package/node_modules/ibm_db/test/test-prepareSync-bad-sql.js +0 -34
- package/node_modules/ibm_db/test/test-promise-open-close.js +0 -33
- package/node_modules/ibm_db/test/test-query-create-table-fetchSync.js +0 -23
- package/node_modules/ibm_db/test/test-query-create-table.js +0 -12
- package/node_modules/ibm_db/test/test-query-drop-table.js +0 -13
- package/node_modules/ibm_db/test/test-query-insert.js +0 -38
- package/node_modules/ibm_db/test/test-query-select-fetch.js +0 -21
- package/node_modules/ibm_db/test/test-query-select-fetchMode-array.js +0 -17
- package/node_modules/ibm_db/test/test-query-select.js +0 -64
- package/node_modules/ibm_db/test/test-queryResult.js +0 -35
- package/node_modules/ibm_db/test/test-queryStream.js +0 -43
- package/node_modules/ibm_db/test/test-querySync-select-with-exception.js +0 -25
- package/node_modules/ibm_db/test/test-querySync-select.js +0 -28
- package/node_modules/ibm_db/test/test-require-and-end.js +0 -8
- package/node_modules/ibm_db/test/test-statement-close.js +0 -118
- package/node_modules/ibm_db/test/test-transaction-commit-sync.js +0 -54
- package/node_modules/ibm_db/test/test-transaction-commit.js +0 -79
- package/node_modules/which-typed-array/eslint.config.mjs +0 -12
- package/node_modules/which-typed-array/test/index.js +0 -105
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/LICENSE +0 -0
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/README.md +0 -0
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/chownr.js +0 -0
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/package.json +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/.travis.yml +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/LICENSE +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/README.md +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/lib/string_decoder.js +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/package.json +0 -0
|
@@ -1,389 +1,389 @@
|
|
|
1
|
-
/*-
|
|
2
|
-
* Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* This code was contributed to The NetBSD Foundation by Klaus Klein.
|
|
6
|
-
* Heavily optimised by David Laight
|
|
7
|
-
*
|
|
8
|
-
* Redistribution and use in source and binary forms, with or without
|
|
9
|
-
* modification, are permitted provided that the following conditions
|
|
10
|
-
* are met:
|
|
11
|
-
* 1. Redistributions of source code must retain the above copyright
|
|
12
|
-
* notice, this list of conditions and the following disclaimer.
|
|
13
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
-
* notice, this list of conditions and the following disclaimer in the
|
|
15
|
-
* documentation and/or other materials provided with the distribution.
|
|
16
|
-
*
|
|
17
|
-
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
18
|
-
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
19
|
-
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
20
|
-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
21
|
-
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/*
|
|
31
|
-
* Inclusion in node-odbc note:
|
|
32
|
-
*
|
|
33
|
-
* This code was found here: http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/25a654f9-b6b6-490a-8f36-c87483bb36b7
|
|
34
|
-
* One user posted what looks to be a scaled down version of the NetBSD code
|
|
35
|
-
* but did not include any header with their work. Since it seems pretty obvious
|
|
36
|
-
* that the user took much of the code from NetBSD, that is why the NetBSD header
|
|
37
|
-
* is displayed above.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
#include "strptime.h"
|
|
41
|
-
|
|
42
|
-
static int conv_num(const char **, int *, int, int);
|
|
43
|
-
static int strncasecmp(char *s1, char *s2, size_t n);
|
|
44
|
-
|
|
45
|
-
char * strptime(const char *buf, const char *fmt, struct tm *tm)
|
|
46
|
-
{
|
|
47
|
-
char c;
|
|
48
|
-
const char *bp;
|
|
49
|
-
size_t len = 0;
|
|
50
|
-
int alt_format, i, split_year = 0;
|
|
51
|
-
|
|
52
|
-
bp = buf;
|
|
53
|
-
|
|
54
|
-
while ((c = *fmt) != '\0')
|
|
55
|
-
{
|
|
56
|
-
/* Clear `alternate' modifier prior to new conversion. */
|
|
57
|
-
alt_format = 0;
|
|
58
|
-
|
|
59
|
-
/* Eat up white-space. */
|
|
60
|
-
if (isspace(c))
|
|
61
|
-
{
|
|
62
|
-
while (isspace(*bp))
|
|
63
|
-
bp++;
|
|
64
|
-
|
|
65
|
-
fmt++;
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if ((c = *fmt++) != '%')
|
|
70
|
-
goto literal;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
again: switch (c = *fmt++)
|
|
74
|
-
{
|
|
75
|
-
case '%': /* "%%" is converted to "%". */
|
|
76
|
-
literal:
|
|
77
|
-
if (c != *bp++)
|
|
78
|
-
return (0);
|
|
79
|
-
break;
|
|
80
|
-
|
|
81
|
-
/*
|
|
82
|
-
* "Alternative" modifiers. Just set the appropriate flag
|
|
83
|
-
* and start over again.
|
|
84
|
-
*/
|
|
85
|
-
case 'E': /* "%E?" alternative conversion modifier. */
|
|
86
|
-
LEGAL_ALT(0);
|
|
87
|
-
alt_format |= ALT_E;
|
|
88
|
-
goto again;
|
|
89
|
-
|
|
90
|
-
case 'O': /* "%O?" alternative conversion modifier. */
|
|
91
|
-
LEGAL_ALT(0);
|
|
92
|
-
alt_format |= ALT_O;
|
|
93
|
-
goto again;
|
|
94
|
-
|
|
95
|
-
/*
|
|
96
|
-
* "Complex" conversion rules, implemented through recursion.
|
|
97
|
-
*/
|
|
98
|
-
case 'c': /* Date and time, using the locale's format. */
|
|
99
|
-
LEGAL_ALT(ALT_E);
|
|
100
|
-
if (!(bp = strptime(bp, "%x %X", tm)))
|
|
101
|
-
return (0);
|
|
102
|
-
break;
|
|
103
|
-
|
|
104
|
-
case 'D': /* The date as "%m/%d/%y". */
|
|
105
|
-
LEGAL_ALT(0);
|
|
106
|
-
if (!(bp = strptime(bp, "%m/%d/%y", tm)))
|
|
107
|
-
return (0);
|
|
108
|
-
break;
|
|
109
|
-
|
|
110
|
-
case 'R': /* The time as "%H:%M". */
|
|
111
|
-
LEGAL_ALT(0);
|
|
112
|
-
if (!(bp = strptime(bp, "%H:%M", tm)))
|
|
113
|
-
return (0);
|
|
114
|
-
break;
|
|
115
|
-
|
|
116
|
-
case 'r': /* The time in 12-hour clock representation. */
|
|
117
|
-
LEGAL_ALT(0);
|
|
118
|
-
if (!(bp = strptime(bp, "%I:%M:%S %p", tm)))
|
|
119
|
-
return (0);
|
|
120
|
-
break;
|
|
121
|
-
|
|
122
|
-
case 'T': /* The time as "%H:%M:%S". */
|
|
123
|
-
LEGAL_ALT(0);
|
|
124
|
-
if (!(bp = strptime(bp, "%H:%M:%S", tm)))
|
|
125
|
-
return (0);
|
|
126
|
-
break;
|
|
127
|
-
|
|
128
|
-
case 'X': /* The time, using the locale's format. */
|
|
129
|
-
LEGAL_ALT(ALT_E);
|
|
130
|
-
if (!(bp = strptime(bp, "%H:%M:%S", tm)))
|
|
131
|
-
return (0);
|
|
132
|
-
break;
|
|
133
|
-
|
|
134
|
-
case 'x': /* The date, using the locale's format. */
|
|
135
|
-
LEGAL_ALT(ALT_E);
|
|
136
|
-
if (!(bp = strptime(bp, "%m/%d/%y", tm)))
|
|
137
|
-
return (0);
|
|
138
|
-
break;
|
|
139
|
-
|
|
140
|
-
/*
|
|
141
|
-
* "Elementary" conversion rules.
|
|
142
|
-
*/
|
|
143
|
-
case 'A': /* The day of week, using the locale's form. */
|
|
144
|
-
case 'a':
|
|
145
|
-
LEGAL_ALT(0);
|
|
146
|
-
for (i = 0; i < 7; i++)
|
|
147
|
-
{
|
|
148
|
-
/* Full name. */
|
|
149
|
-
len = strlen(day[i]);
|
|
150
|
-
if (strncasecmp((char *)(day[i]), (char *)bp, len) == 0)
|
|
151
|
-
break;
|
|
152
|
-
|
|
153
|
-
/* Abbreviated name. */
|
|
154
|
-
len = strlen(abday[i]);
|
|
155
|
-
if (strncasecmp((char *)(abday[i]), (char *)bp, len) == 0)
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/* Nothing matched. */
|
|
160
|
-
if (i == 7)
|
|
161
|
-
return (0);
|
|
162
|
-
|
|
163
|
-
tm->tm_wday = i;
|
|
164
|
-
bp += len;
|
|
165
|
-
break;
|
|
166
|
-
|
|
167
|
-
case 'B': /* The month, using the locale's form. */
|
|
168
|
-
case 'b':
|
|
169
|
-
case 'h':
|
|
170
|
-
LEGAL_ALT(0);
|
|
171
|
-
for (i = 0; i < 12; i++)
|
|
172
|
-
{
|
|
173
|
-
/* Full name. */
|
|
174
|
-
|
|
175
|
-
len = strlen(mon[i]);
|
|
176
|
-
if (strncasecmp((char *)(mon[i]), (char *)bp, len) == 0)
|
|
177
|
-
break;
|
|
178
|
-
|
|
179
|
-
/* Abbreviated name. */
|
|
180
|
-
len = strlen(abmon[i]);
|
|
181
|
-
if (strncasecmp((char *)(abmon[i]),(char *) bp, len) == 0)
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/* Nothing matched. */
|
|
186
|
-
if (i == 12)
|
|
187
|
-
return (0);
|
|
188
|
-
|
|
189
|
-
tm->tm_mon = i;
|
|
190
|
-
bp += len;
|
|
191
|
-
break;
|
|
192
|
-
|
|
193
|
-
case 'C': /* The century number. */
|
|
194
|
-
LEGAL_ALT(ALT_E);
|
|
195
|
-
if (!(conv_num(&bp, &i, 0, 99)))
|
|
196
|
-
return (0);
|
|
197
|
-
|
|
198
|
-
if (split_year)
|
|
199
|
-
{
|
|
200
|
-
tm->tm_year = (tm->tm_year % 100) + (i * 100);
|
|
201
|
-
} else {
|
|
202
|
-
tm->tm_year = i * 100;
|
|
203
|
-
split_year = 1;
|
|
204
|
-
}
|
|
205
|
-
break;
|
|
206
|
-
|
|
207
|
-
case 'd': /* The day of month. */
|
|
208
|
-
case 'e':
|
|
209
|
-
LEGAL_ALT(ALT_O);
|
|
210
|
-
if (!(conv_num(&bp, &tm->tm_mday, 1, 31)))
|
|
211
|
-
return (0);
|
|
212
|
-
break;
|
|
213
|
-
|
|
214
|
-
case 'k': /* The hour (24-hour clock representation). */
|
|
215
|
-
LEGAL_ALT(0);
|
|
216
|
-
/* FALLTHROUGH */
|
|
217
|
-
case 'H':
|
|
218
|
-
LEGAL_ALT(ALT_O);
|
|
219
|
-
if (!(conv_num(&bp, &tm->tm_hour, 0, 23)))
|
|
220
|
-
return (0);
|
|
221
|
-
break;
|
|
222
|
-
|
|
223
|
-
case 'l': /* The hour (12-hour clock representation). */
|
|
224
|
-
LEGAL_ALT(0);
|
|
225
|
-
/* FALLTHROUGH */
|
|
226
|
-
case 'I':
|
|
227
|
-
LEGAL_ALT(ALT_O);
|
|
228
|
-
if (!(conv_num(&bp, &tm->tm_hour, 1, 12)))
|
|
229
|
-
return (0);
|
|
230
|
-
if (tm->tm_hour == 12)
|
|
231
|
-
tm->tm_hour = 0;
|
|
232
|
-
break;
|
|
233
|
-
|
|
234
|
-
case 'j': /* The day of year. */
|
|
235
|
-
LEGAL_ALT(0);
|
|
236
|
-
if (!(conv_num(&bp, &i, 1, 366)))
|
|
237
|
-
return (0);
|
|
238
|
-
tm->tm_yday = i - 1;
|
|
239
|
-
break;
|
|
240
|
-
|
|
241
|
-
case 'M': /* The minute. */
|
|
242
|
-
LEGAL_ALT(ALT_O);
|
|
243
|
-
if (!(conv_num(&bp, &tm->tm_min, 0, 59)))
|
|
244
|
-
return (0);
|
|
245
|
-
break;
|
|
246
|
-
|
|
247
|
-
case 'm': /* The month. */
|
|
248
|
-
LEGAL_ALT(ALT_O);
|
|
249
|
-
if (!(conv_num(&bp, &i, 1, 12)))
|
|
250
|
-
return (0);
|
|
251
|
-
tm->tm_mon = i - 1;
|
|
252
|
-
break;
|
|
253
|
-
|
|
254
|
-
// case 'p': /* The locale's equivalent of AM/PM. */
|
|
255
|
-
// LEGAL_ALT(0);
|
|
256
|
-
// /* AM? */
|
|
257
|
-
// if (strcasecmp(am_pm[0], bp) == 0)
|
|
258
|
-
// {
|
|
259
|
-
// if (tm->tm_hour > 11)
|
|
260
|
-
// return (0);
|
|
261
|
-
//
|
|
262
|
-
// bp += strlen(am_pm[0]);
|
|
263
|
-
// break;
|
|
264
|
-
// }
|
|
265
|
-
// /* PM? */
|
|
266
|
-
// else if (strcasecmp(am_pm[1], bp) == 0)
|
|
267
|
-
// {
|
|
268
|
-
// if (tm->tm_hour > 11)
|
|
269
|
-
// return (0);
|
|
270
|
-
//
|
|
271
|
-
// tm->tm_hour += 12;
|
|
272
|
-
// bp += strlen(am_pm[1]);
|
|
273
|
-
// break;
|
|
274
|
-
// }
|
|
275
|
-
//
|
|
276
|
-
// /* Nothing matched. */
|
|
277
|
-
// return (0);
|
|
278
|
-
|
|
279
|
-
case 'S': /* The seconds. */
|
|
280
|
-
LEGAL_ALT(ALT_O);
|
|
281
|
-
if (!(conv_num(&bp, &tm->tm_sec, 0, 61)))
|
|
282
|
-
return (0);
|
|
283
|
-
break;
|
|
284
|
-
|
|
285
|
-
case 'U': /* The week of year, beginning on sunday. */
|
|
286
|
-
case 'W': /* The week of year, beginning on monday. */
|
|
287
|
-
LEGAL_ALT(ALT_O);
|
|
288
|
-
/*
|
|
289
|
-
* XXX This is bogus, as we can not assume any valid
|
|
290
|
-
* information present in the tm structure at this
|
|
291
|
-
* point to calculate a real value, so just check the
|
|
292
|
-
* range for now.
|
|
293
|
-
*/
|
|
294
|
-
if (!(conv_num(&bp, &i, 0, 53)))
|
|
295
|
-
return (0);
|
|
296
|
-
break;
|
|
297
|
-
|
|
298
|
-
case 'w': /* The day of week, beginning on sunday. */
|
|
299
|
-
LEGAL_ALT(ALT_O);
|
|
300
|
-
if (!(conv_num(&bp, &tm->tm_wday, 0, 6)))
|
|
301
|
-
return (0);
|
|
302
|
-
break;
|
|
303
|
-
|
|
304
|
-
case 'Y': /* The year. */
|
|
305
|
-
LEGAL_ALT(ALT_E);
|
|
306
|
-
if (!(conv_num(&bp, &i, 0, 9999)))
|
|
307
|
-
return (0);
|
|
308
|
-
|
|
309
|
-
tm->tm_year = i - TM_YEAR_BASE;
|
|
310
|
-
break;
|
|
311
|
-
|
|
312
|
-
case 'y': /* The year within 100 years of the epoch. */
|
|
313
|
-
LEGAL_ALT(ALT_E | ALT_O);
|
|
314
|
-
if (!(conv_num(&bp, &i, 0, 99)))
|
|
315
|
-
return (0);
|
|
316
|
-
|
|
317
|
-
if (split_year)
|
|
318
|
-
{
|
|
319
|
-
tm->tm_year = ((tm->tm_year / 100) * 100) + i;
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
split_year = 1;
|
|
323
|
-
if (i <= 68)
|
|
324
|
-
tm->tm_year = i + 2000 - TM_YEAR_BASE;
|
|
325
|
-
else
|
|
326
|
-
tm->tm_year = i + 1900 - TM_YEAR_BASE;
|
|
327
|
-
break;
|
|
328
|
-
|
|
329
|
-
/*
|
|
330
|
-
* Miscellaneous conversions.
|
|
331
|
-
*/
|
|
332
|
-
case 'n': /* Any kind of white-space. */
|
|
333
|
-
case 't':
|
|
334
|
-
LEGAL_ALT(0);
|
|
335
|
-
while (isspace(*bp))
|
|
336
|
-
bp++;
|
|
337
|
-
break;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
default: /* Unknown/unsupported conversion. */
|
|
341
|
-
return (0);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/* LINTED functional specification */
|
|
348
|
-
return ((char *)bp);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
static int conv_num(const char **buf, int *dest, int llim, int ulim)
|
|
353
|
-
{
|
|
354
|
-
int result = 0;
|
|
355
|
-
|
|
356
|
-
/* The limit also determines the number of valid digits. */
|
|
357
|
-
int rulim = ulim;
|
|
358
|
-
|
|
359
|
-
if (**buf < '0' || **buf > '9')
|
|
360
|
-
return (0);
|
|
361
|
-
|
|
362
|
-
do {
|
|
363
|
-
result *= 10;
|
|
364
|
-
result += *(*buf)++ - '0';
|
|
365
|
-
rulim /= 10;
|
|
366
|
-
} while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9');
|
|
367
|
-
|
|
368
|
-
if (result < llim || result > ulim)
|
|
369
|
-
return (0);
|
|
370
|
-
|
|
371
|
-
*dest = result;
|
|
372
|
-
return (1);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
int strncasecmp(char *s1, char *s2, size_t n)
|
|
376
|
-
{
|
|
377
|
-
if (n == 0)
|
|
378
|
-
return 0;
|
|
379
|
-
|
|
380
|
-
while (n-- != 0 && tolower(*s1) == tolower(*s2))
|
|
381
|
-
{
|
|
382
|
-
if (n == 0 || *s1 == '\0' || *s2 == '\0')
|
|
383
|
-
break;
|
|
384
|
-
s1++;
|
|
385
|
-
s2++;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
|
|
389
|
-
}
|
|
1
|
+
/*-
|
|
2
|
+
* Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This code was contributed to The NetBSD Foundation by Klaus Klein.
|
|
6
|
+
* Heavily optimised by David Laight
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions
|
|
10
|
+
* are met:
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
18
|
+
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
19
|
+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
20
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
21
|
+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* Inclusion in node-odbc note:
|
|
32
|
+
*
|
|
33
|
+
* This code was found here: http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/25a654f9-b6b6-490a-8f36-c87483bb36b7
|
|
34
|
+
* One user posted what looks to be a scaled down version of the NetBSD code
|
|
35
|
+
* but did not include any header with their work. Since it seems pretty obvious
|
|
36
|
+
* that the user took much of the code from NetBSD, that is why the NetBSD header
|
|
37
|
+
* is displayed above.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
#include "strptime.h"
|
|
41
|
+
|
|
42
|
+
static int conv_num(const char **, int *, int, int);
|
|
43
|
+
static int strncasecmp(char *s1, char *s2, size_t n);
|
|
44
|
+
|
|
45
|
+
char * strptime(const char *buf, const char *fmt, struct tm *tm)
|
|
46
|
+
{
|
|
47
|
+
char c;
|
|
48
|
+
const char *bp;
|
|
49
|
+
size_t len = 0;
|
|
50
|
+
int alt_format, i, split_year = 0;
|
|
51
|
+
|
|
52
|
+
bp = buf;
|
|
53
|
+
|
|
54
|
+
while ((c = *fmt) != '\0')
|
|
55
|
+
{
|
|
56
|
+
/* Clear `alternate' modifier prior to new conversion. */
|
|
57
|
+
alt_format = 0;
|
|
58
|
+
|
|
59
|
+
/* Eat up white-space. */
|
|
60
|
+
if (isspace(c))
|
|
61
|
+
{
|
|
62
|
+
while (isspace(*bp))
|
|
63
|
+
bp++;
|
|
64
|
+
|
|
65
|
+
fmt++;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if ((c = *fmt++) != '%')
|
|
70
|
+
goto literal;
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
again: switch (c = *fmt++)
|
|
74
|
+
{
|
|
75
|
+
case '%': /* "%%" is converted to "%". */
|
|
76
|
+
literal:
|
|
77
|
+
if (c != *bp++)
|
|
78
|
+
return (0);
|
|
79
|
+
break;
|
|
80
|
+
|
|
81
|
+
/*
|
|
82
|
+
* "Alternative" modifiers. Just set the appropriate flag
|
|
83
|
+
* and start over again.
|
|
84
|
+
*/
|
|
85
|
+
case 'E': /* "%E?" alternative conversion modifier. */
|
|
86
|
+
LEGAL_ALT(0);
|
|
87
|
+
alt_format |= ALT_E;
|
|
88
|
+
goto again;
|
|
89
|
+
|
|
90
|
+
case 'O': /* "%O?" alternative conversion modifier. */
|
|
91
|
+
LEGAL_ALT(0);
|
|
92
|
+
alt_format |= ALT_O;
|
|
93
|
+
goto again;
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* "Complex" conversion rules, implemented through recursion.
|
|
97
|
+
*/
|
|
98
|
+
case 'c': /* Date and time, using the locale's format. */
|
|
99
|
+
LEGAL_ALT(ALT_E);
|
|
100
|
+
if (!(bp = strptime(bp, "%x %X", tm)))
|
|
101
|
+
return (0);
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
case 'D': /* The date as "%m/%d/%y". */
|
|
105
|
+
LEGAL_ALT(0);
|
|
106
|
+
if (!(bp = strptime(bp, "%m/%d/%y", tm)))
|
|
107
|
+
return (0);
|
|
108
|
+
break;
|
|
109
|
+
|
|
110
|
+
case 'R': /* The time as "%H:%M". */
|
|
111
|
+
LEGAL_ALT(0);
|
|
112
|
+
if (!(bp = strptime(bp, "%H:%M", tm)))
|
|
113
|
+
return (0);
|
|
114
|
+
break;
|
|
115
|
+
|
|
116
|
+
case 'r': /* The time in 12-hour clock representation. */
|
|
117
|
+
LEGAL_ALT(0);
|
|
118
|
+
if (!(bp = strptime(bp, "%I:%M:%S %p", tm)))
|
|
119
|
+
return (0);
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
case 'T': /* The time as "%H:%M:%S". */
|
|
123
|
+
LEGAL_ALT(0);
|
|
124
|
+
if (!(bp = strptime(bp, "%H:%M:%S", tm)))
|
|
125
|
+
return (0);
|
|
126
|
+
break;
|
|
127
|
+
|
|
128
|
+
case 'X': /* The time, using the locale's format. */
|
|
129
|
+
LEGAL_ALT(ALT_E);
|
|
130
|
+
if (!(bp = strptime(bp, "%H:%M:%S", tm)))
|
|
131
|
+
return (0);
|
|
132
|
+
break;
|
|
133
|
+
|
|
134
|
+
case 'x': /* The date, using the locale's format. */
|
|
135
|
+
LEGAL_ALT(ALT_E);
|
|
136
|
+
if (!(bp = strptime(bp, "%m/%d/%y", tm)))
|
|
137
|
+
return (0);
|
|
138
|
+
break;
|
|
139
|
+
|
|
140
|
+
/*
|
|
141
|
+
* "Elementary" conversion rules.
|
|
142
|
+
*/
|
|
143
|
+
case 'A': /* The day of week, using the locale's form. */
|
|
144
|
+
case 'a':
|
|
145
|
+
LEGAL_ALT(0);
|
|
146
|
+
for (i = 0; i < 7; i++)
|
|
147
|
+
{
|
|
148
|
+
/* Full name. */
|
|
149
|
+
len = strlen(day[i]);
|
|
150
|
+
if (strncasecmp((char *)(day[i]), (char *)bp, len) == 0)
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
/* Abbreviated name. */
|
|
154
|
+
len = strlen(abday[i]);
|
|
155
|
+
if (strncasecmp((char *)(abday[i]), (char *)bp, len) == 0)
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* Nothing matched. */
|
|
160
|
+
if (i == 7)
|
|
161
|
+
return (0);
|
|
162
|
+
|
|
163
|
+
tm->tm_wday = i;
|
|
164
|
+
bp += len;
|
|
165
|
+
break;
|
|
166
|
+
|
|
167
|
+
case 'B': /* The month, using the locale's form. */
|
|
168
|
+
case 'b':
|
|
169
|
+
case 'h':
|
|
170
|
+
LEGAL_ALT(0);
|
|
171
|
+
for (i = 0; i < 12; i++)
|
|
172
|
+
{
|
|
173
|
+
/* Full name. */
|
|
174
|
+
|
|
175
|
+
len = strlen(mon[i]);
|
|
176
|
+
if (strncasecmp((char *)(mon[i]), (char *)bp, len) == 0)
|
|
177
|
+
break;
|
|
178
|
+
|
|
179
|
+
/* Abbreviated name. */
|
|
180
|
+
len = strlen(abmon[i]);
|
|
181
|
+
if (strncasecmp((char *)(abmon[i]),(char *) bp, len) == 0)
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* Nothing matched. */
|
|
186
|
+
if (i == 12)
|
|
187
|
+
return (0);
|
|
188
|
+
|
|
189
|
+
tm->tm_mon = i;
|
|
190
|
+
bp += len;
|
|
191
|
+
break;
|
|
192
|
+
|
|
193
|
+
case 'C': /* The century number. */
|
|
194
|
+
LEGAL_ALT(ALT_E);
|
|
195
|
+
if (!(conv_num(&bp, &i, 0, 99)))
|
|
196
|
+
return (0);
|
|
197
|
+
|
|
198
|
+
if (split_year)
|
|
199
|
+
{
|
|
200
|
+
tm->tm_year = (tm->tm_year % 100) + (i * 100);
|
|
201
|
+
} else {
|
|
202
|
+
tm->tm_year = i * 100;
|
|
203
|
+
split_year = 1;
|
|
204
|
+
}
|
|
205
|
+
break;
|
|
206
|
+
|
|
207
|
+
case 'd': /* The day of month. */
|
|
208
|
+
case 'e':
|
|
209
|
+
LEGAL_ALT(ALT_O);
|
|
210
|
+
if (!(conv_num(&bp, &tm->tm_mday, 1, 31)))
|
|
211
|
+
return (0);
|
|
212
|
+
break;
|
|
213
|
+
|
|
214
|
+
case 'k': /* The hour (24-hour clock representation). */
|
|
215
|
+
LEGAL_ALT(0);
|
|
216
|
+
/* FALLTHROUGH */
|
|
217
|
+
case 'H':
|
|
218
|
+
LEGAL_ALT(ALT_O);
|
|
219
|
+
if (!(conv_num(&bp, &tm->tm_hour, 0, 23)))
|
|
220
|
+
return (0);
|
|
221
|
+
break;
|
|
222
|
+
|
|
223
|
+
case 'l': /* The hour (12-hour clock representation). */
|
|
224
|
+
LEGAL_ALT(0);
|
|
225
|
+
/* FALLTHROUGH */
|
|
226
|
+
case 'I':
|
|
227
|
+
LEGAL_ALT(ALT_O);
|
|
228
|
+
if (!(conv_num(&bp, &tm->tm_hour, 1, 12)))
|
|
229
|
+
return (0);
|
|
230
|
+
if (tm->tm_hour == 12)
|
|
231
|
+
tm->tm_hour = 0;
|
|
232
|
+
break;
|
|
233
|
+
|
|
234
|
+
case 'j': /* The day of year. */
|
|
235
|
+
LEGAL_ALT(0);
|
|
236
|
+
if (!(conv_num(&bp, &i, 1, 366)))
|
|
237
|
+
return (0);
|
|
238
|
+
tm->tm_yday = i - 1;
|
|
239
|
+
break;
|
|
240
|
+
|
|
241
|
+
case 'M': /* The minute. */
|
|
242
|
+
LEGAL_ALT(ALT_O);
|
|
243
|
+
if (!(conv_num(&bp, &tm->tm_min, 0, 59)))
|
|
244
|
+
return (0);
|
|
245
|
+
break;
|
|
246
|
+
|
|
247
|
+
case 'm': /* The month. */
|
|
248
|
+
LEGAL_ALT(ALT_O);
|
|
249
|
+
if (!(conv_num(&bp, &i, 1, 12)))
|
|
250
|
+
return (0);
|
|
251
|
+
tm->tm_mon = i - 1;
|
|
252
|
+
break;
|
|
253
|
+
|
|
254
|
+
// case 'p': /* The locale's equivalent of AM/PM. */
|
|
255
|
+
// LEGAL_ALT(0);
|
|
256
|
+
// /* AM? */
|
|
257
|
+
// if (strcasecmp(am_pm[0], bp) == 0)
|
|
258
|
+
// {
|
|
259
|
+
// if (tm->tm_hour > 11)
|
|
260
|
+
// return (0);
|
|
261
|
+
//
|
|
262
|
+
// bp += strlen(am_pm[0]);
|
|
263
|
+
// break;
|
|
264
|
+
// }
|
|
265
|
+
// /* PM? */
|
|
266
|
+
// else if (strcasecmp(am_pm[1], bp) == 0)
|
|
267
|
+
// {
|
|
268
|
+
// if (tm->tm_hour > 11)
|
|
269
|
+
// return (0);
|
|
270
|
+
//
|
|
271
|
+
// tm->tm_hour += 12;
|
|
272
|
+
// bp += strlen(am_pm[1]);
|
|
273
|
+
// break;
|
|
274
|
+
// }
|
|
275
|
+
//
|
|
276
|
+
// /* Nothing matched. */
|
|
277
|
+
// return (0);
|
|
278
|
+
|
|
279
|
+
case 'S': /* The seconds. */
|
|
280
|
+
LEGAL_ALT(ALT_O);
|
|
281
|
+
if (!(conv_num(&bp, &tm->tm_sec, 0, 61)))
|
|
282
|
+
return (0);
|
|
283
|
+
break;
|
|
284
|
+
|
|
285
|
+
case 'U': /* The week of year, beginning on sunday. */
|
|
286
|
+
case 'W': /* The week of year, beginning on monday. */
|
|
287
|
+
LEGAL_ALT(ALT_O);
|
|
288
|
+
/*
|
|
289
|
+
* XXX This is bogus, as we can not assume any valid
|
|
290
|
+
* information present in the tm structure at this
|
|
291
|
+
* point to calculate a real value, so just check the
|
|
292
|
+
* range for now.
|
|
293
|
+
*/
|
|
294
|
+
if (!(conv_num(&bp, &i, 0, 53)))
|
|
295
|
+
return (0);
|
|
296
|
+
break;
|
|
297
|
+
|
|
298
|
+
case 'w': /* The day of week, beginning on sunday. */
|
|
299
|
+
LEGAL_ALT(ALT_O);
|
|
300
|
+
if (!(conv_num(&bp, &tm->tm_wday, 0, 6)))
|
|
301
|
+
return (0);
|
|
302
|
+
break;
|
|
303
|
+
|
|
304
|
+
case 'Y': /* The year. */
|
|
305
|
+
LEGAL_ALT(ALT_E);
|
|
306
|
+
if (!(conv_num(&bp, &i, 0, 9999)))
|
|
307
|
+
return (0);
|
|
308
|
+
|
|
309
|
+
tm->tm_year = i - TM_YEAR_BASE;
|
|
310
|
+
break;
|
|
311
|
+
|
|
312
|
+
case 'y': /* The year within 100 years of the epoch. */
|
|
313
|
+
LEGAL_ALT(ALT_E | ALT_O);
|
|
314
|
+
if (!(conv_num(&bp, &i, 0, 99)))
|
|
315
|
+
return (0);
|
|
316
|
+
|
|
317
|
+
if (split_year)
|
|
318
|
+
{
|
|
319
|
+
tm->tm_year = ((tm->tm_year / 100) * 100) + i;
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
split_year = 1;
|
|
323
|
+
if (i <= 68)
|
|
324
|
+
tm->tm_year = i + 2000 - TM_YEAR_BASE;
|
|
325
|
+
else
|
|
326
|
+
tm->tm_year = i + 1900 - TM_YEAR_BASE;
|
|
327
|
+
break;
|
|
328
|
+
|
|
329
|
+
/*
|
|
330
|
+
* Miscellaneous conversions.
|
|
331
|
+
*/
|
|
332
|
+
case 'n': /* Any kind of white-space. */
|
|
333
|
+
case 't':
|
|
334
|
+
LEGAL_ALT(0);
|
|
335
|
+
while (isspace(*bp))
|
|
336
|
+
bp++;
|
|
337
|
+
break;
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
default: /* Unknown/unsupported conversion. */
|
|
341
|
+
return (0);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/* LINTED functional specification */
|
|
348
|
+
return ((char *)bp);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
static int conv_num(const char **buf, int *dest, int llim, int ulim)
|
|
353
|
+
{
|
|
354
|
+
int result = 0;
|
|
355
|
+
|
|
356
|
+
/* The limit also determines the number of valid digits. */
|
|
357
|
+
int rulim = ulim;
|
|
358
|
+
|
|
359
|
+
if (**buf < '0' || **buf > '9')
|
|
360
|
+
return (0);
|
|
361
|
+
|
|
362
|
+
do {
|
|
363
|
+
result *= 10;
|
|
364
|
+
result += *(*buf)++ - '0';
|
|
365
|
+
rulim /= 10;
|
|
366
|
+
} while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9');
|
|
367
|
+
|
|
368
|
+
if (result < llim || result > ulim)
|
|
369
|
+
return (0);
|
|
370
|
+
|
|
371
|
+
*dest = result;
|
|
372
|
+
return (1);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
int strncasecmp(char *s1, char *s2, size_t n)
|
|
376
|
+
{
|
|
377
|
+
if (n == 0)
|
|
378
|
+
return 0;
|
|
379
|
+
|
|
380
|
+
while (n-- != 0 && tolower(*s1) == tolower(*s2))
|
|
381
|
+
{
|
|
382
|
+
if (n == 0 || *s1 == '\0' || *s2 == '\0')
|
|
383
|
+
break;
|
|
384
|
+
s1++;
|
|
385
|
+
s2++;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
|
|
389
|
+
}
|