コード例 #1
0
ファイル: diagnose.c プロジェクト: hercules-390/hyperion
static void ARCH_DEP(diagf14_call)(int r1, int r3, REGS *regs)
{
char name[32+1];
char entry[64];
unsigned int  i;
void (*dllcall)(int, int, REGS *);

static char *prefix[] = {
#if defined(_370)
    "s370_diagf14_",
#endif
#if defined(_390)
    "s390_diagf14_",
#endif
#if defined(_900)
    "z900_diagf14_"
#endif
    };

    ARCH_DEP(vfetchc) (name,sizeof(name)-2, regs->GR(r1), USE_REAL_ADDR, regs);

    for(i = 0; i < sizeof(name)-1; i++)
    {
        name[i] = guest_to_host(name[i]);
        if(!isprint(name[i]) || isspace(name[i]))
        {
            name[i] = '\0';
            break;
        }
    }
    /* Ensure string terminator */
    name[i] = '\0';
    strlcpy(entry,prefix[regs->arch_mode],sizeof(entry));
    strlcat(entry,name,sizeof(entry));

    if( (dllcall = HDL_FINDSYM(entry)) )
        dllcall(r1, r3, regs);
    else
        ARCH_DEP(program_interrupt) (regs, PGM_SPECIFICATION_EXCEPTION);

}
コード例 #2
0
ファイル: httpserv.c プロジェクト: rmblair/h390-sandhawk
static void *http_request(void* arg)
{
    WEBBLK *webblk;
    int authok = !http_serv.httpauth;
    char line[HTTP_PATH_LENGTH];
    char *url = NULL;
    char *pointer;
    char *strtok_str = NULL;
    CGITAB *cgient;
    int content_length = 0;
    int sock = (int) (uintptr_t) arg;

    if(!(webblk = malloc(sizeof(WEBBLK))))
        http_exit(webblk);

    memset(webblk,0,sizeof(WEBBLK));
    webblk->sock = sock;

    while (hgets(line, sizeof(line), webblk->sock))
    {
        if (*line == '\r' || *line == '\n')
            break;

        if((pointer = strtok_r(line," \t\r\n",&strtok_str)))
        {
            if(!strcasecmp(pointer,"GET"))
            {
                if((pointer = strtok_r(NULL," \t\r\n",&strtok_str)))
                {
                    webblk->request_type = REQTYPE_GET;
                    url = strdup(pointer);
                }
            }
            else
            if(!strcasecmp(pointer,"POST"))
            {
                if((pointer = strtok_r(NULL," \t\r\n",&strtok_str)))
                {
                    webblk->request_type = REQTYPE_POST;
                    url = strdup(pointer);
                }
            }
            else
            if(!strcasecmp(pointer,"PUT"))
            {
                http_error(webblk,"400 Bad Request", "",
                                  "This server does not accept PUT requests");
            }
            else
            if(!strcasecmp(pointer,"Authorization:"))
            {
                if((pointer = strtok_r(NULL," \t\r\n",&strtok_str)))
                    authok = http_authenticate(webblk,pointer,
                                  strtok_r(NULL," \t\r\n",&strtok_str));
            }
            else
            if(!strcasecmp(pointer,"Cookie:"))
            {
                if((pointer = strtok_r(NULL,"\r\n",&strtok_str)))
                    http_interpret_variable_string(webblk, pointer, VARTYPE_COOKIE);
            }
            else
            if(!strcasecmp(pointer,"Content-Length:"))
            {
                if((pointer = strtok_r(NULL," \t\r\n",&strtok_str)))
                    content_length = atoi(pointer);
            }
        }
    }
    webblk->request = url;

    if(webblk->request_type == REQTYPE_POST
      && content_length != 0)
    {
    char *post_arg;
        if((pointer = post_arg = malloc(content_length + 1)))
        {
        int i;
            for(i = 0; i < content_length; i++)
            {
                *pointer = hgetc(webblk->sock);
                if(*pointer != '\n' && *pointer != '\r')
                    pointer++;
            }
            *pointer = '\0';
            http_interpret_variable_string(webblk, post_arg, VARTYPE_POST);
            free(post_arg);
        }
    }

    if (!authok)
    {
        http_error(webblk, "401 Authorization Required",
                           "WWW-Authenticate: Basic realm=\"HERCULES\"\n",
                           "You must be authenticated to use this service");
    }

    if (!url)
    {
        http_error(webblk,"400 Bad Request", "",
                          "You must specify a GET or POST request");
    }

    /* anything following a ? in the URL is part of the get arguments */
    if ((pointer=strchr(url,'?'))) {
        *pointer++ = 0;
        http_interpret_variable_string(webblk, pointer, VARTYPE_GET);
    }

    while(url[0] == '/' && url[1] == '/')
        url++;

    webblk->baseurl = url;

    if(!strcasecmp("/",url))
        url = HTTP_WELCOME;

    if(strncasecmp("/cgi-bin/",url,9))
        http_download(webblk,url);
    else
        url += 9;

    while(*url == '/')
        url++;

#if 0
    http_dump_cgi_variables(webblk);
#endif

    for(cgient = cgidir; cgient->path; cgient++)
    {
        if(!strcmp(cgient->path, url))
        {
        char tbuf[80];
            hprintf(webblk->sock,"HTTP/1.0 200 OK\nConnection: close\n");
            hprintf(webblk->sock,"Date: %s\n",
              http_timestring(tbuf,sizeof(tbuf),time(NULL)));
            (cgient->cgibin) (webblk);
            http_exit(webblk);
        }
    }

#if defined(OPTION_DYNAMIC_LOAD)
    {
    zz_cgibin dyncgi;

        if( (dyncgi = HDL_FINDSYM(webblk->baseurl)) )
        {
        char tbuf[80];
            hprintf(webblk->sock,"HTTP/1.0 200 OK\nConnection: close\n");
            hprintf(webblk->sock,"Date: %s\n",
              http_timestring(tbuf,sizeof(tbuf),time(NULL)));
            dyncgi(webblk);
            http_exit(webblk);
        }
    }
#endif /*defined(OPTION_DYNAMIC_LOAD)*/

    http_error(webblk, "404 File Not Found","",
                       "The requested file was not found");
    return NULL;
}
コード例 #3
0
ファイル: dyninst.c プロジェクト: Orfheo/hyperion
static void update_dyninst()
{
  int arch;
  char name[64];
  zz_func newinst;
  zz_func oldinst;
  int opcode1;
  int opcode2;

  for(arch = 0; arch < GEN_ARCHCOUNT; arch++)
  {
    for(opcode1 = 0; opcode1 < 0x100 && dyninst_index < MAXDYNINST; opcode1++)
    {
      snprintf(name, sizeof(name), "%s%02X", prefix[arch], opcode1);
      newinst = HDL_FINDSYM(name);
      if(newinst)
      {
        oldinst = replace_opcode(arch, newinst, opcode1, -1);
        if(oldinst)
        {
          dyninst[dyninst_index].opcode1 = opcode1;
          dyninst[dyninst_index].opcode2 = -1;
          dyninst[dyninst_index].arch = arch;
          dyninst[dyninst_index].newinst = newinst;
          dyninst[dyninst_index].oldinst = oldinst;
          dyninst_index++;
        }
      }

      switch(opcode1) {
        case 0x01:
        case 0xa4:
        case 0xa6:
        case 0xb2:
        case 0xb3:
        case 0xb9:
        case 0xe4:
        case 0xe5:
        case 0xe6:
        case 0xa5:
        case 0xa7:
        case 0xc0:
        case 0xc2:
        case 0xc4:
        case 0xc6:
        case 0xc8:
        case 0xcc:
        case 0xe3:
        case 0xeb:
        case 0xec:
        case 0xed:
          for(opcode2 = 0; opcode2 < 0x100 && dyninst_index < MAXDYNINST; opcode2++)
          {
            snprintf(name, sizeof(name), "%s%02X%02X", prefix[arch], opcode1, opcode2);
            newinst = HDL_FINDSYM(name);
            if(newinst)
            {
              oldinst = replace_opcode(arch, newinst, opcode1, opcode2);
              if(oldinst)
              {
                dyninst[dyninst_index].opcode1 = opcode1;
                dyninst[dyninst_index].opcode2 = opcode2;
                dyninst[dyninst_index].arch = arch;
                dyninst[dyninst_index].newinst = newinst;
                dyninst[dyninst_index].oldinst = oldinst;
                dyninst_index++;
              }
            }
          }
       }
    }
  }
}