本文整理汇总了C++中GET_STR函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_STR函数的具体用法?C++ GET_STR怎么用?C++ GET_STR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GET_STR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obj_mul
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;
}
示例2: obj_add
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;
}
示例3: Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_restoreInodes
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));
}
示例4: write_mobile_espec
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;
}
示例5: Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_getIndexedSnaps
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);
}
示例6: Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_searchFiles
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));
}
示例7: Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_getVersionDetails
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);
}
示例8: Java_com_sun_netstorage_samqfs_mgmt_fs_Restore_takeDump
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));
}
示例9: GET_STR
// 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);
}
示例10: GiveMinStrToWield
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);
}
示例11: affect_total
/* 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); /* fuck 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));
}
}
示例12: os_listdir
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;
}
示例13: Java_com_sun_netstorage_samqfs_mgmt_fs_Host_getConfig
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);
}
示例14: resource_loader_load_url
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;
}
示例15: handle_file
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( ×tamp ));
SET_STR( ctl[ 2 ], a, strlen( a ));
ctl[ 0 ]->draw( ctl[ 0 ], DR_REFRESH );
}