/[osn-commons]/trunk/freehttpd/main.c
ViewVC logotype

Diff of /trunk/freehttpd/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 44 by rakinar2, Sat Aug 10 18:33:37 2024 UTC revision 45 by rakinar2, Sun Aug 11 17:35:46 2024 UTC
# Line 1  Line 1 
1  #include "freehttpd.h"  #include "freehttpd.h"
2  #include <errno.h>  #include <errno.h>
3  #include <getopt.h>  #include <getopt.h>
4    #include <magic.h>
5  #include <stdbool.h>  #include <stdbool.h>
6  #include <stdio.h>  #include <stdio.h>
7  #include <stdlib.h>  #include <stdlib.h>
# Line 89  main (int argc, char **argv) Line 90  main (int argc, char **argv)
90      if (!validate_settings ())      if (!validate_settings ())
91          exit (EXIT_FAILURE);          exit (EXIT_FAILURE);
92    
93      freehttpd_t *freehttpd = freehttpd_init ();      magic_t magic = magic_open (MAGIC_MIME);
94      unsigned int port = 8080;      unsigned int port = 8080;
95      size_t uri_len = 1024;      size_t uri_len = 1024;
96      ecode_t code = E_OK;      ecode_t code = E_OK;
97    
98        if (magic == NULL)
99            {
100                fprintf (stderr, "%s: failed to initialize magic\n",
101                         config.progname);
102                exit (EXIT_FAILURE);
103            }
104    
105        if (magic_load (magic, NULL) != 0)
106            {
107                fprintf (stderr, "%s: failed to load magic database\n",
108                         config.progname);
109                magic_close (magic);
110                exit (EXIT_FAILURE);
111            }
112    
113        freehttpd_t *freehttpd = freehttpd_init (magic);
114    
115      code = freehttpd_setopt (freehttpd, FREEHTTPD_CONFIG_PORT, &port);      code = freehttpd_setopt (freehttpd, FREEHTTPD_CONFIG_PORT, &port);
116    
117      if (code != E_OK)      if (code != E_OK)
# Line 109  main (int argc, char **argv) Line 127  main (int argc, char **argv)
127      if (code != E_OK)      if (code != E_OK)
128          goto error;          goto error;
129    
130        char *docroot = getenv ("FREEHTTPD_DOCROOT");
131        code = freehttpd_setopt (freehttpd, FREEHTTPD_CONFIG_DOCROOT,
132                                 docroot ? docroot : "/var/www");
133    
134        if (code != E_OK)
135            goto error;
136    
137      code = freehttpd_start (freehttpd);      code = freehttpd_start (freehttpd);
138    
139      if (code != E_OK)      if (code != E_OK)
# Line 121  main (int argc, char **argv) Line 146  main (int argc, char **argv)
146          }          }
147    
148      freehttpd_free (freehttpd);      freehttpd_free (freehttpd);
149        magic_close (magic);
150      return 0;      return 0;
151  }  }

Legend:
Removed from v.44  
changed lines
  Added in v.45

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26