当前位置: 首页>>代码示例>>C++>>正文


C++ safestrcpy函数代码示例

本文整理汇总了C++中safestrcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ safestrcpy函数的具体用法?C++ safestrcpy怎么用?C++ safestrcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了safestrcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdatePositionDisplay

void UpdatePositionDisplay( int train_number, int speed, char* pos_node, int pos_offset, int error, int max_error, char* dest_node, int dest_offset, char* state ) {
	int tid = -1;
	tid = WhoIs( "trainsTAB" );

	//check the return value of WhoIs
	if( tid < 0 ) {
		return;
	}

	//create the message
	struct train_position_output_message msg;

	msg.message_type = TRAIN_POSITION_OUTPUT_MESSAGE;
	msg.train_nums = train_number;
	msg.train_speeds = speed;
	safestrcpy( msg.train_pos_node, pos_node, 6 );
	msg.train_pos_off = pos_offset;
	msg.train_err = error;
	msg.train_max_err = max_error;
	safestrcpy( msg.train_dest_node, dest_node, 6 );
	msg.train_dest_off = dest_offset;
	safestrcpy( msg.train_state, state, 6 );

	//send the message via courier
	CourierSend( tid, (char *)&msg, sizeof (msg) );
}
开发者ID:smacleod,项目名称:realtime-microkern-cs452,代码行数:26,代码来源:train.c

示例2: userinit

//PAGEBREAK: 32
// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];
  
  p = allocproc();
  initproc = p;
  initproc->uid = 0;
  if((p->pgdir = setupkvm()) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");
  safestrcpy(p->wdpath, "/\n", 2);	//start in the root directory

  p->state = RUNNABLE;
}
开发者ID:CKost,项目名称:Authorization,代码行数:30,代码来源:proc.c

示例3: dprintf

/**
 * sysfs_open_class_device_path: Opens and populates class device
 * @path: path to class device.
 * returns struct sysfs_class_device with success and NULL with error.
 */
struct sysfs_class_device *sysfs_open_class_device_path(const char *path)
{
    struct sysfs_class_device *cdev;
    char temp_path[SYSFS_PATH_MAX];

    if (!path) {
        errno = EINVAL;
        return NULL;
    }

    /*
     * Post linux-2.6.14 driver model supports nested classes with
     * links to the nested hierarchy at /sys/class/xxx/. Check for
     * a link to the actual class device if a directory isn't found
     */
    if (sysfs_path_is_dir(path)) {
        dprintf("%s: Directory not found, checking for a link\n", path);
        if (!sysfs_path_is_link(path)) {
            if (sysfs_get_link(path, temp_path, SYSFS_PATH_MAX)) {
                dprintf("Error retrieving link at %s\n", path);
                return NULL;
            }
        } else {
            dprintf("%s is not a valid class device path\n", path);
            return NULL;
        }
    } else
        safestrcpy(temp_path, path);

    cdev = alloc_class_device();
    if (!cdev) {
        dprintf("calloc failed\n");
        return NULL;
    }
    if (sysfs_get_name_from_path(temp_path, cdev->name, SYSFS_NAME_LEN)) {
        errno = EINVAL;
        dprintf("Error getting class device name\n");
        sysfs_close_class_device(cdev);
        return NULL;
    }

    safestrcpy(cdev->path, temp_path);
    if (sysfs_remove_trailing_slash(cdev->path)) {
        dprintf("Invalid path to class device %s\n", cdev->path);
        sysfs_close_class_device(cdev);
        return NULL;
    }
    set_classdev_classname(cdev);

    return cdev;
}
开发者ID:tapwag,项目名称:drakx,代码行数:56,代码来源:sysfs_class.c

示例4: memset

/**
 * sysfs_get_bus_devices: gets all devices for bus
 * @bus: bus to get devices for
 * returns dlist of devices with success and NULL with failure
 */
struct dlist *sysfs_get_bus_devices(struct sysfs_bus *bus)
{
	struct sysfs_device *dev;
	struct dlist *linklist;
	char path[SYSFS_PATH_MAX], devpath[SYSFS_PATH_MAX];
	char target[SYSFS_PATH_MAX];
	char *curlink;

