MCPcopy Create free account
hub / github.com/F-Stack/f-stack / login_getstyle

Function login_getstyle

tools/libutil/login_cap.c:779–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

777 */
778
779const char *
780login_getstyle(login_cap_t *lc, const char *style, const char *auth)
781{
782 int i;
783 const char **authtypes = NULL;
784 char *auths= NULL;
785 char realauth[64];
786
787 static const char *defauthtypes[] = { LOGIN_DEFSTYLE, NULL };
788
789 if (auth != NULL && *auth != '\0') {
790 if (snprintf(realauth, sizeof realauth, "auth-%s", auth) < (int)sizeof(realauth))
791 authtypes = login_getcaplist(lc, realauth, NULL);
792 }
793
794 if (authtypes == NULL)
795 authtypes = login_getcaplist(lc, "auth", NULL);
796
797 if (authtypes == NULL)
798 authtypes = defauthtypes;
799
800 /*
801 * We have at least one authtype now; auths is a comma-separated
802 * (or space-separated) list of authentication types. We have to
803 * convert from this to an array of char*'s; authtypes then gets this.
804 */
805 i = 0;
806 if (style != NULL && *style != '\0') {
807 while (authtypes[i] != NULL && strcmp(style, authtypes[i]) != 0)
808 i++;
809 }
810
811 lc->lc_style = NULL;
812 if (authtypes[i] != NULL && (auths = strdup(authtypes[i])) != NULL)
813 lc->lc_style = auths;
814
815 if (lc->lc_style != NULL)
816 lc->lc_style = strdup(lc->lc_style);
817
818 return lc->lc_style;
819}

Callers

nothing calls this directly

Calls 4

snprintfFunction · 0.85
login_getcaplistFunction · 0.85
strcmpFunction · 0.85
strdupFunction · 0.85

Tested by

no test coverage detected