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

Function PROFILE_GetSectionNames

storage/connect/inihandl.cpp:889–944  ·  view source on GitHub ↗

See GetPrivateProfileSectionNamesA for documentation */

Source from the content-addressed store, hash-verified

887
888/* See GetPrivateProfileSectionNamesA for documentation */
889static int PROFILE_GetSectionNames(LPSTR buffer, uint len)
890{
891 LPSTR buf;
892 uint f,l;
893 PROFILESECTION *section;
894
895 if (trace(2))
896 htrc("GetSectionNames: buffer=%p len=%u\n", buffer, len);
897
898 if (!buffer || !len)
899 return 0;
900
901 if (len == 1) {
902 *buffer='\0';
903 return 0;
904 } // endif len
905
906 f = len - 1;
907 buf = buffer;
908 section = CurProfile->section;
909
910 if (trace(2))
911 htrc("GetSectionNames: section=%p\n", section);
912
913 while (section != NULL) {
914 if (trace(2))
915 htrc("section=%s\n", section->name);
916
917 if (section->name[0]) {
918 l = strlen(section->name) + 1;
919
920 if (trace(2))
921 htrc("l=%u f=%u\n", l, f);
922
923 if (l > f) {
924 if (f > 0) {
925 strncpy(buf, section->name, f-1);
926 buf += f-1;
927 *buf++='\0';
928 } // endif f
929
930 *buf = '\0';
931 return len - 2;
932 } // endif l
933
934 strcpy(buf, section->name);
935 buf += l;
936 f -= l;
937 } // endif section->name
938
939 section = section->next;
940 } // endwhile section
941
942 *buf='\0';
943 return buf-buffer;
944} // end of PROFILE_GetSectionNames
945
946

Callers 2

Calls 1

htrcFunction · 0.70

Tested by

no test coverage detected