run OpenBSDindent(1) to fix coding style
This commit is contained in:
parent
25977754ac
commit
24aa4ba284
1 changed files with 47 additions and 50 deletions
17
main.c
17
main.c
|
@ -65,14 +65,14 @@ display_file(char *path)
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
// this is to check if path is a directory
|
/* this is to check if path is a directory */
|
||||||
stat(path, &sb);
|
stat(path, &sb);
|
||||||
|
|
||||||
FILE *fd = fopen(path, "r");
|
FILE *fd = fopen(path, "r");
|
||||||
|
|
||||||
if (fd != NULL && S_ISDIR(sb.st_mode) != 1) {
|
if (fd != NULL && S_ISDIR(sb.st_mode) != 1) {
|
||||||
|
|
||||||
// check if directory
|
/* check if directory */
|
||||||
ok_status();
|
ok_status();
|
||||||
|
|
||||||
/* read the file and write it to stdout */
|
/* read the file and write it to stdout */
|
||||||
|
@ -100,10 +100,8 @@ main(int argc, char **argv)
|
||||||
int option;
|
int option;
|
||||||
char *pos;
|
char *pos;
|
||||||
|
|
||||||
while((option = getopt(argc, argv, ":d:")) != -1)
|
while ((option = getopt(argc, argv, ":d:")) != -1) {
|
||||||
{
|
switch (option) {
|
||||||
switch(option)
|
|
||||||
{
|
|
||||||
case 'd':
|
case 'd':
|
||||||
strlcpy(path, optarg, sizeof(path));
|
strlcpy(path, optarg, sizeof(path));
|
||||||
break;
|
break;
|
||||||
|
@ -144,7 +142,6 @@ main(int argc, char **argv)
|
||||||
request, start_with_gemini);
|
request, start_with_gemini);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove the gemini:// part */
|
/* remove the gemini:// part */
|
||||||
strlcpy(buffer, request + GEMINI_PART, sizeof(buffer) - GEMINI_PART);
|
strlcpy(buffer, request + GEMINI_PART, sizeof(buffer) - GEMINI_PART);
|
||||||
strlcpy(request, buffer, sizeof(request));
|
strlcpy(request, buffer, sizeof(request));
|
||||||
|
@ -170,9 +167,9 @@ main(int argc, char **argv)
|
||||||
strlcpy(hostname, request, position);
|
strlcpy(hostname, request, position);
|
||||||
strlcpy(file, request + position + 1, sizeof(request));
|
strlcpy(file, request + position + 1, sizeof(request));
|
||||||
|
|
||||||
/* use a default file if no file are requested
|
/*
|
||||||
* this can happen in two cases
|
* use a default file if no file are requested this
|
||||||
* gemini://hostname/
|
* can happen in two cases gemini://hostname/
|
||||||
* gemini://hostname/directory/
|
* gemini://hostname/directory/
|
||||||
*/
|
*/
|
||||||
if (strlen(file) == 0)
|
if (strlen(file) == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue