Ejemplo n.º 1
0
int main()
{
	int A[] = {2,3,56,67,89,34,56,67};
	int number;
	printf("Enter the number to be searched:");
	scanf("%d", &number);
	findpair(A, sizeof(A)/sizeof(A[0]), number);
	return 0;
}
Ejemplo n.º 2
0
static int bcl_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
	int i;
	char cache[256] = {0};
	ut64 dst = 0LL;
	if (op == NULL)
		return 1;
	int base = *buf & 3;
	memset (op, 0, sizeof (RAnalOp));
	r_strbuf_init (&op->esil);
	op->size = 1;
	if (*buf == 0) {
		op->type = R_ANAL_OP_TYPE_NOP;
		return 0;
	}
	switch (base) {
	case 0:
		op->type = R_ANAL_OP_TYPE_CJMP;
		op->jump = addr + findpair (addr, buf, len, 3);
		op->fail = addr + 1;
		r_strbuf_setf (&op->esil, "A,++=");
		break;
	case 1:
		op->type = R_ANAL_OP_TYPE_CJMP;
		op->jump = addr + findpair(addr, buf, len, 2);
		op->fail = addr + 1;
		r_strbuf_setf (&op->esil, "C,++=");
		break;
	case 2:
		op->type = R_ANAL_OP_TYPE_CMP;
		r_strbuf_setf (&op->esil, "G,++=");
		break;
	case 3:
		op->type = R_ANAL_OP_TYPE_MOV;
		r_strbuf_setf (&op->esil, "T,++=");
		break;
	}
	return op->size;
}
Ejemplo n.º 3
0
void main() {
	int a[] =  {3, 5, 6, 1, 7, 2};
	int len = sizeof(a)/sizeof(a[0]);
	findpair(a, len, 13);
}
Ejemplo n.º 4
0
void io_loadR (glob_t *glb, tf *files, int nfiles){
	int argc = glb->gl_pathc;
	char **argv = glb->gl_pathv;
	int i;
	
	// Loop thru all and load
	for (i = 0; i < argc; i++) {
		SACHEAD *head = NULL;
		float * data = NULL;
		
		// Load SAC
		data = io_readSac(argv[i], &head);
		
		// Check that is loaded
		if (head == NULL || data == NULL) {
			fprintf(stderr,"Error loading file: %s", argv[i]);
			continue;
		}

		// Search for the correct Z component file
		int j = findpair(files, nfiles, head);
		if (j == -1) {
			head = io_freeData(head);
			data = io_freeData(data);
			head = NULL;
			data = NULL; 
			fprintf(stderr,"File %s not paired.", argv[i]);
			continue;
		}
		
		// Check that we can assign a new data to component r
		if (files[j].r != NULL) {
			head = io_freeData(head);
			data = io_freeData(data);
			head = NULL;
			data = NULL; 
			fprintf(stderr,"Trace already assigned.");
			continue;
		}
		
		// Prepare space for new otf
		files[j].r = malloc(sizeof(otf));
		if (files[j].r == NULL){
			fprintf(stderr,"Failed to allocate more memory");
			continue;
		}
		
		// We mark this file as visited on load
		head->unused27 = 1;
		
		// Attach Data
		files[j].r->data = data;
		
		// Attach Head
		files[j].r->head= head;
		
		// Clear filter data space
		files[j].r->dataf = NULL;
		
		// Save a copy of the filename
		files[j].r->filename = malloc(sizeof(char) * (strlen(argv[i]) + 1));
		strcpy(files[j].r->filename, argv[i]);
	}
}