Exemple #1
0
static void clear_output_vars( const var_list_t *args )
{
  const var_t *arg;

  if (!args) return;
  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
  {
    if (is_attr(arg->attrs, ATTR_OUT) && !is_attr(arg->attrs, ATTR_IN)) {
      print_proxy( "if(%s)\n", arg->name );
      indent++;
      print_proxy( "MIDL_memset( %s, 0, sizeof( *%s ));\n", arg->name, arg->name );
      indent--;
    }
  }
}
Exemple #2
0
SearchIterator::UP
FakeBlueprint::createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool) const
{
    auto result = std::make_unique<FakeSearch>(_tag, _field.getName(), _term, _result, tfmda);
    result->is_attr(_is_attr);
    return result;
}
Exemple #3
0
static void clear_output_vars( const var_list_t *args )
{
  const var_t *arg;

  if (!args) return;
  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
  {
      if (is_attr(arg->attrs, ATTR_IN)) continue;
      if (!is_attr(arg->attrs, ATTR_OUT)) continue;
      if (is_ptr(arg->type))
      {
          if (type_get_type(type_pointer_get_ref(arg->type)) == TYPE_BASIC) continue;
          if (type_get_type(type_pointer_get_ref(arg->type)) == TYPE_ENUM) continue;
      }
      print_proxy( "if (%s) MIDL_memset( %s, 0, sizeof( *%s ));\n", arg->name, arg->name, arg->name );
  }
}
Exemple #4
0
static void proxy_free_variables( var_list_t *args, const char *local_var_prefix )
{
  const var_t *arg;

  if (!args) return;
  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
    if (is_attr(arg->attrs, ATTR_OUT))
    {
      free_variable( arg, local_var_prefix );
      fprintf(proxy, "\n");
    }
}
Exemple #5
0
//gets file, directory attributes
static int sh_getattr(const char *path, struct stat *stbuf) {
    int res = 0;
    struct user* user = find_user(root, path+1);
    
    char uname[9];
    int i = user_from_path(path, uname);
    i+=2;
    struct user* user2 = find_user(root, uname);
    
    printf("getattr\n");
    memset(stbuf, 0, sizeof(struct stat));
    
    if (strcmp(path, "/") == 0) {         //get attributes of root
        stbuf->st_mode = S_IFDIR | 0755;
	stbuf->st_nlink = 2;
    }
    else if(user != NULL) {               //get attr of a user
        stbuf->st_mode = S_IFDIR | 0755;
	stbuf->st_nlink = 1;
    }
    else if(user2 != NULL) {              //get attr of file
        int size = is_attr(path+i, user2);
	if(size > -1) {
	    stbuf->st_mode = S_IFREG | 0666;
	    stbuf->st_nlink = 1;
	    stbuf->st_size = size;
	}
	else res = -ENOENT;
    }
    else if(strcmp(path+1, "sh_file") == 0) {
        res = lstat(backing_path, stbuf);
    }
    else {
        res = -ENOENT;
    }
    return res;
}
static char*
build_direct_request(char *meth, struct url *url, char *headers, struct request *rq, int flags)
{
    int	rlen, authorization_done = FALSE;
    char	*answer = NULL, *fav=NULL, *httpv, *host=NULL;
    struct	buff 	*tmpbuff;
    struct	av	*av;
    int host_len=0;
    int	via_inserted = FALSE;

    // if (!TEST(flags, DONT_CHANGE_HTTPVER) ) {
//		httpv = "HTTP/1.1";
//		if ( TEST(rq->flags, RQ_HAS_HOST) )
//			host = rq->url.host;
//	} else {
    httpv = url->httpv;
    if ( !TEST(rq->flags, RQ_HAS_HOST) )
        host = rq->url.host;
//	}
    tmpbuff = alloc_buff(CHUNK_SIZE);
    if ( !tmpbuff ) return(NULL);
    rlen = strlen(meth) + 1/*sp*/ + strlen(url->path) + 1/*sp*/ +
           strlen(httpv) + 2/* \r\n */;
    if(TEST(rq->flags,RQ_USE_PROXY)) {
        rlen=rlen+7+strlen(rq->url.host);
        if(rq->url.port!=80)
            rlen=rlen+7;
    }
    answer = (char *)xmalloc(ROUND(rlen+1,CHUNK_SIZE), "build_direct_request(): 1"); /* here answer is actually *request* buffer */
    if ( !answer )
        goto fail;
    memset(answer,0,rlen+1);
    if(TEST(rq->flags,RQ_USE_PROXY)) {
        if(rq->url.port!=80)
            snprintf(answer,rlen,"%s http://%s:%d%s %s\r\n",meth,rq->url.host,rq->url.port,rq->url.path,httpv);
        else
            snprintf(answer,rlen,"%s http://%s%s %s\r\n",meth,rq->url.host,rq->url.path,httpv);
    } else {
        sprintf(answer, "%s %s %s\r\n", meth, rq->url.path, httpv);
    }
//  printf("host=%s.path=%s.\n",rq->url.host,rq->url.path);
//  printf("answer=%s.\n",answer);
    if ( attach_data(answer, strlen(answer), tmpbuff) )
        goto fail;
    if ( headers ) { /* attach what was requested */
        if ( attach_data(headers, strlen(headers), tmpbuff) )
            goto fail;
    }
    host_len=strlen(rq->url.host)+10;
    host=(char *)malloc(host_len);
    memset(host,0,host_len);
    if(rq->url.port!=80)
        snprintf(host,host_len-1,"%s:%d",rq->url.host,rq->url.port);
    else
        snprintf(host,host_len-1,"%s",rq->url.host);
    if(fav=format_av_pair("Host:",host)) {
        if(attach_data(fav,strlen(fav),tmpbuff))
            goto fail;
        xfree(fav);
        fav=NULL;
    }

    free(host);
    av = rq->av_pairs;
    while ( av ) {
        if ( is_attr(av, "Proxy-Connection:") )
            goto do_not_insert;
        if ( is_attr(av, "Proxy-Authorization:") ) /* hop-by-hop */
            goto do_not_insert;
        if ( is_attr(av, "Connection:") )
            goto do_not_insert;
        if( is_attr(av,"Host:"))
            goto do_not_insert;
        if ( is_attr(av, "Via:") && conf.insert_via  && !via_inserted ) {
            /* attach my Via: */
            if ( (fav = format_av_pair(av->attr, av->val)) != 0 ) {
                char    *buf;
                buf = strchr(fav, '\r');
                if ( buf ) *buf = 0;
                if ( !buf ) {
                    buf = strchr(fav, '\n');
                    if ( buf ) *buf = 0;
                }
                int buf_len=strlen(fav)+2+18+7+10+strlen(VER_ID)+2+1;
                buf =(char *)malloc(buf_len);
                if ( !buf ) goto fail;
                memset(buf,0,buf_len);
                snprintf(buf,buf_len-1,"%s,%d.%d %s:%d (kingate/%s)\r\n",fav,rq->http_major,rq->http_minor,rq->client->get_server_name() ,conf.port[HTTP], VER_ID);
                if ( attach_data(buf, strlen(buf), tmpbuff) ) {
                    xfree(buf);
                    goto fail;
                }
                via_inserted = TRUE;
                xfree(buf);
                xfree(fav);
                fav = NULL;
            }
            goto do_not_insert;
        }
        if ( (fav=format_av_pair(av->attr, av->val)) != 0 ) {
            if ( attach_data(fav, strlen(fav), tmpbuff) )
                goto fail;
            xfree(fav);
            fav = NULL;
        }
do_not_insert:
        av = av->next;
    }
    if ( (fav = format_av_pair("Connection:", "close")) != 0 ) {
        if ( attach_data(fav, strlen(fav), tmpbuff) )
            goto fail;
        xfree(fav);
        fav = NULL;
    }
    if(conf.x_forwarded_for) {
        if( (fav=format_av_pair("X-Forwarded-For:",(char *)rq->server->get_client_name()))!=0) {
            if ( attach_data(fav, strlen(fav), tmpbuff) )
                goto fail;
            xfree(fav);
            fav = NULL;
        }
    }
    if (conf.insert_via && !via_inserted ) {
        char *buf;
        int buf_len=4+1+18+7+10+strlen(VER_ID)+2+1;
        buf =(char *) malloc(buf_len);
        if ( !buf ) goto fail;
        memset(buf,0,buf_len);
        snprintf(buf,buf_len-1,"Via: %d.%d %s:%d (kingate/%s)\r\n",rq->http_major,rq->http_minor, rq->client->get_server_name(),conf.port[HTTP], VER_ID);
        if ( attach_data(buf, strlen(buf), tmpbuff) ) {
            xfree(buf);
            goto fail;
        }
        xfree(buf);
        xfree(fav);
        fav = NULL;
    }

    /* CRLF  */
    if ( attach_data("\r\n", 2, tmpbuff) )
        goto fail;
    if ( attach_data("", 1, tmpbuff) )
        goto fail;
    IF_FREE(answer);
    answer = tmpbuff->data;
    tmpbuff->data = NULL;
    free_chain(tmpbuff);
    //printf("%s",answer);
    return answer;
fail:
    IF_FREE(fav);
    IF_FREE(host);
    if (tmpbuff) free_chain(tmpbuff);
    IF_FREE(answer);
    return NULL;
}
Exemple #7
0
unsigned short get_type_vt(type_t *t)
{
  unsigned short vt;

  chat("get_type_vt: %p type->name %s\n", t, t->name);
  if (t->name) {
    vt = builtin_vt(t);
    if (vt) return vt;
  }

  if (t->kind == TKIND_ALIAS && is_attr(t->attrs, ATTR_PUBLIC))
    return VT_USERDEFINED;

  switch (t->type) {
  case RPC_FC_BYTE:
  case RPC_FC_USMALL:
    return VT_UI1;
  case RPC_FC_CHAR:
  case RPC_FC_SMALL:
    return VT_I1;
  case RPC_FC_WCHAR:
    return VT_I2; /* mktyplib seems to parse wchar_t as short */
  case RPC_FC_SHORT:
    return VT_I2;
  case RPC_FC_USHORT:
    return VT_UI2;
  case RPC_FC_LONG:
    if (match(t->name, "int")) return VT_INT;
    return VT_I4;
  case RPC_FC_ULONG:
    if (match(t->name, "int")) return VT_UINT;
    return VT_UI4;
  case RPC_FC_HYPER:
    if (t->sign < 0) return VT_UI8;
    if (match(t->name, "MIDL_uhyper")) return VT_UI8;
    return VT_I8;
  case RPC_FC_FLOAT:
    return VT_R4;
  case RPC_FC_DOUBLE:
    return VT_R8;
  case RPC_FC_RP:
  case RPC_FC_UP:
  case RPC_FC_OP:
  case RPC_FC_FP:
  case RPC_FC_CARRAY:
  case RPC_FC_CVARRAY:
    if(t->ref)
    {
      if (match(t->ref->name, "SAFEARRAY"))
        return VT_SAFEARRAY;
      return VT_PTR;
    }

    error("get_type_vt: unknown-deref-type: %d\n", t->ref->type);
    break;
  case RPC_FC_IP:
    if(match(t->name, "IUnknown"))
      return VT_UNKNOWN;
    if(match(t->name, "IDispatch"))
      return VT_DISPATCH;
    return VT_USERDEFINED;

  case RPC_FC_ENUM16:
  case RPC_FC_STRUCT:
  case RPC_FC_PSTRUCT:
  case RPC_FC_CSTRUCT:
  case RPC_FC_CPSTRUCT:
  case RPC_FC_CVSTRUCT:
  case RPC_FC_BOGUS_STRUCT:
  case RPC_FC_COCLASS:
    return VT_USERDEFINED;
  case 0:
    return t->kind == TKIND_PRIMITIVE ? VT_VOID : VT_USERDEFINED;
  default:
    error("get_type_vt: unknown type: 0x%02x\n", t->type);
  }
  return 0;
}
Exemple #8
0
	DomAttr DomNode::to_attr() const
	{
		if (is_attr())
			return DomAttr(impl);
		return DomAttr();
	}
