示例#1
0
bool Request::parse()
{
  request_type = STATIC; // temporary TODO

  request_body = find_string(raw_request->cbegin(), raw_request->cend(), std::string("\r\n\r\n"));
  if (request_body == raw_request->cend()) {
    return false;
  }

  buffer::const_iterator request_line_end = find_string(raw_request->cbegin(), request_body, std::string("\r\n")); // TODO error check 
  std::string request_line_str(raw_request->cbegin(), request_line_end);
  
  std::istringstream request_line_ss(request_line_str);
  std::copy(std::istream_iterator<std::string>(request_line_ss),
      std::istream_iterator<std::string>(),
      std::back_inserter<std::vector<std::string> >(request_line));

  parse_headers(request_line_end + 2, request_body + 2);
  
  return true;
}
示例#2
0
void read_int( const char* szFileName, const char* szVarName, int* pVariable)
{
    char* szValue = NULL;	/* string containing the read variable value */

    if( szVarName  == 0 )  ERROR("null pointer given as varable name" );
    if( szFileName == 0 )  ERROR("null pointer given as filename" );
    if( pVariable  == 0 )  ERROR("null pointer given as variable" );

    if( szVarName[0] == '*' )
	szValue = find_string( szFileName, szVarName +1 );
    else
	szValue = find_string( szFileName, szVarName );
    
    if( sscanf( szValue, "%d", pVariable) == 0)
	READ_ERROR("wrong format", szVarName, szFileName, 0);

    printf( "File: %s\t\t%s%s= %d\n", szFileName, 
	                              szVarName,
	                              &("               "[min_int( strlen(szVarName), 15)]), 
	                              *pVariable );
}
示例#3
0
int detect_firmware_build(uint8_t *fw, int len)
{
	const char ident[] = "FDSemu Firmware by James Holodnak";
	int i, ret = -1;

	if ((i = find_string(fw, len, (uint8_t*)ident, strlen(ident))) != -1) {
		i += strlen(ident);
		ret = *(fw + i);
		ret |= *(fw + i + 1) << 8;
	}
	return(ret);
}
示例#4
0
void read_double( const char* szFileName, const char* szVarName, double* pVariable)
{
    char* szValue = NULL;	/* String mit dem eingelesenen Variablenwert */

    if( szVarName  == 0 )  ERROR("null pointer given as varable name" );
    if( szFileName == 0 )  ERROR("null pointer given as filename" );
    if( pVariable  == 0 )  ERROR("null pointer given as variable" );

    if( szVarName[0] == '*' )
	szValue = find_string( szFileName, szVarName +1 );
    else
	szValue = find_string( szFileName, szVarName );
    
    if( sscanf( szValue, "%lf", pVariable) == 0)
	READ_ERROR("wrong format", szVarName, szFileName, 0);

    printf( "File: %s\t\t%s%s= %f\n", szFileName, 
	                              szVarName,
	                              &("               "[min_int( strlen(szVarName), 15)]), 
	                              *pVariable );
}
示例#5
0
文件: cdda.cpp 项目: luciang/haiku
static void
cut_string(char *string, const char *cut)
{
	if (string == NULL || cut == NULL)
		return;

	char *found = find_string(string, cut);
	if (found != NULL) {
		uint32 foundLength = strlen(found);
		uint32 cutLength = strlen(cut);
		memmove(found, found + cutLength, foundLength + 1 - cutLength);
	}
}
示例#6
0
文件: main.c 项目: taysom/tau
int fp (int argc, char *argv[])
{
	int	i;
	int	rc;

	for (i = 1; i < argc; ++i) {
		rc = find_string(argv[i]);
		if (rc != 0) {
			printf("Didn't find string %s\n", argv[i]);
			return rc;
		}
	}
	return 0;
}
示例#7
0
int replace_string(char source[], char find[], char replace[]) {
    int found;
    int f_length;

    for (f_length = 0; find[f_length] != '\0'; ++f_length) {
    }

    found = find_string(source, find);
    if (found != -1) {
        remove_string(source, found, f_length);
        insert_string(source, replace, found);
    }
    return found;
}
示例#8
0
文件: cronlist.c 项目: l0b0/cronlist
int get_from_tables (char *buf, char **tables[], char **end)
{
  int i, idx;
  for (i = 0; tables[i]; i++) {
    idx = find_string(buf, tables[i]);
    if (idx >= 0) {
      *end = buf + strlen(tables[i][idx]);
      return idx;
    }
  }
  /* not found */
  *end = buf;
  return -1;
}
示例#9
0
int detect_bootloader_version(uint8_t *fw, int len)
{
	const char ident[] = "*BOOT2*";
	int identlen = strlen(ident);
	uint8_t *ptr = fw;
	int i;
	int ret = -1;

	if ((i = find_string(fw, len, (uint8_t*)ident, strlen(ident))) != -1) {
		i += strlen(ident);
		ret = *(fw + i);
	}
	return(ret);
}
示例#10
0
bool GrGLExtensions::remove(const char ext[]) {
    SkASSERT(fInitialized);
    int idx = find_string(*fStrings, ext);
    if (idx < 0) {
        return false;
    }

    // This is not terribly effecient but we really only expect this function to be called at
    // most a handful of times when our test programs start.
    fStrings->removeShuffle(idx);
    SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp;
    SkTInsertionSort(&(fStrings->operator[](idx)), &fStrings->back(), cmp);
    return true;
}
示例#11
0
int main(void)
{
    char str[CLIMIT], strc[CLIMIT], src[CLIMIT], c, pch;
    
    printf("Enter a string, a substring, and a character:\n");
    
    if(scanf("%s", str) !=1){
        printf("Invalid input.\n");
        return EXIT_FAILURE;
    }
    
    pch = getc(stdin);
    if(pch != ' '){
        printf("Invalid input.\n");
        return EXIT_FAILURE;
    }
    
    if(scanf("%s", src) !=1){
        printf("Invalid input.\n");
        return EXIT_FAILURE;
    }
    
    pch = getc(stdin);
    if(pch != ' '){
        printf("Invalid input.\n");
        return EXIT_FAILURE;
    }
    
    c = getc(stdin);
    if((c == '\n') ||(c == '\0')){
        printf("Invalid input.\n");
        return EXIT_FAILURE;
    }
    
    pch = getc(stdin);
    if(pch != '\n'){
        printf("Invalid input.\n");
        return EXIT_FAILURE;
    }
    
    strncpy(strc, str, CLIMIT);
    
    if(find_string(str, src) != EXIT_SUCCESS)
        return EXIT_FAILURE;
    if(find_char(strc, c) != EXIT_SUCCESS)
        return EXIT_FAILURE;
    
	return EXIT_SUCCESS;
}
示例#12
0
bool GrGLExtensions::remove(const char ext[]) {
    SkASSERT(fInitialized);
    int idx = find_string(*fStrings, ext);
    if (idx >= 0) {
        // This is not terribly effecient but we really only expect this function to be called at
        // most a handful of times when our test programs start.
        SkAutoTDelete< SkTArray<SkString> > oldStrings(fStrings.detach());
        fStrings.reset(SkNEW(SkTArray<SkString>(oldStrings->count() - 1)));
        fStrings->push_back_n(idx, &oldStrings->front());
        fStrings->push_back_n(oldStrings->count() - idx - 1, &(*oldStrings)[idx] + 1);
        return true;
    } else {
        return false;
    }
}
示例#13
0
void Request::parse_headers(buffer::const_iterator begin, buffer::const_iterator end)
{
  buffer::const_iterator i = begin;
  buffer::const_iterator j;

  std::string test = std::string(begin, end);
  while (end != (j = find_string(i, end, std::string("\r\n")))) {
    auto separator = std::find(i, j, ':');
    std::pair<std::string, std::string> header;
    header.first = std::string(i, separator);
    header.second = std::string(separator + 2, j);
    headers.insert(header);
    i = j + 2;
  }
}
示例#14
0
// Convert string to shared string in pool
// The string.m_string may be updated if find in pool
bool Program::convert_to_shared(StringImpl** string)
{
    if (!((*string)->attrib & ReferenceImpl::SHARED))
    {
        // Not shared? Lookup in pool
        auto* string_impl_in_pool = find_string(*string);
        if (!string_impl_in_pool)
            return false;

        // Modify previous string
        *string = string_impl_in_pool;
    }

    return true;
}
示例#15
0
int main() {
	int m,n,i,j,sum;
	char input[1000];
	while (scanf("%d%d",&m,&n)!=EOF) {
		for (i=0;i<m;i++) scanf("%s%d",hay[i].s,&hay[i].p);
		qsort(hay,m,sizeof(Point),cmp);
		for (i=0;i<n;i++) {
			sum=0;
			while (scanf("%s",&input),strcmp(input,".")) {
				if ((j=find_string(input,0,m-1))>=0) 
					sum+=hay[j].p;
			}
			printf("%d\n",sum);
		}
	}
}
示例#16
0
文件: main.c 项目: taysom/tau
int fill (int n)
{
	int	i;
	int	rc;
	char	*name;

	for (i = 0; i < n; i++) {
		do {
			name = gen_name();
		} while (find_string(name) != qERR_NOT_FOUND);
		rc = insert_string(name);
		if (rc != 0) {
			return rc;
		}
	}
	return 0;
}
示例#17
0
文件: main.c 项目: gnuvse/sls
int main() {
	char str[] = "chatterbox";
	char substr[SIZE];

	printf("position = %i\n", find_string(str, "ter"));

	remove_string(str, 2, 4);

	printf("%s\n", str);

	sub_string(str, 2, 29, substr);

	printf("%s\n", substr);


	return 0;
}
示例#18
0
/* frees s upon error */
char *_pSLcreate_via_alloced_slstring (char *s, unsigned int len)
{
   unsigned long hash;
   SLstring_Type *sls;

   if (s == NULL)
     return NULL;

   if (len < 2)
     {
	char *s1 = create_short_string (s, len);
	_pSLunallocate_slstring (s, len);
	return s1;
     }

   /* s is not going to be in the cache because when it was malloced, its
    * value was unknown.  This simplifies the coding.
    */
   hash = _pSLstring_hash ((unsigned char *)s, (unsigned char *)s + len);
   sls = find_string (s, len, hash);
   if (sls != NULL)
     {
	sls->ref_count++;
	_pSLunallocate_slstring (s, len);
	s = sls->bytes;

#if SLANG_OPTIMIZE_FOR_SPEED
	cache_string (sls);
#endif
	return s;
     }

   sls = (SLstring_Type *) (s - offsetof(SLstring_Type,bytes[0]));
   sls->ref_count = 1;
   sls->hash = hash;

#if SLANG_OPTIMIZE_FOR_SPEED
   cache_string (sls);
#endif

   hash = MAP_HASH_TO_INDEX(hash);
   sls->next = String_Hash_Table [(unsigned int)hash];
   String_Hash_Table [(unsigned int)hash] = sls;

   return s;
}
示例#19
0
/**
 * @brief
 *      queue_in_partition	-  Tells whether the given node belongs to this scheduler
 *
 * @param[in]	qinfo		-  queue information
 * @param[in]	partitions	-  array of partitions associated to scheduler
 *
 * @return	a node_info filled with information from node
 *
 * @return	int
 * @retval	1	: if success
 * @retval	0	: if failure
 */
