Changeset af8bda0 in mainline
- Timestamp:
- 2018-07-05T21:41:19Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2987160
- Parents:
- d91b329
- git-author:
- Dzejrou <dzejrou@…> (2017-12-18 12:28:07)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:19)
- Location:
- uspace/lib/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
rd91b329 raf8bda0 1689 1689 } 1690 1690 1691 /** Convert string to int64_t. 1692 * 1693 * @param nptr Pointer to string. 1694 * @param endptr If not NULL, pointer to the first invalid character 1695 * is stored here. 1696 * @param base Zero or number between 2 and 36 inclusive. 1697 * @param strict Do not allow any trailing characters. 1698 * @param result Result of the conversion. 1699 * 1700 * @return EOK if conversion was successful. 1701 * 1702 */ 1703 int str_int64_t(const char *nptr, const char **endptr, unsigned int base, 1704 bool strict, int64_t *result) 1705 { 1706 assert(result != NULL); 1707 1708 bool neg; 1709 char *lendptr; 1710 uint64_t unsigned_result; 1711 int ret = str_uint(nptr, &lendptr, base, &neg, &unsigned_result); 1712 1713 if (endptr != NULL) 1714 *endptr = (char *) lendptr; 1715 1716 if (ret != EOK) 1717 return ret; 1718 1719 /* Do not allow negative values */ 1720 if (neg) { 1721 if (unsigned_result == UINT64_MAX) 1722 return EINVAL; 1723 1724 *result = -(int64_t)unsigned_result; 1725 } else 1726 *result = unsigned_result; 1727 1728 /* Check whether we are at the end of 1729 the string in strict mode */ 1730 if ((strict) && (*lendptr != 0)) 1731 return EINVAL; 1732 1733 return EOK; 1734 } 1735 1691 1736 /** Convert string to size_t. 1692 1737 * -
uspace/lib/c/include/str.h
rd91b329 raf8bda0 126 126 extern errno_t str_size_t(const char *, const char **, unsigned int, bool, 127 127 size_t *); 128 extern int str_int64_t(const char *, const char **, unsigned int, bool, 129 int64_t *); 128 130 129 131 extern void order_suffix(const uint64_t, uint64_t *, char *);
Note:
See TracChangeset
for help on using the changeset viewer.