Exemple #9
0
unsigned short get_type_vt(type_t *t)
{
  unsigned short vt;

  chat("get_type_vt: %p type->name %s\n", t, t->name);
  if (t->name) {
    vt = builtin_vt(t);
    if (vt) return vt;
  }

  if (type_is_alias(t) && is_attr(t->attrs, ATTR_PUBLIC))
    return VT_USERDEFINED;

  switch (type_get_type(t)) {
  case TYPE_BASIC:
    switch (type_basic_get_type(t)) {
    case TYPE_BASIC_BYTE:
      return VT_UI1;
    case TYPE_BASIC_CHAR:
    case TYPE_BASIC_INT8:
      if (type_basic_get_sign(t) > 0)
        return VT_UI1;
      else
        return VT_I1;
    case TYPE_BASIC_WCHAR:
      return VT_I2; /* mktyplib seems to parse wchar_t as short */
    case TYPE_BASIC_INT16:
      if (type_basic_get_sign(t) > 0)
        return VT_UI2;
      else
        return VT_I2;
    case TYPE_BASIC_INT:
      if (type_basic_get_sign(t) > 0)
        return VT_UINT;
      else
        return VT_INT;
    case TYPE_BASIC_INT32:
    case TYPE_BASIC_ERROR_STATUS_T:
      if (type_basic_get_sign(t) > 0)
        return VT_UI4;
      else
        return VT_I4;
    case TYPE_BASIC_INT64:
    case TYPE_BASIC_HYPER:
      if (type_basic_get_sign(t) > 0)
        return VT_UI8;
      else
        return VT_I8;
    case TYPE_BASIC_INT3264:
      if (typelib_kind == SYS_WIN64)
      {
        if (type_basic_get_sign(t) > 0)
          return VT_UI8;
        else
          return VT_I8;
      }
      else
      {
        if (type_basic_get_sign(t) > 0)
          return VT_UI4;
        else
          return VT_I4;
      }
    case TYPE_BASIC_FLOAT:
      return VT_R4;
    case TYPE_BASIC_DOUBLE:
      return VT_R8;
    case TYPE_BASIC_HANDLE:
      error("handles can't be used in typelibs\n");
    }
    break;

  case TYPE_POINTER:
    return VT_PTR;

  case TYPE_ARRAY:
    if (type_array_is_decl_as_ptr(t))
    {
      if (match(type_array_get_element(t)->name, "SAFEARRAY"))
        return VT_SAFEARRAY;
    }
    else
      error("get_type_vt: array types not supported\n");
    return VT_PTR;

  case TYPE_INTERFACE:
    if(match(t->name, "IUnknown"))
      return VT_UNKNOWN;
    if(match(t->name, "IDispatch"))
      return VT_DISPATCH;
    return VT_USERDEFINED;

  case TYPE_ENUM:
  case TYPE_STRUCT:
  case TYPE_COCLASS:
  case TYPE_MODULE:
  case TYPE_UNION:
  case TYPE_ENCAPSULATED_UNION:
    return VT_USERDEFINED;

  case TYPE_VOID:
    return VT_VOID;

  case TYPE_ALIAS:
    /* aliases should be filtered out by the type_get_type call above */
    assert(0);
    break;

  case TYPE_FUNCTION:
    error("get_type_vt: functions not supported\n");
    break;

  case TYPE_BITFIELD:
    error("get_type_vt: bitfields not supported\n");
    break;
  }
  return 0;
}