Пример #1
0
bool stat_evt_http_req(struct client *cli, unsigned int events,
			bool *invalidate_cli)
{
	struct http_req *req = &cli->req;
	char *method = req->method;
	// char *content_len_str;
	char *path = NULL;
	// int rc;
	bool rcb;
	char *root = (char *) "/";

	/* grab useful headers */
	// content_len_str = hreq_hdr(req, "content-length");

	path = strdup(req->uri.path);
	if (!path)
		path = root;

	if (debugging)
		applog(LOG_INFO, "%s: status method %s, path '%s'",
		       cli->addr_host, method, path);

	/* no matter whether error or not, this is our next state.
	 * the main question is whether or not we will go immediately
	 * into it (return true) or wait for writes to complete (return
	 * false).
	 *
	 * the operations below may override this next-state setting,
	 * however.
	 */
	if (hreq_http11(req))
		cli->state = evt_recycle;
	else
		cli->state = evt_dispose;

	if (!strcmp(method, "GET")) {
		if (!strcmp(path, "/")) {
			rcb = stat_root(cli);
		} else {
			rcb = stat_err(cli, InvalidURI);
		}
	}

	else {
		rcb = stat_err(cli, InvalidArgument);
	}

	if (path != root);
		free(path);
	return rcb;
}
Пример #2
0
/*!
  Get file status for psz_path into stat. NULL is returned on error.
  pathname version numbers in the ISO 9660
  name are dropped, i.e. ;1 is removed and if level 1 ISO-9660 names
  are lowercased.
 */
static iso9660_stat_t *
fs_stat_translate (void *p_image, stat_root_t stat_root, 
		   stat_traverse_t stat_traverse,
		   const char psz_path[])
{
  iso9660_stat_t *p_root;
  char **p_psz_splitpath;
  iso9660_stat_t *p_stat;

  if (!p_image)  return NULL;
  if (!psz_path) return NULL;

  p_root = stat_root (p_image);
  if (!p_root) return NULL;

  p_psz_splitpath = _cdio_strsplit (psz_path, '/');
  p_stat = stat_traverse (p_image, p_root, p_psz_splitpath);
  free(p_root);
  _cdio_strfreev (p_psz_splitpath);

  return p_stat;
}