int main(int argc, char ** argv) { /* TODO: uname() */ char * _uname = malloc(sizeof(char) * 1024); syscall_kernel_string_XXX(_uname); fprintf(stdout, "\n%s\n\n", _uname); syscall_signal(2, sig_int); syscall_signal(11, sig_segv); while (1) { char * username = malloc(sizeof(char) * 1024); char * password = malloc(sizeof(char) * 1024); /* TODO: gethostname() */ char _hostname[256]; syscall_gethostname(_hostname); fprintf(stdout, "%s login: "******"password: \033[1001z"); fflush(stdout); fgets(password, 1024, stdin); password[strlen(password)-1] = '\0'; fprintf(stdout, "\033[1002z\n"); int uid = checkUserPass(username, password); if (uid < 0) { fprintf(stdout, "\nLogin failed.\n"); continue; } pid_t pid = getpid(); uint32_t f = fork(); if (getpid() != pid) { /* TODO: Read appropriate shell from /etc/passwd */ char * args[] = { "/bin/esh", NULL }; syscall_setuid(uid); int i = execve(args[0], args, NULL); } else { child = f; syscall_wait(f); } child = 0; free(username); free(password); } return 0; }
/* -------------------------------------------------------------------------- * * Initialize things. * * -------------------------------------------------------------------------- */ void servauth_init(void) { /* log_init(0, 0, 0);*/ mem_init(); timer_init(); queue_init(); dlink_init(); connect_init(); db_init(); log_init(1, LOG_ALL, L_debug); #ifdef SIGPIPE syscall_signal(SIGPIPE, SIG_IGN); #endif servauth_log = log_source_register("servauth"); servauth_drain = log_drain_open("servauth.log", LOG_ALL, L_debug, 1, 1); log(servauth_log, L_status, "Done initialising ircd library"); }
int main (int argc, char ** argv) { setup_windowing(); int width = wins_globals->server_width; int height = wins_globals->server_height; win_width = width; win_height = height; event_pipe = syscall_mkpipe(); /* Do something with a window */ window_t * wina = window_create(0,0, width, height); assert(wina); window_reorder (wina, 0); ctx = init_graphics_window_double_buffer(wina); draw_fill(ctx, rgb(127,127,127)); flip(ctx); syscall_signal(2, sig_int); char f_name[512]; sprintf(f_name, "%s/.wallpaper.png", getenv("HOME")); FILE * f = fopen(f_name, "r"); if (f) { fclose(f); init_sprite_png(0, f_name); } else { init_sprite_png(0, "/usr/share/wallpaper.png"); } float x = (float)width / (float)sprites[0]->width; float y = (float)height / (float)sprites[0]->height; int nh = (int)(x * (float)sprites[0]->height); int nw = (int)(y * (float)sprites[0]->width);; if (nw > width) { draw_sprite_scaled(ctx, sprites[0], (width - nw) / 2, 0, nw, height); } else { draw_sprite_scaled(ctx, sprites[0], 0, (height - nh) / 2, width, nh); } flip(ctx); init_shmemfonts(); /* Load Application Shortcuts */ uint32_t i = 0; while (1) { if (!applications[i].icon) { break; } printf("Loading png %s\n", applications[i].icon); init_sprite_png(i+1, applications[i].icon); draw_sprite(ctx, sprites[i+1], ICON_X, ICON_TOP_Y + ICON_SPACING_Y * i); int str_w = draw_string_width(applications[i].title) / 2; int str_x = ICON_X + ICON_WIDTH / 2 - str_w; int str_y = ICON_TOP_Y + ICON_SPACING_Y * i + ICON_WIDTH + 14; draw_string_shadow(ctx, str_x, str_y, rgb(255,255,255), applications[i].title, rgb(0,0,0), 2, 1, 1, 3.0); ++i; } flip(ctx); /* Enable mouse */ win_use_threaded_handler(); mouse_action_callback = wallpaper_check_click; while (_continue) { char buf; read(event_pipe, &buf, 1); if (next_run_activate) { launch_application(next_run_activate); next_run_activate = NULL; } } teardown_windowing(); return 0; }
int main (int argc, char ** argv) { setup_windowing(); int width = wins_globals->server_width; int height = wins_globals->server_height; win_width = width; win_height = height; init_shmemfonts(); set_font_size(14); /* Create the panel */ window_t * panel = window_create(0, 0, width, PANEL_HEIGHT); window_reorder (panel, 0xFFFF); ctx = init_graphics_window_double_buffer(panel); draw_fill(ctx, rgba(0,0,0,0)); flip(ctx); init_sprite_png(0, "/usr/share/panel.png"); init_sprite_png(1, "/usr/share/icons/panel-shutdown.png"); for (uint32_t i = 0; i < width; i += sprites[0]->width) { draw_sprite(ctx, sprites[0], i, 0); } size_t buf_size = panel->width * panel->height * sizeof(uint32_t); char * buf = malloc(buf_size); memcpy(buf, ctx->backbuffer, buf_size); flip(ctx); struct timeval now; int last = 0; struct tm * timeinfo; char buffer[80]; struct utsname u; uname(&u); /* UTF-8 Strings FTW! */ uint8_t * os_name_ = "PonyOS"; uint8_t final[512]; uint32_t l = snprintf(final, 512, "%s %s", os_name_, u.release); syscall_signal(2, sig_int); /* Enable mouse */ win_use_threaded_handler(); mouse_action_callback = panel_check_click; while (_continue) { /* Redraw the background by memcpy (super speedy) */ memcpy(ctx->backbuffer, buf, buf_size); syscall_gettimeofday(&now, NULL); //time(NULL); if (now.tv_sec != last) { last = now.tv_sec; timeinfo = localtime((time_t *)&now.tv_sec); strftime(buffer, 80, "%I:%M:%S %p", timeinfo); draw_string(ctx, width - 120, 17, rgb(255,255,255), buffer); draw_string(ctx, 10, 17, rgb(255,255,255), final); draw_sprite(ctx, sprites[1], win_width - 23, 1); /* Logout button */ flip(ctx); } syscall_nanosleep(0,50); }
sighandler_t signal(int signum, sighandler_t handler) { return (sighandler_t)syscall_signal(signum, (void *)handler); }