int
queue_in_partition(queue_info *qinfo, char **partitions)
{
	if (dflt_sched) {
		if (qinfo->partition == NULL)
			return 1;
		else
			return 0;
	}
	if (qinfo->partition == NULL)
		return 0;

	if (find_string(partitions, qinfo->partition))
		return 1;
	else
		return 0;
}
示例#20
0
/**
    Add type. Returns the index of the new type on success,
    FREESASA_FAIL if realloc/strdup fails, FREESASA_WARN if type
    already known (ignore duplicates).
 */
static int
add_type(struct classifier_types *types,
         const char *type_name,
         const char *class_name, 
         double r)
{
    int the_class, n = types->n_types + 1;
    char **tn = types->name;
    double *tr = types->type_radius;
    int *tc = types->type_class;
    
    if (find_string(types->name, type_name, types->n_types) >= 0)
        return freesasa_warn("Ignoring duplicate entry for '%s'.", type_name);
    
    the_class = add_class(types,class_name);
    if (the_class == FREESASA_FAIL) {
        return mem_fail();
    }
    
    if ((types->name = realloc(tn, sizeof(char*)*n)) == NULL) {
        types->name = tn;
        return mem_fail();
    }
    
    if ((types->type_radius = realloc(tr, sizeof(double)*n)) == NULL) {
        types->type_radius = tr;
        return mem_fail();
    }
    
    if ((types->type_class = realloc(tc, sizeof(int) * n)) == NULL) {
        types->type_class = tc;
        return mem_fail();
    }
    
    if ((types->name[n-1] = strdup(type_name)) == NULL) {
        return mem_fail();
    }
        
    types->n_types++;
    types->type_radius[types->n_types-1] = r;
    types->type_class[types->n_types-1] = the_class;
    return types->n_types-1;
}
split_block_result split_block(const string in_string,const string split_string_) {
    split_block_result result;

    if (!in_string.empty()) {
        split_result block;
        block.second=in_string;

        while (-1!=find_string(block.second,split_string_)) {
            block=split_string(block.second,split_string_);
            left_move_string(block.second,1);

            if (!block.first.empty())
                result.push_back(block.first);
        }
        result.push_back(block.second);
    }

    return result;
}
示例#22
0
int del_substr(char *str,char *substr){
	char * endstr; // ½áβ×Ö·û´®
	int len;
	char * string = find_string(str,substr);
	if(string == NULL)
		return 0;
	len = string - str;
	endstr = str + len + strlen(substr);
	// Óнáβ×Ö·û´®
	if(*endstr != '\0'){
		str = str +len;
		while( *str++ = *endstr++)
			;
		*str = '\0';
	} else {
	    // ÕýºÃÎÞ½áβ
		*string = '\0';
	}
	return 0;
}
示例#23
0
文件: main.c 项目: taysom/tau
int mixp (int argc, char *argv[])
{
	int	n;
	int	i;
	int	rc;
	int	sum;
	char	*name;
	int	x;

	if (argc > 1) {
		n = atoi(argv[1]);
	} else {
		n = 10;
	}
	sum = num_recs();

	for (i = 0; i < n; i++) {
		if (!sum || random_percent(51)) {
			do {
				name = gen_name();
			} while (find_string(name) != qERR_NOT_FOUND);
			rc = insert_string(name);
			if (rc != 0) {
				return rc;
			}
			++sum;
			x = num_recs();
			aver(sum == x);
		} else {
			x = urand(sum);
			rc = del_ith(x);//urand(sum));
			if (rc) {
				return rc;
			}
			--sum;
			x = num_recs();
			aver(sum == x);
		}
	}
	return 0;
}
示例#24
0
/**
    Add class to type-registry. Returns the index of the new class on
    success, FREESASA_FAILURE if realloc/strdup fails.
 */
