MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cgiCopyTemplateLang

Function cgiCopyTemplateLang

cgi-bin/template.c:77–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75 */
76
77void
78cgiCopyTemplateLang(const char *tmpl) /* I - Base filename */
79{
80 char filename[1024], /* Filename */
81 locale[16], /* Locale name */
82 *locptr; /* Pointer into locale name */
83 const char *directory, /* Directory for templates */
84 *lang; /* Language */
85 FILE *in; /* Input file */
86
87
88 fprintf(stderr, "DEBUG2: cgiCopyTemplateLang(tmpl=\"%s\")\n",
89 tmpl ? tmpl : "(null)");
90
91 /*
92 * Convert the language to a locale name...
93 */
94
95 if ((lang = getenv("LANG")) != NULL)
96 {
97 locale[0] = '/';
98 strlcpy(locale + 1, lang, sizeof(locale) - 1);
99
100 if ((locptr = strchr(locale, '.')) != NULL)
101 *locptr = '\0'; /* Strip charset */
102 }
103 else
104 {
105 locale[0] = '\0';
106 }
107
108 fprintf(stderr, "DEBUG2: lang=\"%s\", locale=\"%s\"...\n",
109 lang ? lang : "(null)", locale);
110
111 /*
112 * See if we have a template file for this language...
113 */
114
115 directory = cgiGetTemplateDir();
116
117 snprintf(filename, sizeof(filename), "%s%s/%s", directory, locale, tmpl);
118 if ((in = fopen(filename, "r")) == NULL)
119 {
120 locale[3] = '\0';
121
122 snprintf(filename, sizeof(filename), "%s%s/%s", directory, locale, tmpl);
123 if ((in = fopen(filename, "r")) == NULL)
124 {
125 snprintf(filename, sizeof(filename), "%s/%s", directory, tmpl);
126 in = fopen(filename, "r");
127 }
128 }
129
130 fprintf(stderr, "DEBUG2: Template file is \"%s\"...\n", filename);
131
132 /*
133 * Open the template file...
134 */

Callers 15

mainFunction · 0.85
cgiMoveJobsFunction · 0.85
cgiPrintCommandFunction · 0.85
cgiPrintTestPageFunction · 0.85
cgiShowIPPErrorFunction · 0.85
cgiShowJobsFunction · 0.85
mainFunction · 0.85
do_job_opFunction · 0.85
cgiEndHTMLFunction · 0.85
cgiStartHTMLFunction · 0.85
mainFunction · 0.85
do_class_opFunction · 0.85

Calls 2

cgiGetTemplateDirFunction · 0.85
cgi_copyFunction · 0.85

Tested by

no test coverage detected