static void uploadprogress_file_php_get_info(char * id, zval * return_value)
{
char s[1024];
char * filename;
char * template;
FILE *F;
TSRMLS_FETCH();
template = INI_STR(“uploadprogress.file.filename_template”); <<这里读取设置好的模板
if (strcmp(template, “”) == 0) {
return;
} else {
filename = uploadprogress_mk_filename( id, template );<<<存在的话,会创建
if (!filename) return;
F = VCWD_FOPEN(filename, “rb”);
if (F) {
array_init(return_value);
while ( fgets(s, 1000, F) ) {<<<从流中读取一字符串 *s结果数据的首地址;1000-1:一次读入数据块的长度,其默认值为1k,即1024;F文件指针
char *k, *v, *e;
int index = 0;
e = strchr(s,’='); <<<查找字符串s中首次出现字符=的位置
if (!e) continue;
*e = 0; /* break the line into 2 parts */
v = e+1;
k = s;
/* trim spaces in front of the name/value */
while (*k && *k <= 32) k++;
while (*v && *v <= 32) v++;
/* trim spaces everywhere in the name */
for (e=k; *e; e++) if (*e <= 32) { *e = 0; break; }
/* trim spaces only at the end of the value */
/* http://pecl.php.net/bugs/bug.php?id=14525 */
//for (e=v; *e; e++) if (*e <= 32) { *e = 0; break; }
if (v != NULL) {<<<当文件有内容时
for (index = strlen(v); index > 0; index–) {
if (v[index] > 32) break;<<<累计
v[index] = 0;
}
}
add_assoc_string( return_value, k, v, 1 );
}
fclose(F);
}
if (filename) efree(filename);
return;
}
}