static int
add_class(struct classifier_types *types,
          const char *name)
{
    int the_class = find_string(types->class_name, name, types->n_classes),
        n = types->n_classes + 1;
    char **cn = types->class_name;

    if (the_class == FREESASA_FAIL) {
        if ((types->class_name = realloc(cn, sizeof(char*) * n)) == NULL){
            types->class_name = cn;
            return mem_fail();
        }
        if ((types->class_name[n - 1] = strdup(name)) == NULL) {
            return mem_fail();
        }
        types->n_classes++;
        the_class = types->n_classes - 1;
    }

    return the_class;
}
示例#25
0
unsigned int find_offset(unsigned int dataaddr, unsigned int base, unsigned int size, unsigned char** what) {
	unsigned char* data = (unsigned char *)dataaddr;
	int i = 0;
	unsigned char* top = what[2];
	unsigned char* name = what[0];
	unsigned char* signature = what[1];
	unsigned int dbase = dataaddr;

	// First find the string
	unsigned int address = find_string(dataaddr, base, size, signature);
	if(address == 0) return NULL;

	// Next find where that string is referenced
	unsigned int reference = find_reference(dataaddr, base, size, address);
	if(reference == 0) return NULL;
	reference -= base;

	// Finally find the top of that function
	unsigned int function = find_top(dataaddr, base, size, reference);

	return function;
}
示例#26
0
文件: main.c 项目: taysom/tau
int genp (int argc, char *argv[])
{
	int	n;
	int	i;
	int	rc;
	char	*name;

	if (argc > 1) {
		n = atoi(argv[1]);
	} else {
		n = 10;
	}
	for (i = 0; i < n; i++) {
		do {
			name = gen_name();
		} while (find_string(name) == 0);
		rc = insert_string(name);
		if (rc != 0) {
			return rc;
		}
	}
	return 0;
}
示例#27
0
/**
    Add atom to residue. Returns index of the new atom on
    success. FREESASA_FAIL if memory allocation fails. FREESASA_WARN
    if the atom has already been added.
 */
