Пример #1
0
void ControlPoint::onUpdateHandle(WhichHandle wh) {
	// One handle has changed, update only the other one
	if (lock == LOCK_DIR) {
		getOther(wh) = -getHandle(wh) * getOther(wh).length() / getHandle(wh).length();
	} else if (lock == LOCK_SIZE) {
		getOther(wh) = -getHandle(wh);
	}
}
Пример #2
0
/* Get ALL Tasks by /proc */
int getInfo(char *file, pTable *mytasks, int rec) {
	FILE *output;
	char buffer[255];
	char name[16];
	char id[6];
	char key[KEYSIZE];

	pTask *current_task;

	memset(key, '\0', KEYSIZE);
	
	if((output = fopen(file, "r")) == NULL){
		return -1;
	}
	else {
		while(fgets(buffer, 255, output) != NULL){
			if(!strncmp(buffer, "Name:", 5)){
				getOther(buffer, name, sizeof(buffer), sizeof(name));
				current_task = malloc(sizeof(pTask));
				if(current_task == NULL)
					zeppoo_fatal("malloc error");
				memset(current_task, '\0', sizeof(pTask));

				memcpy(current_task->name, name, sizeof(current_task->name) - 1);
				current_task->name[sizeof(current_task->name) - 1] = '\0';

				current_task->rec = rec;
			}
			else if(!strncmp(buffer, "Pid:", 4)){
				getOther(buffer, id, sizeof(buffer), sizeof(id));
				current_task->pid = atoi(id);
			}
			else if(!strncmp(buffer, "Uid:", 4)){
				getUidGid(buffer, id, sizeof(buffer), sizeof(id));
				current_task->uid = atoi(id);
			}
			else if(!strncmp(buffer, "Gid:", 4)){
				getUidGid(buffer, id, sizeof(buffer), sizeof(id));
				current_task->gid = atoi(id);
			}
					
			memset(buffer, '\0', 255);
		}
		current_task->mybin_fmt.md5sum_loadbinary = NULL;
		current_task->mybin_fmt.md5sum_loadshlib = NULL;
		current_task->mybin_fmt.md5sum_coredump = NULL;
		current_task->mybin_fmt.name = NULL;
		
		snprintf(key, KEYSIZE - 1, "%d", current_task->pid);
		current_task->addr = 0;
		hash_insert(mytasks, key, KEYSIZE, current_task);
		memset(key, '\0', KEYSIZE);
	}
	fclose(output);
	return 0;
}
Пример #3
0
 /**@brief Call function with current self and other instances.*/
 inline Value docall(Function f, unsigned argcnt, Value *args)
 {
     return docall(f, getSelf(), getOther(), argcnt, args);
 }