Example #1
0
Object obj_mul(Object a, Object b) {
    if (a.type == b.type && a.type == TYPE_NUM) {
        GET_NUM(a) *= GET_NUM(b);
        return a;
    }
    if (a.type == TYPE_NUM && b.type == TYPE_STR) {
        Object temp = a;
        a = b;
        b = temp;
    }
    if (a.type == TYPE_STR && b.type == TYPE_NUM) {
        int len = GET_STR_LEN(a);
        Object des;
        if (len == 0)
            return a;
        int times = (int) GET_NUM(b);
        if (times <= 0)
            return sz_to_string("");
        if (times == 1)
            return a;
        des = string_alloc(NULL, len * times);
        char* s = GET_STR(des);
        int i;
        for (i = 0; i < times; i++) {
            strncpy(s, GET_STR(a), len);
            s += len;
        }
        return des;
    }
    tm_raise("obj_mul: can not multiply %o and %o", a, b);
    return NONE_OBJECT;
}
Example #2
0
Object obj_add(Object a, Object b) {
    if (TM_TYPE(a) == TM_TYPE(b)) {
        switch (TM_TYPE(a)) {
        case TYPE_NUM:
            GET_NUM(a) += GET_NUM(b);
            return a;
        case TYPE_STR: {
            char* sa = GET_STR(a);
            char* sb = GET_STR(b);
            int la = GET_STR_LEN(a);
            int lb = GET_STR_LEN(b);
            if (la == 0) {return b;    }
            if (lb == 0) {return a;    }
            int len = la + lb;
            Object des = string_alloc(NULL, len);
            char*s = GET_STR(des);
            memcpy(s, sa, la);
            memcpy(s + la, sb, lb);
            return des;
        }
        case TYPE_LIST: {
            return list_add(GET_LIST(a), GET_LIST(b));
        }
        }
    }
    tm_raise("obj_add: can not add %o and %o", (a), (b));
    return NONE_OBJECT;
}
Example #3
0
JNIEXPORT jstring JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_restoreInodes(JNIEnv *env,
    jclass cls /*ARGSUSED*/, jobject ctx, jstring fsname, jstring dumppath,
    jobjectArray filepaths, jobjectArray destinations, jintArray copies,
    jint replaceType) {

	char *str = NULL;

	jboolean isCopy, isCopy2;
	char *fstr = GET_STR(fsname, isCopy);
	char *dstr = GET_STR(dumppath, isCopy2);

	PTRACE(1, "jni:Restore_restoreInodes() entry");

	if (-1 == restore_inodes(CTX, fstr,
	    dstr, jarray2lst(env, filepaths, "java/Lang/String", String2charr),
	    jarray2lst(env, destinations, "java/Lang/String", String2charr),
	    jintArray2lst(env, copies), replaceType,
	    &str)) {

		REL_STR(fsname, fstr, isCopy);
		REL_STR(dumppath, dstr, isCopy2);
		ThrowEx(env);
		return (NULL);
	}
	REL_STR(fsname, fstr, isCopy);
	REL_STR(dumppath, dstr, isCopy2);
	PTRACE(1, "jni:Restore_restoreInodes() done");
	return (JSTRING(str));

}
Example #4
0
int write_mobile_espec(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{
  if (GET_ATTACK(mob) != 0)
    fprintf(fd, "BareHandAttack: %d\n", GET_ATTACK(mob));
  if (GET_STR(mob) != 0)
    fprintf(fd, "Str: %d\n", GET_STR(mob));
  if (GET_ADD(mob) != 0)
    fprintf(fd, "StrAdd: %d\n", GET_ADD(mob));
  if (GET_DEX(mob) != 0)
    fprintf(fd, "Dex: %d\n", GET_DEX(mob));
  if (GET_INT(mob) != 0)
    fprintf(fd, "Int: %d\n", GET_INT(mob));
  if (GET_WIS(mob) != 0)
    fprintf(fd, "Wis: %d\n", GET_WIS(mob));
  if (GET_CON(mob) != 0)
    fprintf(fd, "Con: %d\n", GET_CON(mob));
  if (GET_CHA(mob) != 0)
    fprintf(fd, "Cha: %d\n", GET_CHA(mob));
  if(GET_CLASS(mob) != CLASS_NPC_OTHER)
    fprintf(fd, "Class: %d\n", GET_CLASS(mob));
  if(GET_RACE(mob) != RACE_NPC_OTHER)
    fprintf(fd, "Race: %d\n", GET_RACE(mob));
  if(GET_MOB_WEIGHT(mob))
    fprintf(fd, "Weight: %d\n", GET_MOB_WEIGHT(mob));

  fprintf(fd, "Size: %d\n", GET_MOB_SIZE(mob));

  fputs("E\n", fd);
  return TRUE;
}
Example #5
0
JNIEXPORT jobjectArray JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_getIndexedSnaps(JNIEnv *env,
    jclass cls /*ARGSUSED*/, jobject ctx, jstring fsname, jstring snapdir) {

	jboolean isCopy, isCopy2;
	char *fstr = GET_STR(fsname, isCopy);
	char *dstr = GET_STR(snapdir, isCopy2);
	sqm_lst_t *snaplist = NULL;
	jobjectArray newArr;

	PTRACE(1, "jni:Restore_getIndexedSnaps(..., %s) entry", Str(fstr));
	if (-1 == get_indexed_snapshots(CTX, fstr, dstr, &snaplist)) {
		REL_STR(fsname, fstr, isCopy);
		REL_STR(snapdir, dstr, isCopy2);
		ThrowEx(env);
		return (NULL);
	}

	REL_STR(fsname, fstr, isCopy);
	REL_STR(snapdir, dstr, isCopy2);

	newArr = lst2jarray(env, snaplist, "java/lang/String", charr2String);
	lst_free_deep(snaplist);

	PTRACE(1, "jni:Restore_getIndexedSnaps() done");
	return (newArr);
}
Example #6
0
JNIEXPORT jstring JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_searchFiles(JNIEnv *env,
    jclass cls /*ARGSUSED*/, jobject ctx, jstring fsname, jstring dumppath,
    jint entries, jstring filepath, jstring restrictions) {

	char *str = NULL;

	jboolean isCopy, isCopy2, isCopy3, isCopy4;
	char *fstr = GET_STR(fsname, isCopy);
	char *dstr = GET_STR(dumppath, isCopy2);
	char *cstr = GET_STR(filepath, isCopy3);
	char *rstr = GET_STR(restrictions, isCopy4);

	PTRACE(1, "jni:Restore_searchFiles(...,%s, %s) entry",
	    Str(cstr), Str(rstr));
	if (-1 == search_versions(CTX,
	    fstr, dstr, (int)entries, cstr, rstr, &str)) {
		REL_STR(fsname, fstr, isCopy);
		REL_STR(dumppath, dstr, isCopy2);
		REL_STR(filepath, cstr, isCopy3);
		REL_STR(restrictions, rstr, isCopy4);
		ThrowEx(env);
		return (NULL);
	}

	REL_STR(fsname, fstr, isCopy);
	REL_STR(dumppath, dstr, isCopy2);
	REL_STR(filepath, cstr, isCopy3);
	REL_STR(restrictions, rstr, isCopy4);

	PTRACE(1, "jni:Restore_searchFiles() done");
	return (JSTRING(str));
}
Example #7
0
JNIEXPORT jobjectArray JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_getVersionDetails(JNIEnv *env,
    jclass cls /*ARGSUSED*/, jobject ctx, jstring fsname,
    jstring dumppath, jstring filepath) {

	sqm_lst_t *detailslst = NULL;
	jobjectArray newArr;

	jboolean isCopy, isCopy2, isCopy3;
	char *fstr = GET_STR(fsname, isCopy);
	char *dstr = GET_STR(dumppath, isCopy2);
	char *cstr = GET_STR(filepath, isCopy3);

	PTRACE(1, "jni:Restore_getVersionDetails(...,%s)", Str(cstr));
	if (-1 == get_version_details(CTX, fstr, dstr, cstr, &detailslst)) {
		REL_STR(fsname, fstr, isCopy);
		REL_STR(dumppath, dstr, isCopy2);
		REL_STR(filepath, cstr, isCopy3);
		ThrowEx(env);
		return (NULL);
	}

	REL_STR(fsname, fstr, isCopy);
	REL_STR(dumppath, dstr, isCopy2);
	REL_STR(filepath, cstr, isCopy3);

	newArr = lst2jarray(env, detailslst, "java/lang/String", charr2String);
	lst_free_deep(detailslst);

	PTRACE(1, "jni:Restore_getVersionDetails() done");
	return (newArr);
}
Example #8
0
JNIEXPORT jstring JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_takeDump(JNIEnv *env,
    jclass cls /*ARGSUSED*/, jobject ctx, jstring fsname, jstring dumppath) {

	char *str = NULL;

	jboolean isCopy, isCopy2;
	char *fstr = GET_STR(fsname, isCopy);
	char *dstr = GET_STR(dumppath, isCopy2);

	PTRACE(1, "jni:Restore_takeDump(...,%s, %s) entry",
	    Str(fstr), Str(dstr));
	if (-1 == take_dump(CTX, fstr, dstr, &str)) {
		REL_STR(fsname, fstr, isCopy);
		REL_STR(dumppath, dstr, isCopy2);
		ThrowEx(env);
		return (NULL);
	}

	REL_STR(fsname, fstr, isCopy);
	REL_STR(dumppath, dstr, isCopy2);

	PTRACE(1, "jni:Restore_takeDump() done");
	return (JSTRING(str));
}
Example #9
0
// getDumpStatus(fsName, directory);
// Calls get_Dump_Status_by_dir
JNIEXPORT jobjectArray JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_getDumpStatus__Lcom_sun_netstorage_samqfs_mgmt_Ctx_2Ljava_lang_String_2Ljava_lang_String_2_3Ljava_lang_String_2
(JNIEnv *env, jclass cls /*ARGSUSED*/, jobject ctx, jstring fsname,
	jstring directory, jobjectArray dumps) {

	sqm_lst_t *statuslst = NULL;
	jobjectArray newArr;
	jboolean isFsNameCopy;
	jboolean isDirectoryCopy;
	char *cstr_fsname = GET_STR(fsname, isFsNameCopy);
	char *cstr_directory = GET_STR(directory, isDirectoryCopy);

	PTRACE(1, "jni:Restore_getDumpStatus() entry");
	if (-1 == get_dump_status_by_dir(CTX, cstr_fsname, cstr_directory,
	    jarray2lst(env, dumps, "java/lang/String", String2charr),
	    &statuslst)) {
		REL_STR(fsname, cstr_fsname, isFsNameCopy);
		REL_STR(directory, cstr_directory, isDirectoryCopy);
		ThrowEx(env);
		return (NULL);
	}

	REL_STR(fsname, cstr_fsname, isFsNameCopy);
	REL_STR(directory, cstr_directory, isDirectoryCopy);
	newArr = lst2jarray(env, statuslst, "java/lang/String", charr2String);
	lst_free_deep(statuslst);

	PTRACE(1, "jni:Restore_getDumpStatus() done");
	return (newArr);
}
Example #10
0
int GiveMinStrToWield(struct obj_data *obj, struct char_data *ch)
{
  int str=0;

  GET_STR(ch) = 16;  /* nice, semi-reasonable start */
  /* 
    will have a problem with except. str, that i do not care to solve
  */

  while (GET_OBJ_WEIGHT(obj) > str_app[STRENGTH_APPLY_INDEX(ch)].wield_w)
     GET_STR(ch)++;

  return(str);

}
Example #11
0
/* walk even though they could fly at will.                             */
void affect_total(struct char_data *ch)
{
  struct affected_type *af;
  int i,j;
  char buff[200];

  for(i=0; i<MAX_WEAR; i++) {
    if (ch->equipment[i])
      for(j=0; j<MAX_OBJ_AFFECT; j++)
	affect_modify(ch, ch->equipment[i]->affected[j].location,
		      (int)ch->equipment[i]->affected[j].modifier,
		      ch->equipment[i]->obj_flags.bitvector, FALSE);
  }
  
  for(af = ch->affected; af; af=af->next)
    if(af->type != SPELL_FLY)
      affect_modify(ch, af->location, (int) af->modifier, af->bitvector, 
		    FALSE);

  ch->tmpabilities = ch->abilities; 
  
  for(i=0; i<MAX_WEAR; i++) {
    if (ch->equipment[i])
      for(j=0; j<MAX_OBJ_AFFECT; j++)
	affect_modify(ch, ch->equipment[i]->affected[j].location,
		      (int) ch->equipment[i]->affected[j].modifier,
		      ch->equipment[i]->obj_flags.bitvector, TRUE);
  }
  
  
  for(af = ch->affected; af; af=af->next)
    if(af->type != SPELL_FLY)
      affect_modify(ch, af->location, (int)af->modifier, 
		    af->bitvector, TRUE);
  
  /* Make certain values are between 0..25, not < 0 and not > 25! */
  
  i = ((!IS_PC(ch)) ? 25 :18);	/* f**k polies */
 
  GET_DEX(ch) = MAX(3,MIN(GET_DEX(ch), i));
  GET_INT(ch) = MAX(3,MIN(GET_INT(ch), i));
  GET_WIS(ch) = MAX(3,MIN(GET_WIS(ch), i));
  GET_CON(ch) = MAX(3,MIN(GET_CON(ch), i));
  GET_STR(ch) = MAX(3,GET_STR(ch));
  
  if (!IS_PC(ch)) {
    GET_STR(ch) = MIN(GET_STR(ch), i);
  } else if(GET_RACE(ch) != RACE_OGRE) {
    if (GET_STR(ch) > 18) {
      GET_ADD(ch) = 100;
      GET_STR(ch) = 18;
    }
  } else {			
    /* warning: I am counting on ChangeStrength() */
    /* to be working for this to be safe :) */
    GET_STR(ch) = MIN(22,GET_STR(ch));
  }
}
Example #12
0
Object os_listdir() {
    Object list = list_new(10);
    Object path = arg_take_str_obj("listdir");
#ifdef _WIN32
    WIN32_FIND_DATA Find_file_data;
    Object _path = obj_add(path, string_new("\\*.*"));
    HANDLE h_find = FindFirstFile(GET_STR(_path), &Find_file_data);
    if (h_find == INVALID_HANDLE_VALUE) {
        tm_raise("%s is not a directory", path);
    }
    do {
        if (strcmp(Find_file_data.cFileName, "..")==0 || strcmp(Find_file_data.cFileName, ".") == 0) {
            continue;
        }
        if (Find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
            // do nothing.
        }
        Object file = string_new(Find_file_data.cFileName);
        obj_append(list, file);
    } while (FindNextFile(h_find, &Find_file_data));
    FindClose(h_find);
#else
    tm_raise("listdir not implemented in posix.");
#endif
    return list;
}
Example #13
0
JNIEXPORT jobjectArray JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Host_getConfig(JNIEnv *env,
    jclass cls /*ARGSUSED*/, jobject ctx, jstring fsName) {

	jobjectArray newArr;
	sqm_lst_t *hlst;
	jboolean isCopy; /* used by string macros */
	char *cstr = GET_STR(fsName, isCopy);

	PTRACE(1, "jni:Host_getConfig(...,%s)", Str(cstr));

	if (-1 == get_host_config(CTX, cstr, &hlst)) {
		REL_STR(fsName, cstr, isCopy);
		ThrowEx(env);
		return (NULL);
	}
	PTRACE(1, "jni:host config information obtained");

	newArr = lst2jarray(env, hlst, BASEPKG"/fs/Host", host2Host);
	REL_STR(fsName, cstr, isCopy);
	free_list_of_host_info(hlst);
	PTRACE(1, "jni:Host_getConfig() done");
	return (newArr);

}
resource_p resource_loader_load_url(const char *url) {
    // DANGER: This is called from a thread other than GLThread!
    JNIEnv *env = NULL;
    native_shim *shim = get_native_thread_shim(&env);
    jobject instance = shim->instance;
    jclass type = shim->type;
    resource *result = NULL;
    result = (resource*)malloc(sizeof(resource));
    jmethodID fetch_id = env->GetMethodID(type, "loadSourceFile", "(Ljava/lang/String;)Ljava/lang/String;");
    jstring s = env->NewStringUTF(url);
    jstring str = (jstring)env->CallObjectMethod(instance, fetch_id, s);
    env->DeleteLocalRef(s);
    if (str == NULL) {
        result->text = NULL;
        result->mapped = false;
    } else {
        char *contents = NULL;
        GET_STR(env, str, contents);
        env->DeleteLocalRef(str);
        int len;
        if (contents == NULL) {
            len = 0;
            contents = strdup("");
        } else {
            len = strlen(contents);
        }
        result->text = contents;
        result->size = len + 1;
        result->mapped = false;
    }
    return result;
}
Example #15
0
static void handle_file( LWControl *ectl, void *edata )
{
   char a[ 24 ];
   struct stat s;
   time_t timestamp;

   GET_STR( ectl, filename, sizeof( filename ));
   if ( filename[ 0 ] == 0 ) return;

   if ( fp ) fclose( fp );
   if ( !( fp = fopen( filename, "rb" ))) {
      msgf->error( "Couldn't open", filename );
      return;
   }

   stat( filename, &s );
   filesize = s.st_size;
   timestamp = s.st_mtime;

   pos = 0;
   set_scroll();

   SET_STR( ctl[ 11 ], itoa( filesize, a, 10 ), sizeof( a ));
   strftime( a, sizeof( a ), "%d %b %y %X", localtime( &timestamp ));
   SET_STR( ctl[ 2 ], a, strlen( a ));

   ctl[ 0 ]->draw( ctl[ 0 ], DR_REFRESH );
}
Example #16
0
JNIEXPORT jobjectArray JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Host_getSharedFSHosts(JNIEnv *env,
    jclass cls /*ARGSUSED*/, jobject ctx, jstring fsName, jint options) {

	jobjectArray newArr;
	sqm_lst_t *kvlst;
	jboolean isCopy; /* used by string macros */
	char *cstr = GET_STR(fsName, isCopy);

	PTRACE(1, "jni:Host_getSharedFSHosts(...,%s)", Str(cstr));

	if (-1 == get_shared_fs_hosts(CTX, cstr, options, &kvlst)) {
		REL_STR(fsName, cstr, isCopy);
		ThrowEx(env);
		return (NULL);
	}
	PTRACE(1, "jni:shared host information obtained");

	newArr = lst2jarray(env, kvlst, "java/lang/String", charr2String);
	REL_STR(fsName, cstr, isCopy);
	lst_free_deep(kvlst);
	PTRACE(1, "jni:Host_getSharedFSHosts() done");
	return (newArr);

}
Example #17
0
/*
 * extract a char array from the Java String stored in the specified object
 * field and copy into a newly created buffer that must be freed by the caller
 */
void
getCharStarFld(JNIEnv *env, jclass cls, jobject obj,
    char *fieldname, char **buf) {
	jfieldID fid;
	jboolean isCopy;
	jstring s;
	char *cstr;

	if (NULL == obj) {
		PTRACE(1, "jni:getCharStarFld(...,%s,...):obj arg is null",
		    fieldname);
		*buf = (char *)malloc(sizeof (char));
		(*buf)[0] = '\0';
		return;
	}
	fid = (*env)->GetFieldID(env, cls, fieldname, "Ljava/lang/String;");
	if (NULL == fid) (*env)->ExceptionDescribe(env);
	s = (jstring)(*env)->GetObjectField(env, obj, fid);
	if (NULL == s) {
		*buf = (char *)malloc(sizeof (char));
		(*buf)[0] = '\0';
	} else {
		cstr = GET_STR(s, isCopy);
		*buf = strdup(cstr);
		REL_STR(s, cstr, isCopy);
	}
}
Example #18
0
JNIEXPORT jobjectArray JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Host_getAdvancedNetCfg(JNIEnv *env,
    jclass cls /*ARGSUSED*/, jobject ctx, jstring fsName) {


	jobjectArray newArr;
	sqm_lst_t *lst;
	jboolean isCopy; /* used by string macros */
	char *cstr = GET_STR(fsName, isCopy);

	PTRACE(1, "jni:Host_getAdvancedNetCfg(...,%s)", Str(cstr));

	if (-1 == get_advanced_network_cfg(CTX, cstr, &lst)) {
		REL_STR(fsName, cstr, isCopy);
		ThrowEx(env);
		return (NULL);
	}
	PTRACE(1, "jni:advanced net cfg information obtained");

	newArr = lst2jarray(env, lst, "java/lang/String", charr2String);
	REL_STR(fsName, cstr, isCopy);
	lst_free_deep(lst);

	PTRACE(1, "jni:Host_getAdvancedNetCfg() done");
	return (newArr);
}
Example #19
0
JNIEXPORT void JNICALL
Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_setIsDumpRetainedPermanently
	(JNIEnv *env, jclass cls, /*ARGSUSED*/ jobject ctx,
	jstring dumpPath, jboolean retainValue) {

	jboolean isCopy;
	char *pDumpPathStr = GET_STR(dumpPath, isCopy);

	PTRACE(1, "jni:Restore_setIsDumpRetainedPermanently(...,%s,%d) entry",
	Str(pDumpPathStr), retainValue);

	if (JNI_TRUE == retainValue) {
	// Call setter
		if (-1 == set_snapshot_locked(CTX, pDumpPathStr)) {
			REL_STR(dumpPath, pDumpPathStr, isCopy);
			ThrowEx(env);
		return;
		}
	} else {
	// Call clearer
	if (-1 == clear_snapshot_locked(CTX, pDumpPathStr)) {
		REL_STR(dumpPath, pDumpPathStr, isCopy);
		ThrowEx(env);
		return;
	}
	}

    REL_STR(dumpPath, pDumpPathStr, isCopy);

    PTRACE(1, "jni:Restore_setIsDumpRetainedPermanently() done");
}
Example #20
0
/**
 * @since 2016-11-20
 */
Object tm_load_module(Object file, Object code, Object name) {
    Object mod = module_new(file, name, code);
    Object fnc = func_new(mod, NONE_OBJECT, NULL);
    GET_FUNCTION(fnc)->code = (unsigned char*) GET_STR(code);
    GET_FUNCTION(fnc)->name = string_new("#main");
    call_function(fnc);
    return GET_MODULE(mod)->globals;
}
Example #21
0
int write_mobile_espec(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{
  if (GET_ATTACK(mob) != 0)
    fprintf(fd, "BareHandAttack: %d\n", GET_ATTACK(mob));
  if (GET_STR(mob) != 11)
    fprintf(fd, "Str: %d\n", GET_STR(mob));
  if (GET_ADD(mob) != 0)
    fprintf(fd, "StrAdd: %d\n", GET_ADD(mob));
  if (GET_DEX(mob) != 11)
    fprintf(fd, "Dex: %d\n", GET_DEX(mob));
  if (GET_INT(mob) != 11)
    fprintf(fd, "Int: %d\n", GET_INT(mob));
  if (GET_WIS(mob) != 11)
    fprintf(fd, "Wis: %d\n", GET_WIS(mob));
  fputs("E\n", fd);
  return TRUE;
}
Example #22
0
Object os_exists(){
    Object _fname = arg_take_str_obj("exists");
    char* fname = GET_STR(_fname);
    FILE*fp = fopen(fname, "rb");
    if(fp == NULL) return tm->_FALSE;
    fclose(fp);
    return tm->_TRUE;
}
Example #23
0
int obj_cmp(Object a, Object b) {
    if (TM_TYPE(a) == TM_TYPE(b)) {
        switch (TM_TYPE(a)) {
            case TYPE_NUM: {
                double diff = GET_NUM(a) - GET_NUM(b);
                if (diff > 0.0) {
                    return 1;
                } else if (diff < 0.0) {
                    return -1;
                }
                return 0;
            }
            case TYPE_STR: return strcmp(GET_STR(a), GET_STR(b));
        }
    }
    tm_raise("obj_cmp: can not compare %o and %o", a, b);
    return 0;
}
Example #24
0
const char* device_info() {
    native_shim *shim = get_native_shim();
    jmethodID method = shim->env->GetMethodID(shim->type, "getDeviceInfo", "()Ljava/lang/String;");
    jstring result = (jstring) shim->env->CallObjectMethod(shim->instance, method);
    const char* str = NULL;
    GET_STR(shim->env, result, str);
    shim->env->DeleteLocalRef(result);
    return str;
}
Example #25
0
int
mpfr_asprintf (char **pp, const char *fmt, ...)
{
  int ret;

  GET_STR (ret, *pp, fmt);

  return ret;
}
Example #26
0
// TestOptions():
//  Test the options on the Main Panel before processing,
//  such as the Source Pattern, Destination Path, etc.
bool AllKeyer::TestOptions() {
  // Destination Path Tests
  char dest[MAX_PATH_LENGTH];
  GET_STR( panel->destination_path, dest, MAX_PATH_LENGTH );
  if( (stricmp( dest, "(none)" ) == 0) ||
      (dest[0] == '\0' ) ) {
    message->Error("You must enter a destination path!");
    return false;
  }

  if( !DirInfo::Exists( dest, DI_EXIST_ONLY ) ) {
    panel->message->Error("Destination path doesn't exist:", dest);
    return false;
  }

  // Comapre Test
  char comp[MAX_PATH_LENGTH];
  GET_STR( panel->compare_file, comp, MAX_PATH_LENGTH );
  if( stricmp( comp, "(none)" ) != 0 ){
    if( DirInfo::Exists( comp ) )
      use_compare = true;
    else
      use_compare = false;
  }

  // Source Pattern Tests
  char source[MAX_PATH_LENGTH];
  GET_STR( panel->source_pattern, source, MAX_PATH_LENGTH );
  if( (stricmp( source, "(none)"    ) == 0) ||
      (stricmp( source, "(unnamed)" ) == 0) ) {
    panel->message->Error("You must enter a source pattern",
                          "or load a scene into layout" );
    return false;
  }

  os_dir->ChangeFullPath( source );
  if( !os_dir->FindFirstWildcardMatch() ) {
    message->Error("No files found that match the source pattern!");
    os_dir->CloseSearch();
    return false;
  }

  return true;
}
Example #27
0
const char* device_global_id() {
    native_shim *shim = get_native_shim();
    JNIEnv *env = shim->env;
    jmethodID method = env->GetMethodID(shim->type, "getDeviceID", "()Ljava/lang/String;");
    jstring result = (jstring) env->CallObjectMethod(shim->instance, method);
    const char* str = NULL;
    GET_STR(env, result, str);
    env->DeleteLocalRef(result);
    return str;
}
Example #28
0
int get_str2(void **buf, int *len, char **value, size_t *n)
{
    GET_STR_ARG_CHECK;

    uint16_t slen = 0;
    if (get_uint16(buf, len, &slen) < 0)
        return -2;

    GET_STR(slen);
}
Example #29
0
const char* textbox_get_value(int id) {
	native_shim* shim = get_native_shim();
	JNIEnv *env = shim->env;

	jmethodID method = env->GetMethodID(shim->type, "getTextBoxValue", "(I)Ljava/lang/String;");
	jstring value = (jstring) env->CallObjectMethod(shim->instance, method, id);
	const char* str = NULL;
	GET_STR(env, value, str);
	env->DeleteLocalRef(value);
	return str;
}
Example #30
0
/*
 * a common type of j2c: converts a String to a char[]
 */
void *
String2charr(JNIEnv *env, jobject strObj) {

	jboolean isCopy;
	jstring s = (jstring)strObj;
	char *newstr, *cstr = GET_STR(s, isCopy);

	newstr = (char *)strdup(cstr);
	REL_STR(s, cstr, isCopy);
	return (newstr);
}