static int
add_atom(struct classifier_residue *res,
         const char *name,
         double radius,
         int the_class)
{
    int n;
    char **an = res->atom_name;
    double *ar = res->atom_radius;
    int *ac = res->atom_class;

    if (find_string(res->atom_name, name, res->n_atoms) >= 0)
        return freesasa_warn("in %s(): Ignoring duplicate entry for atom '%s %s'", 
                             __func__, res->name, name);
    n = res->n_atoms+1;

    if ((res->atom_name = realloc(res->atom_name,sizeof(char*)*n)) == NULL) {
        res->atom_name = an;
        return mem_fail();
    }
    if ((res->atom_radius = realloc(res->atom_radius,sizeof(double)*n)) == NULL) {
        res->atom_radius = ar;
        return mem_fail();
    }
    if ((res->atom_class = realloc(res->atom_class,sizeof(int)*n)) == NULL) {
        res->atom_class = ac;
        return mem_fail();
    }
    if ((res->atom_name[n-1] = strdup(name)) == NULL) 
        return mem_fail();

    ++res->n_atoms;
    res->atom_radius[n-1] = radius;
    res->atom_class[n-1] = the_class;

    return n-1;
}
示例#28
0
文件: Test.c 项目: JammyStuff/vermont
void test1_5(){
	struct KTree *ktree;
	ktree = new_KTree();

	struct KTreeNode * ptr_addedKeyword;
	ptr_addedKeyword = add_keyword(ktree, "bist", 4);
	ptr_addedKeyword = add_keyword(ktree, "ist", 3);
	ptr_addedKeyword = add_keyword(ktree, "ist", 3);

	ptr_addedKeyword = add_keyword(ktree, "abcdef", 6);

	printf("find_string: %i\n", find_string(ktree, "012"));

	int * matches;
	char *  flow = "istn\n \0\12\n30130123\n012313230103";
	matches = match(ktree, flow, strlen(flow));

	int i;
	for (i = 0; i < ktree->numofkeywords_actual; ++i)
		printf("%i : ", matches[i]);
	printf("\n");

	destruct_KTree(ktree);
}
示例#29
0
/* Reads a _triangular_ mesh from a PLY ASCII file. Note that no
 * binary formats are supported, although PLY format allows
 * them. Maybe in a further version ...
 * Only the vertices and faces are read. All other possible properties
 * (e.g. color ...) are skipped silently.
 * However, this code should be sufficient to read most common PLY files.
 * It returns the number of meshes read (i.e. 1) if successful, and a
 * negative code if it failed. */
int read_ply_tmesh(struct model **tmesh_ref, struct file_data *data) 
{
  char stmp[MAX_WORD_LEN+1];
  vertex_t bbmin, bbmax;
  struct model* tmesh;
  int rcode=1;
  int is_bin=0;
  int file_endianness=0, platform_endianness=0, swap_bytes=0;
  struct ply_prop *vertex_prop=NULL, *face_prop=NULL;
  int n_vert_prop=0, n_face_prop=0;
  int c;
  union sw_uint32 test_byte_order = {{0x01, 0x02, 0x03, 0x04}};
  
  tmesh = (struct model*)calloc(1, sizeof(struct model));

  /* read the header */
  /* check if the format is ASCII or binary */
  if (skip_ws_str_scanf(data, stmp) == 1 && strcmp(stmp, "format") == 0) {
    if (skip_ws_str_scanf(data, stmp) == 1) { 
      /* check whether we have ASCII or binary stuff */
      if (strcmp(stmp, "binary_little_endian") == 0) {
        is_bin = 1;
      } else if (strcmp(stmp, "binary_big_endian") == 0) {
        is_bin = 1;
        file_endianness = 1;
      } else if (strcmp(stmp, "ascii") != 0) {
        rcode = MESH_CORRUPTED;
      } else {
        if (skip_ws_str_scanf(data, stmp) != 1 || strcmp(stmp, "1.0") != 0) 
          rcode = MESH_CORRUPTED;
      }
    } else {
      rcode = MESH_CORRUPTED;
    }
  } else
    rcode = MESH_CORRUPTED;

  if (rcode >= 0) {
    do {
      if ((c = find_string(data, "element")) != EOF) {
        if (skip_ws_str_scanf(data, stmp) == 1) {
          if (strcmp(stmp, "vertex") == 0) {
            if ((c = int_scanf(data, &(tmesh->num_vert))) != 1)
              rcode = MESH_CORRUPTED;
            else {
              n_vert_prop = read_properties(data, &vertex_prop);
              if (n_vert_prop <= 0)
                rcode = MESH_CORRUPTED;
              
#ifdef DEBUG
              DEBUG_PRINT("num_vert = %d\n", tmesh->num_vert);
#endif
            }
          } else if (strcmp(stmp, "face") == 0) {
            if ((c = int_scanf(data, &(tmesh->num_faces))) != 1) 
              rcode = MESH_CORRUPTED;
            else {
              n_face_prop = read_properties(data, &face_prop);
              if (n_face_prop <= 0)
                rcode = MESH_CORRUPTED;

#ifdef DEBUG
              DEBUG_PRINT("num_faces = %d\n", tmesh->num_faces);
#endif
            }
          } else if (strcmp(stmp, "edge") == 0) {
            fprintf(stderr, "[Warning] 'edge' field not supported !\n");
          } else if (strcmp(stmp, "material") == 0)
            fprintf(stderr, "[Warning] 'material' field not supported !\n");
        } else {
          fprintf(stderr, "[Warning] Unrecognized 'element' field found."
                  " Skipping...\n");
        }
      } else
        rcode = MESH_CORRUPTED;
    } while (rcode >= 0 && (tmesh->num_faces == 0 || tmesh->num_vert == 0));
    
  /* Ignore everything else from the header */
    if ((c = find_string(data, "end_header")) == EOF)
      rcode = MESH_CORRUPTED;
    /* end_header read */
    else {

      tmesh->vertices = (vertex_t*)malloc(tmesh->num_vert*sizeof(vertex_t));
      tmesh->faces = (face_t*)malloc(tmesh->num_faces*sizeof(face_t));
      
      if (tmesh->vertices == NULL || tmesh->faces == NULL)
        rcode = MESH_NO_MEM;
      else {
        if (is_bin) { 
          /* check endianness of the platform, just in case ;-) */
          if (test_byte_order.bo == TEST_BIG_ENDIAN)
            platform_endianness = 1;
          else if (test_byte_order.bo != TEST_LITTLE_ENDIAN) {
            fprintf(stderr, "Unable to probe for byte ordering\n");
            platform_endianness = -1;
          }
          swap_bytes = (file_endianness == platform_endianness)?0:1;
          skip_ws_comm(data); /* find the first relevant byte */
        }
        
        /* read the vertices */
        rcode = read_ply_vertices(tmesh->vertices, data, is_bin,
                                      tmesh->num_vert,
                                      &bbmin, &bbmax, 
                                      swap_bytes,
                                      vertex_prop, n_vert_prop);
        
        /* read the faces */
        rcode = read_ply_faces(tmesh->faces, data, is_bin,
                                   tmesh->num_faces,
                                   tmesh->num_vert,
                                   swap_bytes,
                                   face_prop, n_face_prop);

      }
    }
  }
  if (rcode < 0) { /* something went wrong */
    if (tmesh->vertices != NULL)
      free(tmesh->vertices);
    if (tmesh->faces != NULL)
      free(tmesh->faces);
    free(tmesh);
  } else {
    tmesh->bBox[0] = bbmin;
    tmesh->bBox[1] = bbmax;
    *tmesh_ref = tmesh;
    rcode = 1;
  }
  if (vertex_prop != NULL)
    free(vertex_prop);
  if (face_prop != NULL)
    free(face_prop);
  
  return rcode;
}
crack_index network_crack_http(const string target_ip,const unsigned int target_port,dictionary crack_dictionary,const string crack_express,const string crack_term) {
    string resolve_string(crack_express);
    split_result split;
    crack_index result;

    unsigned int username_point=find_string(resolve_string,"%username%");
    if (-1==username_point) {
        dictionary crack_dictionary_;
        resolve_dictionary_add_username(crack_dictionary_,"");
        resolve_dictionary_add_password(crack_dictionary_,
            resolve_dictionary_get_password_list(crack_dictionary,
                resolve_dictionary_get_user_list(crack_dictionary)[0]));
        crack_dictionary=crack_dictionary_;
    }
    unsigned int password_point=find_string(resolve_string,"%password%");
    if (-1==password_point) {
        dictionary crack_dictionary_;
        username_list name_list;
        name_list=resolve_dictionary_get_user_list(crack_dictionary);
        crack_dictionary=crack_dictionary_;
        for (dictionary::const_iterator username_iterator=crack_dictionary.begin();
                                        username_iterator!=crack_dictionary.end();
                                        ++username_iterator)
            resolve_dictionary_add_username(crack_dictionary,username_iterator->first);
        resolve_dictionary_add_password(crack_dictionary,"");
    }
    unsigned int length_point=find_string(resolve_string,"%length%");

    unsigned int handle=scan_tcp_connect(target_ip.c_str(),target_port);
    if (-1!=handle) {
        for (dictionary::const_iterator username_iterator=crack_dictionary.begin();
                                        username_iterator!=crack_dictionary.end();
                                        ++username_iterator) {
            for (password_list::const_iterator password_iterator=username_iterator->second.begin();
                                               password_iterator!=username_iterator->second.end();
                                               ++password_iterator) {
                string packet(resolve_string);
                if (-1!=username_point)
                    replace_string(packet,"%username%",username_iterator->first);
                if (-1!=password_point)
                    replace_string(packet,"%password%",*password_iterator);
                packet=resolve_express(packet);
                if (-1!=length_point) {
                    string http_body;
                    split_result result_body(split_string(packet,"\r\n\r\n"));
                    if (!result_body.second.empty()) {
                        unsigned int length=result_body.second.length()-4;
                        replace_string(packet,"%length%",number_to_string(length));
                    }
                }
CRACK:
                scan_tcp_send(handle,packet.c_str(),packet.length());
                char recv_buffer[NETWORK_CRACK_RECV_BUFFER_LENGTH]={0};
                unsigned int recv_length=scan_tcp_recv(handle,recv_buffer,NETWORK_CRACK_RECV_BUFFER_LENGTH);
                if (-1!=recv_length && recv_length) {
                    if (-1!=find_string(recv_buffer,crack_term)) {
                        result.first=username_iterator->first;
                        result.second=*password_iterator;
                        scan_tcp_disconnect(handle);
                        return result;
                    }
                } else {
                    scan_tcp_disconnect(handle);
                    Sleep(50);
                    handle=scan_tcp_connect(target_ip.c_str(),target_port);
                    Sleep(50);
                    goto CRACK;
                }
            }
        }
        scan_tcp_disconnect(handle);
    }
    return result;
}