	if (!bus) {
		errno = EINVAL;
		return NULL;
	}
	memset(path, 0, SYSFS_PATH_MAX);
	safestrcpy(path, bus->path);
	safestrcat(path, "/");
	safestrcat(path, SYSFS_DEVICES_NAME);

	linklist = read_dir_links(path);
	if (linklist) {
		dlist_for_each_data(linklist, curlink, char) {
			if (bus->devices) {
				dev = (struct sysfs_device *)
					dlist_find_custom(bus->devices,
					(void *)curlink, name_equal);
				if (dev)
					continue;
			}
			safestrcpy(devpath, path);
			safestrcat(devpath, "/");
			safestrcat(devpath, curlink);
			if (sysfs_get_link(devpath, target, SYSFS_PATH_MAX)) {
				dprintf("Error getting link - %s\n", devpath);
				continue;
			}
			dev = sysfs_open_device_path(target);
			if (!dev) {
				dprintf("Error opening device at %s\n",
								target);
				continue;
			}
			if (!bus->devices)
				bus->devices = dlist_new_with_delete
					(sizeof(struct sysfs_device),
					 		sysfs_close_dev);
			dlist_unshift_sorted(bus->devices, dev, sort_list);
		}
		sysfs_close_list(linklist);
	}
	return (bus->devices);
}
开发者ID:26597925,项目名称:Android-USB,代码行数:55,代码来源:sysfs_bus.c

示例5: memset

/**
 * sysfs_open_class: opens specific class and all its devices on system
 * returns sysfs_class structure with success or NULL with error.
 */
struct sysfs_class *sysfs_open_class(const char *name)
{
    struct sysfs_class *cls = NULL;
    char *c, classpath[SYSFS_PATH_MAX];

    if (!name) {
        errno = EINVAL;
        return NULL;
    }

    memset(classpath, 0, SYSFS_PATH_MAX);
    if ((sysfs_get_mnt_path(classpath, SYSFS_PATH_MAX)) != 0) {
        dprintf("Sysfs not supported on this system\n");
        return NULL;
    }

    safestrcat(classpath, "/");
    if (strcmp(name, SYSFS_BLOCK_NAME) == 0) {
        safestrcat(classpath, SYSFS_BLOCK_NAME);
        if (!sysfs_path_is_dir(classpath))
            goto done;
        c = strrchr(classpath, '/');
        *(c+1) = '\0';
    }
    safestrcat(classpath, SYSFS_CLASS_NAME);
    safestrcat(classpath, "/");
    safestrcat(classpath, name);
done:
    if (sysfs_path_is_dir(classpath)) {
        dprintf("Class %s not found on the system\n", name);
        return NULL;
    }

    cls = alloc_class();
    if (cls == NULL) {
        dprintf("calloc failed\n");
        return NULL;
    }
    safestrcpy(cls->name, name);
    safestrcpy(cls->path, classpath);
    if ((sysfs_remove_trailing_slash(cls->path)) != 0) {
        dprintf("Invalid path to class device %s\n", cls->path);
        sysfs_close_class(cls);
        return NULL;
    }

    return cls;
}
开发者ID:tapwag,项目名称:drakx,代码行数:52,代码来源:sysfs_class.c

示例6: safestrcpy

/**
 * sysfs_get_bus_driver: Get specific driver on bus using driver name
 * @bus: bus to find driver on
 * @drvname: name of driver
 * returns struct sysfs_driver reference or NULL if not found.
 */
