NetSurf
Functions
dirlist.c File Reference

Generate HTML content for displaying directory listings (implementation). More...

#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "utils/nsurl.h"
#include "utils/messages.h"
#include "utils/nscolour.h"
#include "netsurf/inttypes.h"
#include "netsurf/types.h"
#include "netsurf/plot_style.h"
#include "dirlist.h"
#include "desktop/system_colour.h"
Include dependency graph for dirlist.c:

Go to the source code of this file.

Functions

static int dirlist_filesize_calculate (unsigned long *bytesize)
 Obtain display value and units for filesize after conversion to B/kB/MB/GB, as appropriate. More...
 
static int dirlist_filesize_value (unsigned long bytesize)
 Obtain display value for filesize after conversion to B/kB/MB/GB, as appropriate. More...
 
static char * dirlist_filesize_unit (unsigned long bytesize)
 Obtain display units for filesize after conversion to B/kB/MB/GB, as appropriate. More...
 
bool dirlist_generate_top (char *buffer, int buffer_length)
 Generates the top part of an HTML directory listing page. More...
 
bool dirlist_generate_hide_columns (int flags, char *buffer, int buffer_length)
 Generates the part of an HTML directory listing page that can suppress particular columns. More...
 
bool dirlist_generate_title (const char *title, char *buffer, int buffer_length)
 Generates the part of an HTML directory listing page that contains the title. More...
 
bool dirlist_generate_parent_link (const char *parent, char *buffer, int buffer_length)
 Generates the part of an HTML directory listing page that links to the parent directory. More...
 
bool dirlist_generate_headings (char *buffer, int buffer_length)
 Generates the part of an HTML directory listing page that displays the column headings. More...
 
bool dirlist_generate_row (bool even, bool directory, nsurl *url, char *name, const char *mimetype, long long size, char *date, char *time, char *buffer, int buffer_length)
 Generates the part of an HTML directory listing page that displays a row in the directory contents table. More...
 
bool dirlist_generate_bottom (char *buffer, int buffer_length)
 Generates the bottom part of an HTML directory listing page. More...
 

Detailed Description

Generate HTML content for displaying directory listings (implementation).

Definition in file dirlist.c.

Function Documentation

◆ dirlist_filesize_calculate()

int dirlist_filesize_calculate ( unsigned long *  bytesize)
static

Obtain display value and units for filesize after conversion to B/kB/MB/GB, as appropriate.


Parameters
bytesizefile size in bytes, updated to filesize in output units
Returns
number of times bytesize has been divided by 1024

Definition at line 367 of file dirlist.c.

Referenced by dirlist_filesize_unit(), and dirlist_filesize_value().

Here is the caller graph for this function:

◆ dirlist_filesize_unit()

char * dirlist_filesize_unit ( unsigned long  bytesize)
static

Obtain display units for filesize after conversion to B/kB/MB/GB, as appropriate.

Parameters
bytesizefile size in bytes
Returns
Units to display for file size, for value given by filesize_value()

Definition at line 403 of file dirlist.c.

References dirlist_filesize_calculate().

Referenced by dirlist_generate_row().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dirlist_filesize_value()

int dirlist_filesize_value ( unsigned long  bytesize)
static

Obtain display value for filesize after conversion to B/kB/MB/GB, as appropriate.

Parameters
bytesizefile size in bytes
Returns
Value to display for file size, in units given by filesize_unit()

Definition at line 388 of file dirlist.c.

References dirlist_filesize_calculate().

Referenced by dirlist_generate_row().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dirlist_generate_bottom()

bool dirlist_generate_bottom ( char *  buffer,
int  buffer_length 
)

Generates the bottom part of an HTML directory listing page.

Returns
Bottom of directory listing HTML

This is part of a series of functions. To generate a complete page, call the following functions in order:

dirlist_generate_top()
dirlist_generate_hide_columns()  -- optional
dirlist_generate_title()
dirlist_generate_parent_link()   -- optional
dirlist_generate_headings()
dirlist_generate_row()           -- call 'n' times for 'n' rows
dirlist_generate_bottom()

Definition at line 344 of file dirlist.c.

References buffer.

Referenced by fetch_file_process_dir().

Here is the caller graph for this function:

◆ dirlist_generate_headings()

bool dirlist_generate_headings ( char *  buffer,
int  buffer_length 
)

Generates the part of an HTML directory listing page that displays the column headings.

Parameters
bufferbuffer to fill with generated HTML
buffer_lengthmaximum size of buffer
Returns
true iff buffer filled without error

This is part of a series of functions. To generate a complete page, call the following functions in order:

dirlist_generate_top()
dirlist_generate_hide_columns()  -- optional
dirlist_generate_title()
dirlist_generate_parent_link()   -- optional
dirlist_generate_headings()
dirlist_generate_row()           -- call 'n' times for 'n' rows
dirlist_generate_bottom()

