|
@@ -270,25 +270,25 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
/* Store the content to a file */
|
|
/* Store the content to a file */
|
|
if (mg_fopen(conn, path, "wb", &fstore) == 0) {
|
|
if (mg_fopen(conn, path, "wb", &fstore) == 0) {
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fstore.access.fp = NULL;
|
|
}
|
|
}
|
|
file_size = 0;
|
|
file_size = 0;
|
|
- if (fstore.fp != NULL) {
|
|
|
|
- size_t n =
|
|
|
|
- (size_t)fwrite(val, 1, (size_t)vallen, fstore.fp);
|
|
|
|
- if ((n != (size_t)vallen) || (ferror(fstore.fp))) {
|
|
|
|
|
|
+ if (fstore.access.fp != NULL) {
|
|
|
|
+ size_t n = (size_t)
|
|
|
|
+ fwrite(val, 1, (size_t)vallen, fstore.access.fp);
|
|
|
|
+ if ((n != (size_t)vallen) || (ferror(fstore.access.fp))) {
|
|
mg_cry(conn,
|
|
mg_cry(conn,
|
|
"%s: Cannot write file %s",
|
|
"%s: Cannot write file %s",
|
|
__func__,
|
|
__func__,
|
|
path);
|
|
path);
|
|
- fclose(fstore.fp);
|
|
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fclose(fstore.access.fp);
|
|
|
|
+ fstore.access.fp = NULL;
|
|
remove_bad_file(conn, path);
|
|
remove_bad_file(conn, path);
|
|
}
|
|
}
|
|
file_size += (int64_t)n;
|
|
file_size += (int64_t)n;
|
|
|
|
|
|
- if (fstore.fp) {
|
|
|
|
- r = fclose(fstore.fp);
|
|
|
|
|
|
+ if (fstore.access.fp) {
|
|
|
|
+ r = fclose(fstore.access.fp);
|
|
if (r == 0) {
|
|
if (r == 0) {
|
|
/* stored successfully */
|
|
/* stored successfully */
|
|
field_stored(conn, path, file_size, fdh);
|
|
field_stored(conn, path, file_size, fdh);
|
|
@@ -299,7 +299,7 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
path);
|
|
path);
|
|
remove_bad_file(conn, path);
|
|
remove_bad_file(conn, path);
|
|
}
|
|
}
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fstore.access.fp = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -406,10 +406,10 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
|
|
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
if (mg_fopen(conn, path, "wb", &fstore) == 0) {
|
|
if (mg_fopen(conn, path, "wb", &fstore) == 0) {
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fstore.access.fp = NULL;
|
|
}
|
|
}
|
|
file_size = 0;
|
|
file_size = 0;
|
|
- if (!fstore.fp) {
|
|
|
|
|
|
+ if (!fstore.access.fp) {
|
|
mg_cry(conn, "%s: Cannot create file %s", __func__, path);
|
|
mg_cry(conn, "%s: Cannot create file %s", __func__, path);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -446,16 +446,16 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
fdh);
|
|
fdh);
|
|
get_block++;
|
|
get_block++;
|
|
}
|
|
}
|
|
- if (fstore.fp) {
|
|
|
|
- size_t n =
|
|
|
|
- (size_t)fwrite(val, 1, (size_t)vallen, fstore.fp);
|
|
|
|
- if ((n != (size_t)vallen) || (ferror(fstore.fp))) {
|
|
|
|
|
|
+ if (fstore.access.fp) {
|
|
|
|
+ size_t n = (size_t)
|
|
|
|
+ fwrite(val, 1, (size_t)vallen, fstore.access.fp);
|
|
|
|
+ if ((n != (size_t)vallen) || (ferror(fstore.access.fp))) {
|
|
mg_cry(conn,
|
|
mg_cry(conn,
|
|
"%s: Cannot write file %s",
|
|
"%s: Cannot write file %s",
|
|
__func__,
|
|
__func__,
|
|
path);
|
|
path);
|
|
- fclose(fstore.fp);
|
|
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fclose(fstore.access.fp);
|
|
|
|
+ fstore.access.fp = NULL;
|
|
remove_bad_file(conn, path);
|
|
remove_bad_file(conn, path);
|
|
}
|
|
}
|
|
file_size += (int64_t)n;
|
|
file_size += (int64_t)n;
|
|
@@ -494,8 +494,8 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
|
|
|
|
} while (!end_of_key_value_pair_found);
|
|
} while (!end_of_key_value_pair_found);
|
|
|
|
|
|
- if (fstore.fp) {
|
|
|
|
- r = fclose(fstore.fp);
|
|
|
|
|
|
+ if (fstore.access.fp) {
|
|
|
|
+ r = fclose(fstore.access.fp);
|
|
if (r == 0) {
|
|
if (r == 0) {
|
|
/* stored successfully */
|
|
/* stored successfully */
|
|
field_stored(conn, path, file_size, fdh);
|
|
field_stored(conn, path, file_size, fdh);
|
|
@@ -503,7 +503,7 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
mg_cry(conn, "%s: Error saving file %s", __func__, path);
|
|
mg_cry(conn, "%s: Error saving file %s", __func__, path);
|
|
remove_bad_file(conn, path);
|
|
remove_bad_file(conn, path);
|
|
}
|
|
}
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fstore.access.fp = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
/* Proceed to next entry */
|
|
/* Proceed to next entry */
|
|
@@ -673,11 +673,11 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
/* Store the content to a file */
|
|
/* Store the content to a file */
|
|
if (mg_fopen(conn, path, "wb", &fstore) == 0) {
|
|
if (mg_fopen(conn, path, "wb", &fstore) == 0) {
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fstore.access.fp = NULL;
|
|
}
|
|
}
|
|
file_size = 0;
|
|
file_size = 0;
|
|
|
|
|
|
- if (!fstore.fp) {
|
|
|
|
|
|
+ if (!fstore.access.fp) {
|
|
mg_cry(conn, "%s: Cannot create file %s", __func__, path);
|
|
mg_cry(conn, "%s: Cannot create file %s", __func__, path);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -705,17 +705,17 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
}
|
|
}
|
|
|
|
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
- if (fstore.fp) {
|
|
|
|
|
|
+ if (fstore.access.fp) {
|
|
|
|
|
|
/* Store the content of the buffer. */
|
|
/* Store the content of the buffer. */
|
|
- n = (size_t)fwrite(hend, 1, towrite, fstore.fp);
|
|
|
|
- if ((n != towrite) || (ferror(fstore.fp))) {
|
|
|
|
|
|
+ n = (size_t)fwrite(hend, 1, towrite, fstore.access.fp);
|
|
|
|
+ if ((n != towrite) || (ferror(fstore.access.fp))) {
|
|
mg_cry(conn,
|
|
mg_cry(conn,
|
|
"%s: Cannot write file %s",
|
|
"%s: Cannot write file %s",
|
|
__func__,
|
|
__func__,
|
|
path);
|
|
path);
|
|
- fclose(fstore.fp);
|
|
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fclose(fstore.access.fp);
|
|
|
|
+ fstore.access.fp = NULL;
|
|
remove_bad_file(conn, path);
|
|
remove_bad_file(conn, path);
|
|
}
|
|
}
|
|
file_size += (int64_t)n;
|
|
file_size += (int64_t)n;
|
|
@@ -760,15 +760,15 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
|
|
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
|
|
|
|
- if (fstore.fp) {
|
|
|
|
- n = (size_t)fwrite(hend, 1, towrite, fstore.fp);
|
|
|
|
- if ((n != towrite) || (ferror(fstore.fp))) {
|
|
|
|
|
|
+ if (fstore.access.fp) {
|
|
|
|
+ n = (size_t)fwrite(hend, 1, towrite, fstore.access.fp);
|
|
|
|
+ if ((n != towrite) || (ferror(fstore.access.fp))) {
|
|
mg_cry(conn,
|
|
mg_cry(conn,
|
|
"%s: Cannot write file %s",
|
|
"%s: Cannot write file %s",
|
|
__func__,
|
|
__func__,
|
|
path);
|
|
path);
|
|
- fclose(fstore.fp);
|
|
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fclose(fstore.access.fp);
|
|
|
|
+ fstore.access.fp = NULL;
|
|
remove_bad_file(conn, path);
|
|
remove_bad_file(conn, path);
|
|
}
|
|
}
|
|
file_size += (int64_t)n;
|
|
file_size += (int64_t)n;
|
|
@@ -777,8 +777,8 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
|
|
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
if (field_storage == FORM_FIELD_STORAGE_STORE) {
|
|
|
|
|
|
- if (fstore.fp) {
|
|
|
|
- r = fclose(fstore.fp);
|
|
|
|
|
|
+ if (fstore.access.fp) {
|
|
|
|
+ r = fclose(fstore.access.fp);
|
|
if (r == 0) {
|
|
if (r == 0) {
|
|
/* stored successfully */
|
|
/* stored successfully */
|
|
field_stored(conn, path, file_size, fdh);
|
|
field_stored(conn, path, file_size, fdh);
|
|
@@ -789,7 +789,7 @@ mg_handle_form_request(struct mg_connection *conn,
|
|
path);
|
|
path);
|
|
remove_bad_file(conn, path);
|
|
remove_bad_file(conn, path);
|
|
}
|
|
}
|
|
- fstore.fp = NULL;
|
|
|
|
|
|
+ fstore.access.fp = NULL;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|