Skip to content

Instantly share code, notes, and snippets.

@Globik

Globik/file command

Last active Oct 4, 2017
Embed
What would you like to do?
hello_world in Lwan.c environment
file ./hello_world
./hello_world: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=16f24d59fb4fc8a31086dd8e8305edc289655a3a, not stripped
gcc -I /usr/local/include/lwan -o hello_world hello_world.c -L/usr/local/lib -llwan -L/usr/lib/i386-linux-gnu/libz.so -lz -lpthread -L/usr/lib -llua5.1 -lm
globik@globik-laptop:~/lwan/minimal$ ./hello_world
2352 lwan-job.c:96 lwan_job_thread_init() Initializing low priority job thread.
2352 lwan-tables.c:40 lwan_tables_init() Uncompressing MIME type table.
2352 lwan.c:60 lwan_module_init() Initializing module registry.
2352 lwan.c:397 setup_from_config() Loading configuration file: hello_world.conf.
2352 lwan.c:469 setup_from_config() Error on config file "hello_world.conf", line 9: Could not find handler "hello_world".
Aborted (core dumped)
#include <stdio.h>
#include <stdlib.h>
#include "lwan.h"
static enum lwan_http_status
hello_world(struct lwan_request *request,struct lwan_response *response,void *data){
static const char message[]="hello world";
response->mime_type="text/plain";
strbuf_set_static(response->buffer,message,sizeof(message)-1);
return HTTP_OK;
}
int main(void){
const struct lwan_url_map default_map[] = {
{ .prefix = "/", .handler = hello_world },
{}
};
struct lwan l;
lwan_init(&l);
lwan_set_url_map(&l,default_map);
lwan_main_loop(&l);
lwan_shutdown(&l);
return 0;
}
//gcc -I /usr/local/include/lwan -o hello_world hello_world.c -L/usr/local/lib -llwan -L/usr/lib/i386-linux-gnu/libz.so -lz -lpthread -L/usr/lib -llua5.1 -lm
keep_alive_timeout = 15
reuse_port = false
threads = 0
proxy_protocol = 0
listener 127.0.0.1:8080 {
prefix / {
handler = hello_world
}
}
globik@globik-laptop:~/lwan/minimal$ nm ./hello_world
0804a034 B __bss_start
0804a034 b completed.6591
0804a02c D __data_start
0804a02c W data_start
080485e0 t deregister_tm_clones
08048650 t __do_global_dtors_aux
08049eec t __do_global_dtors_aux_fini_array_entry
0804a030 D __dso_handle
08049ef4 d _DYNAMIC
0804a034 D _edata
0804a038 B _end
080487e4 T _fini
080487f8 R _fp_hw
08048670 t frame_dummy
08049ee8 t __frame_dummy_init_array_entry
08048928 r __FRAME_END__
0804a000 d _GLOBAL_OFFSET_TABLE_
w __gmon_start__
0804869d t hello_world
080484ec T _init
08049eec t __init_array_end
08049ee8 t __init_array_start
080487fc R _IO_stdin_used
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
08049ef0 d __JCR_END__
08049ef0 d __JCR_LIST__
w _Jv_RegisterClasses
080487e0 T __libc_csu_fini
08048770 T __libc_csu_init
U __libc_start_main@@GLIBC_2.0
U lwan_init
U lwan_main_loop
U lwan_set_url_map
U lwan_shutdown
080486d1 T main
0804880d r message.3893
08048610 t register_tm_clones
U __stack_chk_fail@@GLIBC_2.4
080485a0 T _start
U strbuf_set_static
0804a034 D __TMC_END__
080485d0 T __x86.get_pc_thunk.bx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment