Lines Matching full:path

508 mg_static_assert(PATH_MAX >= 1, "path length must be a positive number");
760 const char *path,
854 #define mg_mkdir(conn, path, mode) (mkdir(path, mode)) argument
3122 const char *path, in open_file_in_memory() argument
3139 buf = conn->phys_ctx->callbacks.open_file(conn, path, &size); in open_file_in_memory()
3171 (void)path; in open_file_in_memory()
3182 is_file_in_memory(const struct mg_connection *conn, const char *path) in is_file_in_memory() argument
3184 return open_file_in_memory(conn, path, NULL, MG_FOPEN_MODE_NONE); in is_file_in_memory()
3205 const char *path,
3210 * The input parameter path is a string in UTF-8 encoding.
3217 const char *path, in mg_fopen() argument
3231 if (!is_file_in_memory(conn, path)) { in mg_fopen()
3235 found = mg_stat(conn, path, &(filep->stat)); in mg_fopen()
3245 path_to_unicode(conn, path, wbuf, ARRAY_SIZE(wbuf)); in mg_fopen()
3262 filep->access.fp = fopen(path, "r"); in mg_fopen()
3265 filep->access.fp = fopen(path, "w"); in mg_fopen()
3268 filep->access.fp = fopen(path, "a"); in mg_fopen()
3277 found = mg_stat(conn, path, &(filep->stat)); in mg_fopen()
3287 if (open_file_in_memory(conn, path, filep, mode)) { in mg_fopen()
4403 const char *path,
5157 /* For Windows, change all slashes to backslashes in path names. */
5159 change_slashes_to_backslashes(char *path) argument
5163 for (i = 0; path[i] != '\0'; i++) {
5164 if (path[i] == '/') {
5165 path[i] = '\\';
5170 if ((path[i] == '\\') && (i > 0)) {
5171 while ((path[i + 1] == '\\') || (path[i + 1] == '/')) {
5172 (void)memmove(path + i + 1, path + i + 2, strlen(path + i + 1));
5195 /* Encode 'path' which is assumed UTF-8 string, into UNICODE string.
5199 const char *path, argument
5208 mg_strlcpy(buf, path, sizeof(buf));
5241 /* Only accept a full file path, not a Windows short (8.3) path. */
5260 if (strchr(path, '~')) {
5270 const char *path, argument
5283 if (conn && is_file_in_memory(conn, path)) {
5290 open_file_in_memory(conn, path, &tmp_file, MG_FOPEN_MODE_NONE);
5312 path_to_unicode(conn, path, wbuf, ARRAY_SIZE(wbuf));
5316 len = strlen(path);
5317 if ((len > 0) && (path[len - 1] != ' ') && (path[len - 1] != '.')
5344 mg_remove(const struct mg_connection *conn, const char *path) argument
5347 path_to_unicode(conn, path, wbuf, ARRAY_SIZE(wbuf));
5353 mg_mkdir(const struct mg_connection *conn, const char *path, int mode) argument
5357 path_to_unicode(conn, path, wbuf, ARRAY_SIZE(wbuf));
5873 const char *path, argument
5882 if (conn && is_file_in_memory(conn, path)) {
5887 open_file_in_memory(conn, path, &tmp_file, MG_FOPEN_MODE_NONE);
5896 if (0 == stat(path, &st)) {
6982 * Switch to alternative code path that uses incremental
7355 /* For given directory path, substitute it to valid index file.
7360 char *path, argument
7366 size_t n = strlen(path);
7369 /* The 'path' given to us points to the directory. Remove all trailing
7370 * directory separator characters from the end of the path, and
7372 while ((n > 0) && (path[n - 1] == '/')) {
7375 path[n] = '/';
7378 * path and see if the file exists. If it exists, break the loop */
7380 /* Ignore too long entries that may overflow path buffer */
7385 /* Prepare full path to the index file */
7386 mg_strlcpy(path + n + 1, filename_vec.ptr, filename_vec.len + 1);
7389 if (mg_stat(conn, path, filestat)) {
7396 /* If no index file exists, restore directory path */
7398 path[n] = '\0';
7477 /* Step 6: Determine the local file path from the root path and the
7480 * part of the path one byte on the right. */
7509 /* Local file path and name, corresponding to requested URI
7523 * /path/script.cgi), and there is no additional resource
7524 * path (like /path/script.cgi/something).
7638 DEBUG_TRACE("Substitute script %s serving path %s",
7667 DEBUG_TRACE("Substitute file %s serving path %s",
7958 mg_get_builtin_mime_type(const char *path) argument
7963 path_len = strlen(path);
7966 ext = path + (path_len - builtin_mime_types[i].ext_len);
7977 /* Look at the "path" extension and figure what mime type it has.
7980 get_mime_type(struct mg_connection *conn, const char *path, struct vec *vec) argument
7986 path_len = strlen(path);
7999 /* ext now points to the path suffix */
8000 ext = path + path_len - ext_vec.len;
8007 vec->ptr = mg_get_builtin_mime_type(path);
8099 const char *path, argument
8116 /* Important: using local struct mg_file to test path for
8121 } else if (mg_stat(conn, path, &filep->stat)
8128 path,
8142 for (p = path, e = p + strlen(p) - 1; e > p; e--) {
8522 check_authorization(struct mg_connection *conn, const char *path) argument
8559 open_auth_file(conn, path, &file);
8570 (void)path;
8704 /* The maximum length of the path to the password file is limited */
9217 must_hide_file(struct mg_connection *conn, const char *path) argument
9222 return (match_prefix(pw_pattern, strlen(pw_pattern), path) > 0)
9224 && (match_prefix(pattern, strlen(pattern), path) > 0));
9237 char path[PATH_MAX]; local
9256 conn, &truncated, path, sizeof(path), "%s/%s", dir, dp->d_name);
9266 /* If the path is not complete, skip processing. */
9270 if (!mg_stat(conn, path, &de.file)) {
9274 path,
9291 char path[PATH_MAX]; local
9311 conn, &truncated, path, sizeof(path), "%s/%s", dir, dp->d_name);
9326 if (!mg_stat(conn, path, &de.file)) {
9330 path,
9336 if (remove_directory(conn, path) == 0) {
9341 if (mg_remove(conn, path) == 0) {
9667 const char *path, argument
9701 get_mime_type(conn, path, &mime_vec);
9731 mg_snprintf(conn, &truncated, gz_path, sizeof(gz_path), "%s.gz", path);
9736 "Error: Path of zipped file too long (%s)",
9737 path);
9741 path = gz_path;
9752 mg_snprintf(conn, &truncated, gz_path, sizeof(gz_path), "%s.gz", path);
9759 path = gz_path;
9769 if (!mg_fopen(conn, path, MG_FOPEN_MODE_READ, filep)) {
9773 path,
9924 mg_send_file_body(struct mg_connection *conn, const char *path) argument
9927 if (!mg_fopen(conn, path, MG_FOPEN_MODE_READ, &file)) {
9991 mg_send_file(struct mg_connection *conn, const char *path) argument
9993 mg_send_mime_file2(conn, path, NULL, NULL);
9999 const char *path, argument
10002 mg_send_mime_file2(conn, path, mime_type, NULL);
10008 const char *path, argument
10019 if (mg_stat(conn, path, &file.stat)) {
10029 handle_directory_request(conn, path);
10038 conn, path, &file, mime_type, additional_headers);
10046 /* For a given PUT path, create all intermediate subdirectories.
10047 * Return 0 if the path itself is a directory.
10048 * Return 1 if the path leads to a file.
10049 * Return -1 for if the path is too long.
10050 * Return -2 if path can not be created.
10053 put_dir(struct mg_connection *conn, const char *path) argument
10061 for (s = p = path + 2; (p = strchr(s, '/')) != NULL; s = ++p) {
10062 len = (size_t)(p - path);
10064 /* path too long */
10068 memcpy(buf, path, len);
10074 /* path does not exixt and can not be created */
10079 /* Is path itself a directory? */
10090 remove_bad_file(const struct mg_connection *conn, const char *path) argument
10092 int r = mg_remove(conn, path);
10097 path);
10103 mg_store_body(struct mg_connection *conn, const char *path) argument
10115 ret = put_dir(conn, path);
10117 /* -1 for path too long,
10118 * -2 for path can not be created. */
10122 /* Return 0 means, path itself is a directory. */
10126 if (mg_fopen(conn, path, MG_FOPEN_MODE_WRITE, &fi) == 0) {
10136 remove_bad_file(conn, path);
10147 remove_bad_file(conn, path);
10696 /* Each error code path in this function must send an error */
10927 if ((s = getenv("PATH")) != NULL) {
10928 addenv(env, "PATH=%s", s);
11095 mg_cry_internal(conn, "Error: CGI program \"%s\": Path too long", prog);
11096 mg_send_http_error(conn, 500, "Error: %s", "CGI path too long");
11375 mkcol(struct mg_connection *conn, const char *path) argument
11390 if (!mg_stat(conn, path, &de.file)) {
11394 path,
11403 conn, 405, "Error: mkcol(%s): %s", path, strerror(ERRNO));
11410 conn, 415, "Error: mkcol(%s): %s", path, strerror(ERRNO));
11414 rc = mg_mkdir(conn, path, 0755);
11433 conn, 405, "Error: mkcol(%s): %s", path, strerror(ERRNO));
11436 conn, 403, "Error: mkcol(%s): %s", path, strerror(ERRNO));
11439 conn, 409, "Error: mkcol(%s): %s", path, strerror(ERRNO));
11442 conn, 500, "fopen(%s): %s", path, strerror(ERRNO));
11449 put_file(struct mg_connection *conn, const char *path) argument
11462 if (mg_stat(conn, path, &file.stat)) {
11482 path);
11488 if (access(path, W_OK) == 0) {
11497 path);
11504 rc = put_dir(conn, path);
11508 /* put_dir returns 0 if path is a directory */
11529 /* put_dir returns -1 if the path is too long */
11532 "Error: Path too long\nput_dir(%s): %s",
11533 path,
11543 path,
11550 if (!mg_fopen(conn, path, MG_FOPEN_MODE_WRITE, &file)
11556 path,
11600 delete_file(struct mg_connection *conn, const char *path) argument
11604 if (!mg_stat(conn, path, &de.file)) {
11609 path);
11620 path);
11626 if (remove_directory(conn, path)) {
11631 mg_send_http_error(conn, 500, "Error: Could not delete %s", path);
11638 if (access(path, W_OK) != 0) {
11644 path);
11649 if (mg_remove(conn, path) == 0) {
11657 path,
11675 char file_name[MG_BUF_LEN], path[512], *p; local
11692 path,
11693 sizeof(path),
11700 * or it is absolute system path */
11703 mg_snprintf(conn, &truncated, path, sizeof(path), "%s", file_name);
11709 (void)mg_snprintf(conn, &truncated, path, sizeof(path), "%s", ssi);
11712 if ((p = strrchr(path, '/')) != NULL) {
11715 len = strlen(path);
11718 path + len,
11719 sizeof(path) - len,
11730 mg_cry_internal(conn, "SSI #include path length overflow: [%s]", tag);
11734 if (!mg_fopen(conn, path, MG_FOPEN_MODE_READ, &file)) {
11738 path,
11744 path)
11746 send_ssi_file(conn, path, &file, include_level + 1);
11804 const char *path, argument
11812 mg_cry_internal(conn, "SSI #include level is too deep (%s)", path);
11833 do_ssi_include(conn, path, buf + 12, include_level + 1);
11842 path,
11867 mg_cry_internal(conn, "%s: tag is too large", path);
11910 const char *path, argument
11918 if ((conn == NULL) || (path == NULL) || (filep == NULL)) {
11932 if (!mg_fopen(conn, path, MG_FOPEN_MODE_READ, filep)) {
11938 path,
11957 send_ssi_file(conn, path, filep, 0);
12069 const char *path, argument
12078 if (!conn || !path || !filep || !conn->dom_ctx) {
12108 scan_directory(conn, path, conn, &print_dav_dir_entry);
12671 const char *path, argument
12685 (void)path;
12823 path);
12828 conn->lua_websocket_state = lua_websocket_new(path, conn);
13017 char *path, argument
13031 path,
13037 mg_cry_internal(fud->conn, "%s: File path too long", __func__);
13063 mg_upload_field_stored(const char *path, long long file_size, void *user_data) argument
13069 fud->conn->phys_ctx->callbacks.upload(fud->conn, path);
13670 /* Check if the script file is in a path, allowed for script files.
13675 is_in_script_path(const struct mg_connection *conn, const char *path) argument
13677 /* TODO (Feature): Add config value for allowed script path.
13680 (void)path;
13734 char path[PATH_MAX]; local
13754 path[0] = 0;
13789 /* 1.4. clean URIs, so a path like allowed_dir/../forbidden_file is
13931 path,
13932 sizeof(path),
13988 if (!check_authorization(conn, path)) {
14029 path,
14030 sizeof(path),
14052 path,
14070 if (is_in_script_path(conn, path)) {
14073 path,
14082 /* Script was in an illegal path */
14089 path,
14121 handle_file_based_request(conn, path, &file);
14129 put_file(conn, path);
14134 delete_file(conn, path);
14139 mkcol(conn, path);
14154 if (!is_found || (must_hide_file(conn, path))) {
14181 handle_propfind(conn, path, &file.stat);
14211 handle_directory_request(conn, path);
14222 handle_file_based_request(conn, path, &file);
14230 const char *path, argument
14242 path)
14244 if (is_in_script_path(conn, path)) {
14249 handle_lsp_request(conn, path, file, NULL);
14251 /* Script was in an illegal path */
14258 path)
14260 if (is_in_script_path(conn, path)) {
14265 mg_exec_lua_script(conn, path, NULL);
14267 /* Script was in an illegal path */
14275 path)
14277 if (is_in_script_path(conn, path)) {
14279 mg_exec_duktape_script(conn, path);
14281 /* Script was in an illegal path */
14288 path)
14290 if (is_in_script_path(conn, path)) {
14292 handle_cgi_request(conn, path);
14294 /* Script was in an illegal path */
14300 path)
14302 if (is_in_script_path(conn, path)) {
14303 handle_ssi_file_request(conn, path, file);
14305 /* Script was in an illegal path */
14315 handle_static_file_request(conn, path, file, NULL, NULL);
16154 const char *path; local
16159 path = dom_ctx->config[GLOBAL_PASSWORDS_FILE];
16160 if ((path != NULL)
16161 && !mg_stat(fake_connection(&fc, phys_ctx), path, &file.stat)) {
16164 path,
16898 * Allow full matches (like http://mydomain.com/path/file.ext), and
16899 * allow subdomain matches (like http://www.mydomain.com/path/file.ext),
16901 * http://notmydomain.com/path/file.ext
16902 * or http://mydomain.com.fake/path/file.ext).
17372 const char *path, argument
17416 path,
17506 (void)path;