MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / API_ROUTINE gds__get_prefix

Function API_ROUTINE gds__get_prefix

src/yvalve/gds.cpp:1806–1865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1804
1805
1806SLONG API_ROUTINE gds__get_prefix(SSHORT arg_type, const TEXT* passed_string)
1807{
1808/**************************************
1809 *
1810 * g d s _ $ g e t _ p r e f i x
1811 *
1812 **************************************
1813 *
1814 * Functional description
1815 * Find appropriate Firebird command line arguments
1816 * for Interbase file prefix.
1817 *
1818 * arg_type is 0 for $FIREBIRD, 1 for $FIREBIRD_LOCK
1819 * and 2 for $FIREBIRD_MSG
1820 *
1821 * Function returns 0 on success and -1 on failure
1822 * it has very strange name, but to keep API as is leave it
1823 **************************************/
1824 if (! passed_string)
1825 return -1;
1826
1827 Firebird::PathName prefix(passed_string);
1828 prefix.erase(MAXPATHLEN);
1829 for (FB_SIZE_T n = 0; n < prefix.length(); ++n)
1830 {
1831 switch (prefix[n])
1832 {
1833 case ' ':
1834 case '\n': // don't know exact reason - just keep
1835 case '\r': // old API call behavior
1836 prefix.erase(n);
1837 break; // will also leave for() due to length change
1838 }
1839 }
1840
1841 if (arg_type == IB_PREFIX_TYPE)
1842 {
1843 // it's very important to do it BEFORE GDS_init_prefix()
1844 Firebird::Config::setRootDirectoryFromCommandLine(prefix);
1845 }
1846
1847 GDS_init_prefix();
1848
1849 switch (arg_type)
1850 {
1851 case IB_PREFIX_TYPE:
1852 prefix.copyTo(fb_prefix_val, sizeof fb_prefix_val);
1853 break;
1854 case IB_PREFIX_LOCK_TYPE:
1855 prefix.copyTo(fb_prefix_lock_val, sizeof fb_prefix_lock_val);
1856 break;
1857 case IB_PREFIX_MSG_TYPE:
1858 prefix.copyTo(fb_prefix_msg_val, sizeof fb_prefix_msg_val);
1859 break;
1860 default:
1861 return -1;
1862 }
1863

Callers

nothing calls this directly

Calls 4

GDS_init_prefixFunction · 0.85
eraseMethod · 0.45
lengthMethod · 0.45
copyToMethod · 0.45

Tested by

no test coverage detected