struct sysfs_driver *sysfs_get_bus_driver(struct sysfs_bus *bus,
		const char *drvname)
{
	struct sysfs_driver *drv;
	char drvpath[SYSFS_PATH_MAX];

	if (!bus || !drvname) {
		errno = EINVAL;
		return NULL;
	}

	if (bus->drivers) {
		drv = (struct sysfs_driver *)dlist_find_custom
			(bus->drivers, (void *)drvname, name_equal);
		if (drv)
			return drv;
	}
	safestrcpy(drvpath, bus->path);
	safestrcat(drvpath, "/");
	safestrcat(drvpath, SYSFS_DRIVERS_NAME);
	safestrcat(drvpath, "/");
	safestrcat(drvpath, drvname);
	drv = sysfs_open_driver_path(drvpath);
	if (!drv) {
		dprintf("Error opening driver at %s\n", drvpath);
		return NULL;
	}
	if (!bus->drivers)
		bus->drivers = dlist_new_with_delete
				(sizeof(struct sysfs_driver),
				 		sysfs_close_drv);
	dlist_unshift_sorted(bus->drivers, drv, sort_list);
	return drv;
}
开发者ID:26597925,项目名称:Android-USB,代码行数:40,代码来源:sysfs_bus.c

示例7: createInternalProcess

// Set up internal proccess for swap managment (inswapper)
void 
createInternalProcess(const char *name, void (*entrypoint)())
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];
  
  p = allocproc();
  inswapper = p;
  if((p->pgdir = setupkvm(kalloc)) == 0)
    panic("inswapper: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;
  p->context->eip = (uint) entrypoint;  // beginning of inswapper

  safestrcpy(p->name, name, sizeof(p->name));
  p->cwd = namei("/");

  // start sleeping until first proccess is created
  p->state = SLEEPING;
}
开发者ID:RonBarabash,项目名称:OS132-Ass3,代码行数:29,代码来源:proc.c

示例8: userinit

//PAGEBREAK: 32
// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];
  
  p = allocproc();
  initproc = p;
  if((p->pgdir = setupkvm()) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");

  p->state = RUNNABLE;
#ifndef __ORIGINAL_SCHED__
  penqueue(p);
#endif
}
开发者ID:Minjun-Li,项目名称:xv6,代码行数:31,代码来源:proc.c

示例9: userinit

// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern uchar _binary_initcode_start[], _binary_initcode_size[];
  
  p = copyproc(0);
  p->sz = PAGE;
  p->mem = kalloc(p->sz);
  p->cwd = namei("/");
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = p->sz;
  
  // Make return address readable; needed for some gcc.
  p->tf->esp -= 4;
  *(uint*)(p->mem + p->tf->esp) = 0xefefefef;

  // On entry to user space, start executing at beginning of initcode.S.
  p->tf->eip = 0;
  memmove(p->mem, _binary_initcode_start, (int)_binary_initcode_size);
  safestrcpy(p->name, "initcode", sizeof(p->name));
#ifdef LOTTERY
  p->tickets = INIT_TICKETS;
#endif
  p->state = UNUSED;
  setstate(p, RUNNABLE);

  initproc = p;
}
开发者ID:aaronb,项目名称:CS637,代码行数:35,代码来源:proc.c

示例10: userinit

//PAGEBREAK: 32
// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];
  
  p = allocproc();
  initproc = p;
  if((p->pgdir = setupkvm()) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");

  p->state = RUNNABLE;
  p->next = NULL;   // initialize queue next pointer
  p->priority = 15; // initialize priority
  
  //**** 
  //cprintf("add in userinit\n");
  acquire(&ptable.lock);
  addtoq(p);
  release(&ptable.lock);
  //****
}
开发者ID:jayakumark,项目名称:advanced_os_class,代码行数:37,代码来源:proc.c

示例11: userinit

//PAGEBREAK: 32
// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];

  p = allocproc();
  
  initproc = p;
  if((p->pgdir = setupkvm()) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");

  // this assignment to p->state lets other cores
  // run this process. the acquire forces the above
  // writes to be visible, and the lock is also needed
  // because the assignment might not be atomic.
  acquire(&ptable.lock);

  p->state = RUNNABLE;

  release(&ptable.lock);
}
开发者ID:buf1024,项目名称:xv6-public,代码行数:37,代码来源:proc.c

示例12: checkpoint

