MCPcopy Create free account
hub / github.com/MariaDB/server / PROFILE_GetSection

Function PROFILE_GetSection

storage/connect/inihandl.cpp:826–885  ·  view source on GitHub ↗

* PROFILE_GetSection * * Returns all keys of a section. * If return_values is TRUE, also include the corresponding values. ***********************************************************************/

Source from the content-addressed store, hash-verified

824 * If return_values is TRUE, also include the corresponding values.
825 ***********************************************************************/
826static int PROFILE_GetSection(PROFILESECTION *section, LPCSTR section_name,
827 LPSTR buffer, uint len,
828 BOOL handle_env, BOOL return_values)
829{
830 PROFILEKEY *key;
831
832 if(!buffer)
833 return 0;
834
835 while (section) {
836 if (section->name[0] && !stricmp(section->name, section_name)) {
837 uint oldlen = len;
838
839 for (key = section->key; key; key = key->next) {
840 if (len <= 2)
841 break;
842
843 if (!*key->name)
844 continue; /* Skip empty lines */
845
846 if (IS_ENTRY_COMMENT(key->name))
847 continue; /* Skip comments */
848
849 PROFILE_CopyEntry(buffer, key->name, len - 1, handle_env);
850 len -= strlen(buffer) + 1;
851 buffer += strlen(buffer) + 1;
852
853 if (len < 2)
854 break;
855
856 if (return_values && key->value) {
857 buffer[-1] = '=';
858 PROFILE_CopyEntry(buffer, key->value, len - 1, handle_env);
859 len -= strlen(buffer) + 1;
860 buffer += strlen(buffer) + 1;
861 } // endif return_values
862
863 } // endfor key
864
865 *buffer = '\0';
866
867 if (len <= 1) {
868 /*If either lpszSection or lpszKey is NULL and the supplied
869 destination buffer is too small to hold all the strings,
870 the last string is truncated and followed by two null characters.
871 In this case, the return value is equal to cchReturnBuffer
872 minus two. */
873 buffer[-1] = '\0';
874 return oldlen - 2;
875 } // endif len
876
877 return oldlen - len;
878 } // endif section->name
879
880 section = section->next;
881 } // endwhile section
882
883 buffer[0] = buffer[1] = '\0';

Callers 2

PROFILE_GetStringFunction · 0.85
GetPrivateProfileSectionFunction · 0.85

Calls 1

PROFILE_CopyEntryFunction · 0.85

Tested by

no test coverage detected