Пример #1
0
/* Function: al_set_path_filename
 */
void al_set_path_filename(ALLEGRO_PATH *path, const char *filename)
{
   ASSERT(path);

   if (filename)
      al_ustr_assign_cstr(path->filename, filename);
   else
      al_ustr_truncate(path->filename, 0);
}
Пример #2
0
/* Function: al_set_path_drive
 */
void al_set_path_drive(ALLEGRO_PATH *path, const char *drive)
{
   ASSERT(path);

   if (drive)
      al_ustr_assign_cstr(path->drive, drive);
   else
      al_ustr_truncate(path->drive, 0);
}
Пример #3
0
/* Function: al_replace_path_component
 */
void al_replace_path_component(ALLEGRO_PATH *path, int i, const char *s)
{
   ASSERT(path);
   ASSERT(s);
   ASSERT(i < (int)_al_vector_size(&path->segments));

   if (i < 0)
      i = _al_vector_size(&path->segments) + i;

   ASSERT(i >= 0);

   al_ustr_assign_cstr(get_segment(path, i), s);
}
Пример #4
0
/* Test al_ustr_assign, al_ustr_assign_cstr. */
static void t40(void)
{
   ALLEGRO_USTR *us1 = al_ustr_new("我隻氣墊船裝滿晒鱔");
   ALLEGRO_USTR *us2 = al_ustr_new("Τὸ χόβερκράφτ μου εἶναι γεμᾶτο χέλια");

   CHECK(al_ustr_assign(us1, us2));
   CHECK(0 == strcmp(al_cstr(us1), "Τὸ χόβερκράφτ μου εἶναι γεμᾶτο χέλια"));

   CHECK(al_ustr_assign_cstr(us1, "私のホバークラフトは鰻でいっぱいです"));
   CHECK(54 == al_ustr_size(us1));

   al_ustr_free(us1);
   al_ustr_free(us2);
}
Пример #5
0
static bool ljoy_detect_device_name(int num, ALLEGRO_USTR *device_name)
{
    char key[80];
    const char *value;
    struct stat stbuf;

    al_ustr_truncate(device_name, 0);

    snprintf(key, sizeof(key), "device%d", num);
    value = al_get_config_value(al_get_system_config(), "joystick", key);
    if (value)
        al_ustr_assign_cstr(device_name, value);

    if (al_ustr_size(device_name) == 0)
        al_ustr_appendf(device_name, "/dev/input/event%d", num);

    return (stat(al_cstr(device_name), &stbuf) == 0);
}