示例#1
0
int main(int argc, char *argv[])
{
  if ( argc != 2 ) /* argc should be 2 for correct execution */
  {
    /* We print argv[0] assuming it is the program name */
    printf( "usage: %s red|green|bell|various\n", argv[0] );
  }
  else 
  {
    int ret = load_device();
    if(ret == 1)
      lamp_shutdown();
    return 1;
    char* argument = argv[1];
    if(strcmp(argument, "green") == 0){
      set_green();
    } else if (strcmp(argument, "red") == 0){
      red_with_no_bell();
    } else if (strcmp(argument, "off") == 0){
      set_lights_off();
    } else if (strcmp(argument, "various") == 0){
      set_colors_with_bell();
    } else if (strcmp(argument, "bell") == 0){
      only_bell_on();
    }
  }
  lamp_shutdown();
  return 0;
}
示例#2
0
static BOOL load_devices(IMMDeviceEnumerator *devenum, EDataFlow dataflow,
        UINT *ndevs, struct DeviceInfo **out)
{
    IMMDeviceCollection *coll;
    UINT i;
    HRESULT hr;

    hr = IMMDeviceEnumerator_EnumAudioEndpoints(devenum, dataflow,
            DEVICE_STATE_ACTIVE, &coll);
    if(FAILED(hr))
        return FALSE;

    hr = IMMDeviceCollection_GetCount(coll, ndevs);
    if(FAILED(hr)){
        IMMDeviceCollection_Release(coll);
        return FALSE;
    }

    if(*ndevs > 0){
        *out = HeapAlloc(GetProcessHeap(), 0,
                sizeof(struct DeviceInfo) * (*ndevs));
        if(!*out){
            IMMDeviceCollection_Release(coll);
            return FALSE;
        }

        for(i = 0; i < *ndevs; ++i){
            IMMDevice *dev;

            hr = IMMDeviceCollection_Item(coll, i, &dev);
            if(FAILED(hr)){
                (*out)[i].id = NULL;
                continue;
            }

            load_device(dev, &(*out)[i]);

            IMMDevice_Release(dev);
        }
    }else
        *out = NULL;

    IMMDeviceCollection_Release(coll);

    return TRUE;
}
//-----------------------------------------------------------------------------
CE_EXPORT int32_t luaopen_libcrown(lua_State* L)
{
	LuaEnvironment env(L);

	load_vec2(env);
	load_vec3(env);
	load_mat4(env);
	load_quat(env);
	load_math(env);

	load_mouse(env);
	load_keyboard(env);
	load_accelerometer(env);

	load_device(env);

	load_window(env);

	return 1;
}
示例#4
0
int main(int argc, char* argv[]) {
  int pid;
  int fd;

  int ppid;
  int local_result;

  if (argc <= 1 || argc > 2) {
    printf("Usage : %s {binary}\n", argv[0]);
    return 0;
  }

  pid = getpid();

  fd = load_device();
  strncpy(profilee, argv[1], BUF_LEN);
  getProfiling(fd);

  close_device(fd);
  return 0;
}
示例#5
0
int load_device_map(const char *file)
{
	char line[512];
	char *lptr;
	char *tokens[64];
	int tindex=0;

	FILE *fdevice = fopen(file,"r");
	if (NULL==fdevice) {
		perror("fopen");
		return -1;
	}

	while (fgets(line,sizeof(line),fdevice)) {
		// Chomp
		chomp(line);
		lptr=line;
		tindex=0;

		while (*lptr && isspace(*lptr))
			lptr++;
		if (!*lptr || *lptr=='#')
			continue;
		// Tokenize
		tokens[tindex++] = strtok(lptr,",");
		while ( (tokens[tindex++]=strtok(NULL,",") ) );

		if (tindex<3) {
			fprintf(stderr,"SIMULATOR: Invalid line in device.map\n");
			return -1;
		}
		// Load
		if (load_device(atoi(tokens[0]), tokens[1], tindex-3, &tokens[2])<0) {
			return -1;
		}
	}
	return 0;
}