Definition at line 237 of file dirlist.c.

References buffer, and messages_get().

Referenced by fetch_file_process_dir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dirlist_generate_hide_columns()

bool dirlist_generate_hide_columns ( int  flags,
char *  buffer,
int  buffer_length 
)

Generates the part of an HTML directory listing page that can suppress particular columns.

Parameters
flagsflags for which cols to suppress. 0 to suppress none
bufferbuffer to fill with generated HTML
buffer_lengthmaximum size of buffer
Returns
true iff buffer filled without error

This is part of a series of functions. To generate a complete page, call the following functions in order:

dirlist_generate_top()
dirlist_generate_hide_columns()  -- optional
dirlist_generate_title()
dirlist_generate_parent_link()   -- optional
dirlist_generate_headings()
dirlist_generate_row()           -- call 'n' times for 'n' rows
dirlist_generate_bottom()

Definition at line 100 of file dirlist.c.

References buffer, DIRLIST_NO_DATE_COLUMN, DIRLIST_NO_NAME_COLUMN, DIRLIST_NO_SIZE_COLUMN, DIRLIST_NO_TIME_COLUMN, and DIRLIST_NO_TYPE_COLUMN.

◆ dirlist_generate_parent_link()

bool dirlist_generate_parent_link ( const char *  parent,
char *  buffer,
int  buffer_length 
)

Generates the part of an HTML directory listing page that links to the parent directory.

Parameters
parenturl of parent directory
bufferbuffer to fill with generated HTML
buffer_lengthmaximum size of buffer
Returns
true iff buffer filled without error

This is part of a series of functions. To generate a complete page, call the following functions in order:

dirlist_generate_top()
dirlist_generate_hide_columns()  -- optional
dirlist_generate_title()
dirlist_generate_parent_link()   -- optional
dirlist_generate_headings()
dirlist_generate_row()           -- call 'n' times for 'n' rows
dirlist_generate_bottom()

Definition at line 202 of file dirlist.c.

References buffer, messages_get(), and parent.

Referenced by fetch_file_process_dir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dirlist_generate_row()

bool dirlist_generate_row ( bool  even,
bool  directory,
nsurl url,
char *  name,
const char *  mimetype,
long long  size,
char *  date,
char *  time,
char *  buffer,
int  buffer_length 
)

Generates the part of an HTML directory listing page that displays a row in the directory contents table.

Parameters
evenevenness of row number, for alternate row colouring
directorywhether this row is for a directory (or a file)
urlurl for row entry
namename of row entry
mimetypeMIME type of row entry
sizesize of row entry. If negative, size is left blank
datedate row entry was last modified
timetime row entry was last modified
bufferbuffer to fill with generated HTML
buffer_lengthmaximum size of buffer
Returns
true iff buffer filled without error

This is part of a series of functions. To generate a complete page, call the following functions in order:

dirlist_generate_top()
dirlist_generate_hide_columns()  -- optional
dirlist_generate_title()
dirlist_generate_parent_link()   -- optional
dirlist_generate_headings()
dirlist_generate_row()           -- call 'n' times for 'n' rows
dirlist_generate_bottom()

Definition at line 289 of file dirlist.c.

References buffer, dirlist_filesize_unit(), dirlist_filesize_value(), messages_get(), and nsurl_access().

Referenced by process_dir_ent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dirlist_generate_title()

bool dirlist_generate_title ( const char *  title,
char *  buffer,
int  buffer_length 
)

Generates the part of an HTML directory listing page that contains the title.

Parameters
titletitle to use
bufferbuffer to fill with generated HTML
buffer_lengthmaximum size of buffer
Returns
true iff buffer filled without error

This is part of a series of functions. To generate a complete page, call the following functions in order:

dirlist_generate_top()
dirlist_generate_hide_columns()  -- optional
dirlist_generate_title()
dirlist_generate_parent_link()   -- optional
dirlist_generate_headings()
dirlist_generate_row()           -- call 'n' times for 'n' rows
dirlist_generate_bottom()

Definition at line 143 of file dirlist.c.

References buffer, colour_rb_swap, nscolour_get_stylesheet(), NSCOLOUR_WIN_ODD_BG, nscolours, and NSERROR_OK.

Referenced by fetch_file_process_dir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dirlist_generate_top()

bool dirlist_generate_top ( char *  buffer,
int  buffer_length 
)

Generates the top part of an HTML directory listing page.

Returns
Top of directory listing HTML

This is part of a series of functions. To generate a complete page, call the following functions in order:

dirlist_generate_top()
dirlist_generate_hide_columns()  -- optional
dirlist_generate_title()
dirlist_generate_parent_link()   -- optional
dirlist_generate_headings()
dirlist_generate_row()           -- call 'n' times for 'n' rows
dirlist_generate_bottom()

Definition at line 61 of file dirlist.c.

References buffer.

Referenced by fetch_file_process_dir().

Here is the caller graph for this function: