Back to index

webcit  8.12-dfsg
Functions
graphics.c File Reference
#include "webcit.h"

Go to the source code of this file.

Functions

void output_static (const char *What)
void display_graphics_upload (char *filename)
void do_graphics_upload (char *filename)
void edithellopic (void)
void editpic (void)
void editgoodbuyepic (void)
void display_editpic (void)
void display_editroompic (void)
void display_edithello (void)
void display_editgoodbyepic (void)
void display_editfloorpic (void)
void editroompic (void)
void editfloorpic (void)
void InitModule_GRAPHICS (void)

Function Documentation

void display_editfloorpic ( void  )

Definition at line 134 of file graphics.c.

                                {
       StrBuf *PicAction;

       PicAction = NewStrBuf();
       StrBufPrintf(PicAction, "_floorpic_|%s", bstr("which_floor"));
       putbstr("__WHICHPIC", PicAction);
       putbstr("__PICDESC", NewStrBufPlain(_("the icon for this floor"), -1));
       putbstr("__UPLURL", NewStrBufPlain(HKEY("editfloorpic")));
       display_graphics_upload("editfloorpic");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_editgoodbyepic ( void  )

Definition at line 127 of file graphics.c.

                                  {
       putbstr("__WHICHPIC", NewStrBufPlain(HKEY("UIMG 0|%s|goodbuye")));
       putbstr("__PICDESC", NewStrBufPlain(_("the Logoff banner picture"), -1));
       putbstr("__UPLURL", NewStrBufPlain(HKEY("editgoodbuyepic")));
       display_graphics_upload("editgoodbuyepic");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_edithello ( void  )

Definition at line 119 of file graphics.c.

                             {
       putbstr("__WHICHPIC", NewStrBufPlain(HKEY("hello")));
       putbstr("__PICDESC", NewStrBufPlain(_("the Greetingpicture for the login prompt"), -1));
       putbstr("__UPLURL", NewStrBufPlain(HKEY("edithellopic")));
       display_graphics_upload("edithellopic");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_editpic ( void  )

Definition at line 104 of file graphics.c.

                           {
       putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_userpic_")));
       putbstr("__PICDESC", NewStrBufPlain(_("your photo"), -1));
       putbstr("__UPLURL", NewStrBufPlain(HKEY("editpic")));
       display_graphics_upload("editpic");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_editroompic ( void  )

Definition at line 111 of file graphics.c.

                               {
       putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_roompic_")));
       putbstr("__PICDESC", NewStrBufPlain(_("the icon for this room"), -1));
       putbstr("__UPLURL", NewStrBufPlain(HKEY("editroompic")));
       display_graphics_upload("editroompic");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_graphics_upload ( char *  filename)

Definition at line 19 of file graphics.c.

{
       StrBuf *Line;

       Line = NewStrBuf();
       serv_printf("UIMG 0||%s", filename);
       StrBuf_ServGetln(Line);
       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
              display_main_menu();
              return;
       }
       else
       {
              output_headers(1, 0, 0, 0, 1, 0);
              do_template("files_graphicsupload");
              end_burst();
       }
       FreeStrBuf(&Line);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void do_graphics_upload ( char *  filename)

Definition at line 39 of file graphics.c.

{
       StrBuf *Line;
       const char *MimeType;
       wcsession *WCC = WC;
       int bytes_remaining;
       int pos = 0;
       int thisblock;
       bytes_remaining = WCC->upload_length;

       if (havebstr("cancel_button")) {
              AppendImportantMessage(_("Graphics upload has been cancelled."), -1);
              display_main_menu();
              return;
       }

       if (WCC->upload_length == 0) {
              AppendImportantMessage(_("You didn't upload a file."), -1);
              display_main_menu();
              return;
       }
       
       MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining);
       serv_printf("UIMG 1|%s|%s", MimeType, filename);

       Line = NewStrBuf();
       StrBuf_ServGetln(Line);
       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
              display_main_menu();
              FreeStrBuf(&Line);
              return;
       }
       while (bytes_remaining) {
              thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
              serv_printf("WRIT %d", thisblock);
              StrBuf_ServGetln(Line);
              if (GetServerStatusMsg(Line, NULL, 1, 7) != 7) {
                     serv_puts("UCLS 0");
                     StrBuf_ServGetln(Line);
                     display_main_menu();
                     FreeStrBuf(&Line);
                     return;
              }
              thisblock = extract_int(ChrPtr(Line) +4, 0);
              serv_write(&ChrPtr(WCC->upload)[pos], thisblock);
              pos += thisblock;
              bytes_remaining -= thisblock;
       }

       serv_puts("UCLS 1");
       StrBuf_ServGetln(Line);
       if (*ChrPtr(Line) != 'x') {
              display_success(ChrPtr(Line) + 4);
       
       }
       FreeStrBuf(&Line);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void editfloorpic ( void  )

Definition at line 152 of file graphics.c.

                       {
       char buf[SIZ];
       snprintf(buf, SIZ, "_floorpic_|%s",
               bstr("which_floor"));
       do_graphics_upload(buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void editgoodbuyepic ( void  )

Definition at line 101 of file graphics.c.

{ do_graphics_upload("UIMG 1|%s|goodbuye"); }

Here is the call graph for this function:

Here is the caller graph for this function:

void edithellopic ( void  )

Definition at line 99 of file graphics.c.

{ do_graphics_upload("hello"); }

Here is the call graph for this function:

Here is the caller graph for this function:

void editpic ( void  )

Definition at line 100 of file graphics.c.

{ do_graphics_upload("_userpic_"); }

Here is the call graph for this function:

Here is the caller graph for this function:

void editroompic ( void  )

Definition at line 145 of file graphics.c.

                       {
       char buf[SIZ];
       snprintf(buf, SIZ, "_roompic_|%s",
               bstr("which_room"));
       do_graphics_upload(buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void InitModule_GRAPHICS ( void  )

Definition at line 161 of file graphics.c.

{
       WebcitAddUrlHandler(HKEY("display_editpic"), "", 0, display_editpic, 0);
       WebcitAddUrlHandler(HKEY("editpic"), "", 0, editpic, 0);
       WebcitAddUrlHandler(HKEY("display_editroompic"), "", 0, display_editroompic, 0);
       WebcitAddUrlHandler(HKEY("editroompic"), "", 0, editroompic, 0);
       WebcitAddUrlHandler(HKEY("display_edithello"), "", 0, display_edithello, 0);
       WebcitAddUrlHandler(HKEY("edithellopic"), "", 0, edithellopic, 0);
       WebcitAddUrlHandler(HKEY("display_editgoodbuye"), "", 0, display_editgoodbyepic, 0);
       WebcitAddUrlHandler(HKEY("editgoodbuyepic"), "", 0, editgoodbuyepic, 0);
       WebcitAddUrlHandler(HKEY("display_editfloorpic"), "", 0, display_editfloorpic, 0);
       WebcitAddUrlHandler(HKEY("editfloorpic"), "", 0, editfloorpic, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void output_static ( const char *  What)

Definition at line 84 of file static.c.

{
       int fd;
       struct stat statbuf;
       off_t bytes;
       const char *content_type;
       int len;
       const char *Err;

       len = strlen (what);
       content_type = GuessMimeByFilename(what, len);
       fd = open(what, O_RDONLY);
       if (fd <= 0) {
              syslog(9, "output_static('%s') [%s]  -- NOT FOUND --\n", what, ChrPtr(WC->Hdr->this_page));
              if (strstr(content_type, "image/") != NULL)
              {
                     output_error_pic("the file you requsted is gone.", strerror(errno));
              }
              else
              {
                     hprintf("HTTP/1.1 404 %s\r\n", strerror(errno));
                     hprintf("Content-Type: text/plain\r\n");
                     begin_burst();
                     wc_printf("Cannot open %s: %s\r\n", what, strerror(errno));
                     end_burst();
              }
       } else {
              if (fstat(fd, &statbuf) == -1) {
                     syslog(9, "output_static('%s')  -- FSTAT FAILED --\n", what);
                     if (strstr(content_type, "image/") != NULL)
                     {
                            output_error_pic("Stat failed!", strerror(errno));
                     }
                     else
                     {
                            hprintf("HTTP/1.1 404 %s\r\n", strerror(errno));
                            hprintf("Content-Type: text/plain\r\n");
                            begin_burst();
                            wc_printf("Cannot fstat %s: %s\n", what, strerror(errno));
                            end_burst();
                     }
                     if (fd > 0) close(fd);
                     return;
              }

              bytes = statbuf.st_size;

              if (StrBufReadBLOB(WC->WBuf, &fd, 1, bytes, &Err) < 0)
              {
                     if (fd > 0) close(fd);
                     syslog(9, "output_static('%s')  -- FREAD FAILED (%s) --\n", what, strerror(errno));
                            hprintf("HTTP/1.1 500 internal server error \r\n");
                            hprintf("Content-Type: text/plain\r\n");
                            end_burst();
                            return;
              }


              close(fd);
              http_transmit_thing(content_type, 2);
       }
       if (yesbstr("force_close_session")) {
              end_webcit_session();
       }
}

Here is the call graph for this function: