/**
 * Internal function that takes in a string of HTTP headers and values as
 * the first parameter, invokes another function to convert the string into
 * device offsets and finally passes control to another function that builds
 * an array of Property -> Value pairs.
 * @param httpHeaders a string of characters where HTTP header name must be
 * separated from the HTTP header value either by a colon or by space. In
 * addition the HTTP header and value pairs must be separated by the new line
 * character 'n'.
 * @param httpHeadersLength length of the httpHeaders string.
 * @param returnArray pointer to the Zend array for storing results.
 */
void matchHttpHeaders(char *httpHeaders, int httpHeadersLength, zval *returnArray) {
    // Match the provided user agent.
    fiftyoneDegreesSetHttpHeaders(FIFTYONE_G(ws), httpHeaders, httpHeadersLength);
    fiftyoneDegreesMatchForHttpHeaders(FIFTYONE_G(ws));
    // Build the PHP array with the result.
    buildArray(returnArray);
}
Exemple #2
0
int main(){
    buildArray=creatRandomArray;
    int* array=buildArray(0,100,10);
    printArray(array,10);
    sort=mergeSort;
    sort(array,10);
    printArray(array,10);
}
Exemple #3
0
void QJsonView::setJson(const QString &text)
{
    clear();
    QJsonDocument document = QJsonDocument::fromJson(text.toUtf8());

    if( document.isArray() ) {
        buildArray("", document.array());
    } else if( document.isObject() ) {
        buildObject("", document.object());
    } else {
        throw -1;
    }
}
Exemple #4
0
/* ChapelArray.chpl:445 */
_array_int32_t_locale_1_SingleLocaleArithmeticArray_locale_int32_t_0_1_0 __init_306845(_ArrayTypeInfo* const t, int32_t _ln, _string _fn) {
  _array_int32_t_locale_1_SingleLocaleArithmeticArray_locale_int32_t_0_1_0 T5;
  _array_int32_t_locale_1_SingleLocaleArithmeticArray_locale_int32_t_0_1_0 T4;
  SingleLocaleArithmeticDomain_1_int32_t_0 T1 = NULL;
  _domain_1_SingleLocaleArithmeticDomain_1_int32_t_0 T2;
  _domain_1_SingleLocaleArithmeticDomain_1_int32_t_0 T3;
  T1 = ((*t).dom);
  T2 = _wrapDomain(T1, _ln, _fn);
  T3 = T2;
  T4 = buildArray(&(T3), _ln, _fn);
  T5 = T4;
  return T5;
}
void main() {
  int masterArray[size];
  int tempArray[size];

  buildArray(masterArray);

  bruteCount(masterArray);
  cout << "Inversion from Brute: " << INVERSIONS_BRUTE << endl;
  cin.get();

  sortArray(0, size - 1, masterArray, tempArray);
  cout << "Inversions from Sort: " << INVERSIONS_SORT << endl;

  cin.get();
}
/**************************************************
 * This function opens the file and reads each    *
 * line into the buildArray function. It then     *
 * calls the rest of the functions to sort the    *
 * array and build the balanced binary tree.      *
 * EXIT 2 for file input error                    *
 * EXIT 1 for memory error                        *
 **************************************************/
void initialize(char *filename)
{
    FILE *fp;
    char buffer[21], **names;
    int count = 0, *count_ptr = &count, size = 2, *size_ptr = &size;
    BNODE* root;

    if ((fp = fopen(filename, "r")) == NULL)
    {
        printf("Error: Filename does not exist\n");
        exit(2);
    }
    
    if ((names = malloc(2 * sizeof(char*))) == NULL)
    {
        printf("Error: Unable to allocate memory\n");
        exit(1);
    }

    while (fgets(buffer, sizeof(buffer), fp) != NULL)
    {
        /* Double the size of the array after it is full */
        if (count == size)
            names = resizeArray(names, size_ptr);

        names = buildArray(names, buffer, count_ptr);
    }

    fclose(fp);

    names = sortArray(names, count_ptr);

    root = buildTree(names, 0, count-1);

    printf("\n preorder: ");
    preorder(root);
    printf("\n\n");

    printf("  inorder: ");
    inorder(root);
    printf("\n\n");

    printf("postorder: ");
    postorder(root);
    printf("\n");
}
int main(int argc, char *argv[]){
	int i, j, size, n = 10;
	int *results;
	
	printf("Lets perform a Binary Search over an ordered array:\n");
	//random number generator
	srand(time(NULL));

	size = pow(2,n);
	buildArray(&results, size);

	printf("We have an array of size %d, which element do you want to look for?\n", size);
	scanf("%d", &i);

	printf("The element in position %d is %d\n",i,results[i]);
	
	j = binarySearch(&results, 0, size-1, results[i]);
	printf("The Binary search returned: array[%d] = %d\n", j, results[j]);
	
}
Exemple #8
0
int main(int argc, char *argv[]) {
printf("1");
	int i;		//counter
	int *msa = NULL;	//this pointer will get the array back from functions
	int msaSum;		//this will hold the sum
	
    FILE *file, *output;
    file = fopen(argv[1], "r");
    output = fopen("MSS_Results.txt", "w");
    int* array1, *array2, *array3, *array4, *array5, *array6, *array7;
    int length[7];
printf("2");
    array1 = buildArray(40, file, &length[0]);
    array2 = buildArray(40, file, &length[1]);
    array3 = buildArray(40, file, &length[2]);
    array4 = buildArray(40, file, &length[3]);
    array5 = buildArray(40, file, &length[4]);
    array6 = buildArray(40, file, &length[5]);
    array7 = buildArray(40, file, &length[6]);
printf("3");
    linearSubArray(array1, length[0], msa, &msaSum);		//pass in array, length, pointer for subarr, and pointer to store the sum of subarr
printf("4");	
	printf("msa\n");
printf("5");								/* SEG FAULT HERE
	for(i=0; i<length[0]; i++){	//guessing problem is here, for loop going out of bounds
		printf("%d \n", msa[i]);	//wanted it to print value to console for checking if it was doing it's job
	}
	printf("msaSum is %d \n", msaSum);*/
printf("6");
    free(array1);
    free(array2);
    free(array3);
    free(array4);
    free(array5);
    free(array6);
    free(array7);

    fclose(file);
    fclose(output);
	
	return 0;
}
Exemple #9
0
void redraw(){
  
  
  int k = buildArray();
  
  int i, j;
  
  G_rgb(0,0,.3);
  
  G_clear();
  
  for(i =0; i < k; i++){
    buildPoly(i);
  }
  
  G_rgb(1,0,0);
  G_point((300/H)*lightPos[0]/lightPos[2] + 300, (300/H)*lightPos[1]/lightPos[2] + 300);
  /*
    
  //printf("%d\n", numPolygons[thisObj]);
  
  for(thisObj=0;thisObj<numObjects; thisObj++){
  
  for(i=0;i<numPolygons[thisObj];i++){
  
  buildPoly(i);
  
  
  }
  
  
  }
  */
  
  //  exit(1) ;
}
/**
 * Internal function that performs match for all of the relevant headers. All
 * relevant HTTP headers must be set in the Work Set prior to calling this
 * function.
 * @param returnArray a pointer to the Zend array to store results in.
 */
void matchHttpHeadersAuto(zval *returnArray) {
    fiftyoneDegreesMatchForHttpHeaders(FIFTYONE_G(ws));
    buildArray(returnArray);
}
/**
 * Internal function that performs match with a single User-Agent HTTP header
 * string and invokes the buildArray function to process the results.
 * @param userAgent is the User-Agent string to be matched.
 * @param userAgentLength is the length of the User-Agent string.
 * @param returnArray a pointer to the Zend array to store results in.
 */
void matchUserAgent(char *userAgent, int userAgentLength, zval *returnArray) {
    // Match the provided user agent.
    fiftyoneDegreesMatch(FIFTYONE_G(ws), userAgent);
    // Build the PHP array with the result.
    buildArray(returnArray);
}