Exemplo n.º 1
0
static void ShowDirText(FILE * out, struct parsedname * pn)
{
	HTTPstart(out, "200 OK", ct_text);

	FS_dir(ShowDirTextCallback, out, pn);
	return;
}
Exemplo n.º 2
0
/* Only error is if parsename fails */
GOOD_OR_BAD DS9490_root_dir( struct dirblob * db, struct connection_in * in )
{
	ASCII path[PATH_MAX] ;
	struct parsedname pn_root ;

	UCLIBCLOCK;
		/* Force this adapter with bus.n path */
		snprintf(path, PATH_MAX, "/uncached/bus.%d", in->index);
	UCLIBCUNLOCK;

	if ( FS_ParsedName(path, &pn_root) != 0 ) {
		LEVEL_DATA("Cannot get root directory on [%s] Parsing %s error.", SAFESTRING(DEVICENAME(in)), path);
		return gbBAD ;
	}
	DirblobInit( db ) ;
	/* First time pretend there are devices */
	pn_root.selected_connection->changed_bus_settings |= CHANGED_USB_SPEED ;	// Trigger needing new configuration
	pn_root.selected_connection->overdrive = 0 ;	// not overdrive at start
	pn_root.selected_connection->flex = Globals.usb_flextime ;
	
	SetReconnect(&pn_root) ;
	FS_dir( DS9490_dir_callback, db, &pn_root ) ;
	LEVEL_DEBUG("Finished FS_dir");
	FS_ParsedName_destroy(&pn_root) ;

	return gbGOOD ;
	// Dirblob must be cleared by recipient.
}
Exemplo n.º 3
0
static void WildLexCD(struct cd_parse_s *cps, ASCII * match)
{
	struct parsedname pn;

	LEVEL_DEBUG("FTP Wildcard patern matching: Path=%s, Pattern=%s, rest=%s", SAFESTRING(cps->buffer), SAFESTRING(match), SAFESTRING(cps->rest));
	/* Check potential length */
	if (strlen(cps->buffer) + OW_FULLNAME_MAX + 2 > PATH_MAX) {
		cps->ret = -ENAMETOOLONG;
		return;
	}

	if ( FS_ParsedName(cps->buffer, &pn) != 0 ) {
		cps->ret = -ENOENT;
		return;
	}

	if (!IsDir(&pn)) {
		cps->ret = -ENOTDIR;
	} else {
		struct wildlexcd wlcd = { NULL, match, cps, };
		int root = (cps->buffer[1] == '\0');

		wlcd.end = &cps->buffer[strlen(cps->buffer)];
		if (root) {
			--wlcd.end;
		}
		wlcd.end[0] = '/';
		FS_dir(WildLexCDCallback, &wlcd, &pn);
		if (root) {
			++wlcd.end;
		}
		wlcd.end[0] = '\0';		// restore cps->buffer
	}
	FS_ParsedName_destroy(&pn);
}
Exemplo n.º 4
0
static void getdir( struct charblob * cb, struct one_wire_query * owq ) 
{  
	if ( FS_dir( getdircallback, cb, PN(owq) ) != 0 ) {
		CharblobClear( cb ) ;
	} else if ( CharblobLength(cb) == 0 ) {
		CharblobAddChar( '\0', cb) ;
	}
}
Exemplo n.º 5
0
static void ShowDirJson(FILE * out, struct parsedname * pn)
{
	HTTPstart(out, "200 OK", ct_text);

	fprintf(out, "{" );
	FS_dir(ShowDirJsonCallback, out, pn);
	fprintf(out, "}" );
	return;
}
Exemplo n.º 6
0
static int getdir( struct charblob * cb, struct one_wire_query * owq ) 
{
	int ret = 0;
	if ( (ret = FS_dir( getdircallback, cb, PN(owq) )) != 0 ) {
		CharblobClear( cb ) ;
	} else if ( CharblobLength(cb) == 0 ) {
		CharblobAddChar( '\0', cb) ;
	}
	return ret;
}
Exemplo n.º 7
0
static void ShowDirJson(FILE * out, struct parsedname * pn)
{
	struct JsonCBstruct jcbs ;
	
	JSON_dir_init( &jcbs, out ) ;

	HTTPstart(out, "200 OK", ct_json);

	fprintf(out, "{" );
	FS_dir(ShowDirJsonCallback, &jcbs, pn);
	
	JSON_dir_finish( &jcbs ) ;
	fprintf(out, "}" );
	return;
}
Exemplo n.º 8
0
	/* Misnamed. Actually all directory */
void ShowDir(FILE * out, struct parsedname * pn)
{
	int b = Backup(pn->path); // length of string to get to higher level
	if (pn->state & ePS_text) {
		ShowDirText(out, pn);
		return;
	} else if (pn->state & ePS_json) {
		ShowDirJson(out, pn);
		return;
	}

	HTTPstart(out, "200 OK", ct_html);
	HTTPtitle(out, "Directory");

	if (NotRealDir(pn)) {
		/* return whole path since tree structure could be much deeper now */
		/* first / is stripped off */
		HTTPheader(out, &pn->path[1]);
	} else if (pn->state) {
		/* return whole path since tree structure could be much deeper now */
		/* first / is stripped off */
		HTTPheader(out, &pn->path[1]);
	} else {
		HTTPheader(out, "directory");
	}


	fprintf(out, "<TABLE BGCOLOR=\"#DDDDDD\" BORDER=1>");

	if (b != 1) {
		char * escaped_path = httpescape( pn->path ) ;
		fprintf(out, "<TR><TD><A HREF='%.*s'><CODE><B><BIG>up</BIG></B></CODE></A></TD><TD>higher level</TD><TD>directory</TD></TR>", b, escaped_path==NULL ? pn->path : escaped_path );
		if ( escaped_path ) {
			owfree( escaped_path ) ;
		}
	} else {
		fprintf(out, "<TR><TD><A HREF='/'><CODE><B><BIG>top</BIG></B></CODE></A></TD><TD>highest level</TD><TD>directory</TD></TR>");
	}

	FS_dir(ShowDirCallback, out, pn);
	fprintf(out, "</TABLE>");
	HTTPfoot(out);
}