// Create a new process copying p as the parent.
// Sets up stack to return as if from system call.
static int checkpoint(struct proc *p)
{
	// Allocate process.
  	//if((checkpoint_proc = allocproc()) == 0)
	//	return -1;

  	// Copy process state from p.
  	if((p->pgdir = copyuvm(proc->pgdir, proc->sz)) == 0){
    		kfree(p->kstack);
    		p->kstack = 0;
    		p->state = UNUSED;
    		return -1;
  	}
  	p->sz = proc->sz;
  	p->parent = proc;
  	// *p->tf = *proc->tf;

  	// Clear %eax so that fork returns 0 in the child.
	// p->tf->eax = 0;

	/*
  	for(i = 0; i < NOFILE; i++)
		if(proc->ofile[i])
			p->ofile[i] = filedup(proc->ofile[i]);
  	p->cwd = idup(proc->cwd);
	*/

  	safestrcpy(p->name, proc->name, sizeof(proc->name));
	cprintf("Your process name was: %s\n", p->name);

	return 0;
}
开发者ID:gitter-badger,项目名称:Shakh6,代码行数:34,代码来源:checkpoint.c

示例13: alloc_attribute

/**
 * sysfs_open_attribute: creates sysfs_attribute structure
 * @path: path to attribute.
 * returns sysfs_attribute struct with success and NULL with error.
 */
struct sysfs_attribute *sysfs_open_attribute(const char *path)
{
	struct sysfs_attribute *sysattr = NULL;
	struct stat fileinfo;
	
	if (path == NULL) {
		errno = EINVAL;
		return NULL;
	}
	sysattr = alloc_attribute();
	if (sysattr == NULL) {
		dprintf("Error allocating attribute at %s\n", path);
		return NULL;
	}
	if (sysfs_get_name_from_path(path, sysattr->name, 
				SYSFS_NAME_LEN) != 0) {
		dprintf("Error retrieving attrib name from path: %s\n", path);
		sysfs_close_attribute(sysattr);
		return NULL;
	}
	safestrcpy(sysattr->path, path);
	if ((stat(sysattr->path, &fileinfo)) != 0) {
		dprintf("Stat failed: No such attribute?\n");
		sysattr->method = 0;
		free(sysattr);
		sysattr = NULL;
	} else {
		if (fileinfo.st_mode & S_IRUSR)
			sysattr->method |= SYSFS_METHOD_SHOW;
		if (fileinfo.st_mode & S_IWUSR)
			sysattr->method |= SYSFS_METHOD_STORE;
	}

	return sysattr;
}
开发者ID:26597925,项目名称:Android-USB,代码行数:40,代码来源:sysfs_dir.c

示例14: userinit

//PAGEBREAK: 32
// Set up first user process.
void userinit(void) {
	struct proc *p;
	extern char _binary_initcode_start[], _binary_initcode_size[];

	p = allocproc();

	initproc = p;
	if ((p->pgdir = setupkvm()) == 0)
		panic("userinit: out of memory?");
	inituvm(p->pgdir, _binary_initcode_start, (int) _binary_initcode_size);
	p->sz = PGSIZE;
	memset(p->tf, 0, sizeof(*p->tf));
	p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
	p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
	p->tf->es = p->tf->ds;
	p->tf->ss = p->tf->ds;
	p->tf->eflags = FL_IF;
	p->tf->esp = PGSIZE;
	p->tf->eip = 0; // beginning of initcode.S

	safestrcpy(p->name, "initcode", sizeof(p->name));
	p->cwd = namei("/");


	p->parent=0;
	setpriority(p,0);
	SetProcessRunnable(p);
}
开发者ID:jahandideh-iman,项目名称:XV6_Scheduling,代码行数:30,代码来源:proc.c

示例15: userinit

//PAGEBREAK: 32
// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];
  
  p = allocproc();
  initproc = p;
  if((p->pgdir = setupkvm(kalloc)) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");

  p->state = RUNNABLE;
  createInternalProcess("inSwapper",(void*)inSwapper);
}
开发者ID:yonatana,项目名称:OS,代码行数:29,代码来源:proc.c


注:本文中的safestrcpy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。