zgossip_msg_t * zgossip_msg_decode (zmsg_t **msg_p) { assert (msg_p); zmsg_t *msg = *msg_p; if (msg == NULL) return NULL; zgossip_msg_t *self = zgossip_msg_new (0); // Read and parse command in frame zframe_t *frame = zmsg_pop (msg); if (!frame) goto empty; // Malformed or empty // Get and check protocol signature self->needle = zframe_data (frame); self->ceiling = self->needle + zframe_size (frame); uint16_t signature; GET_NUMBER2 (signature); if (signature != (0xAAA0 | 0)) goto empty; // Invalid signature // Get message id and parse per message type GET_NUMBER1 (self->id); switch (self->id) { case ZGOSSIP_MSG_HELLO: break; case ZGOSSIP_MSG_ANNOUNCE: GET_STRING (self->endpoint); GET_STRING (self->service); break; case ZGOSSIP_MSG_PING: break; case ZGOSSIP_MSG_PONG: break; case ZGOSSIP_MSG_INVALID: break; default: goto malformed; } // Successful return zframe_destroy (&frame); zmsg_destroy (msg_p); return self; // Error returns malformed: printf ("E: malformed message '%d'\n", self->id); empty: zframe_destroy (&frame); zmsg_destroy (msg_p); zgossip_msg_destroy (&self); return (NULL); }
void CGameMenu::FixLevelLabel(BOOL fRusLng) { if (!fRusLng) GET_STRING()->SetPos(m_iLevelId, 380, 168, 8); else GET_STRING()->SetPos(m_iLevelId, 350, 168, 8); }
CELL func_string_to_list(CELL frame) { CELL string = FV0; if (!STRINGP(string)) { return make_exception("expects string"); } CELL result = V_NULL; CELL pre_tail = V_EMPTY; gc_root_3("func_string_to_list", string, result, pre_tail); const size_t len = GET_STRING(string)->len; int i; for(i = 0; i < len; ++i) { const CELL next = make_cons(make_char(GET_STRING(string)->data[i]), V_NULL); if (i == 0) { result = next; } else { CDR(pre_tail) = next; } pre_tail = next; } gc_unroot(); return result; }
CELL func_substring(CELL frame) { CELL string = FV0; CELL start = FV1; CELL end = FV2; if (!STRINGP(string)) { return make_exception("expects a string"); } if (!INTP(start)) { return make_exception("expects a non-negative start index"); } if (!INTP(end)) { return make_exception("expects a non-negative end index"); } size_t len = GET_STRING(string)->len; size_t starti = GET_INT(start); size_t endi = GET_INT(end); if (starti < 0 || starti > len) { return make_exception("start index %d out of range [0,%d]", starti, len); } if (endi < starti || endi > len) { return make_exception("end index %d out of range [%d,%d]", endi, starti, len); } gc_root_1("func_substring", string); CELL result = make_string_raw(endi - starti); gc_unroot(); memcpy(GET_STRING(result)->data, GET_STRING(string)->data + starti, endi - starti); return result; }
// 1: lattice // 2: filename // 3: metadata static int qopqdp_lattice_writer(lua_State *L) { BEGIN_ARGS; GET_LATTICE(lat); GET_STRING(fn); GET_STRING(md); END_ARGS; qopqdp_writer_create(L, fn, md, lat); return 1; }
/*-----------------------------------------------------------------------------------------* | <<< コマンド : Material >>> | 入力 bUV = false : uv のチェックを行わない(法線マップを作成する際に使用) *-----------------------------------------------------------------------------------------*/ static void ComMaterial(BOOL bUV) { float a; iMetaCount += PARAM_GET(&a, &MetaText[iMetaCount]); meta->iMatCount = (int)a; // マテリアル総数 iMetaCount += 1; // "{" 分移動 // テクスチャーデータの書き込み位置を設定 meta->pTex = &meta->atex[meta->iMatID]; //--- 各パラメータ抽出 ------------------------------------------ while(MetaText[iMetaCount] != '}') { // 改行を見つけたら、次へすすむ char str[512]; if(MetaText[iMetaCount] == '\r' && MetaText[iMetaCount + 1] == '\n') { meta->iMatID++; // マテリアル読み込み終了なので、次へ進める // テクスチャーデータの書き込み位置を設定 meta->pTex = &meta->atex[meta->iMatID]; iMetaCount += 2; //--- マテリアル名を得る -------------------------------- int i = GET_STRING(str, &MetaText[iMetaCount]); if(meta_obj_name_func != NULL) // オブジェ名を外部へ渡す { void(*func)(int iNum, char *str); func = (void(*)(int iNum, char *str))meta_obj_name_func; (*func)(meta->iMatID, str); } iMetaCount += i; //------------------------------------------------------- } //--- コマンドチェック -------------------------------------- BOOL bRet = CommandCheck(bUV); //--- 半角・全角チェック ------------------------------------ if(!bRet) { //char str[512]; // ダブルクォーテーション中に コマンドが入っているのを防ぐため、こうする。 int i = GET_STRING(str, &MetaText[iMetaCount]); iMetaCount += i; if(i == 0) { if(ISKANJI(MetaText[iMetaCount])){ iMetaCount += 2;} // 全角 else { iMetaCount += 1;} // 半角 } } } iMetaCount++; meta->pTex = NULL; // テクスチャーデータの書き込み位置をクリアー }
CELL func_string_copy(CELL frame) { CELL string = FV0; if (!STRINGP(string)) { return make_exception("expects a string"); } gc_root_1("func_string_copy", string); CELL result = make_string_raw(GET_STRING(string)->len); gc_unroot(); STRING *str = GET_STRING(string); memcpy(GET_STRING(result)->data, str->data, str->len); return result; }
void QueryWindow::onPrivmsgMessage(Event *pEvent) { Message msg = DCAST(MessageEvent, pEvent)->getMessage(); if(m_pSession->isMyNick(msg.m_params[0])) { QString fromNick = parseMsgPrefix(msg.m_prefix, MsgPrefixName); if(isTargetNick(fromNick)) { QString textToPrint; bool shouldHighlight = false; OutputMessageType msgType = MESSAGE_CUSTOM; CtcpRequestType requestType = getCtcpRequestType(msg); if(requestType != RequestTypeInvalid) { // ACTION is /me, so handle according to that. if(requestType == RequestTypeAction) { QString action = msg.m_params[1]; // Action is in the format of "\1ACTION <action>\1", so // the first 8 and last 1 characters will be excluded. msgType = MESSAGE_IRC_ACTION; QString msgText = action.mid(8, action.size()-9); shouldHighlight = containsNick(msgText); textToPrint = GET_STRING("message.action") .arg(fromNick) .arg(msgText); } } else { msgType = MESSAGE_IRC_SAY; shouldHighlight = containsNick(msg.m_params[1]); textToPrint = GET_STRING("message.say") .arg(fromNick) .arg(msg.m_params[1]); } if(!hasFocus()) { QApplication::alert(this); } printOutput(textToPrint, msgType, shouldHighlight ? COLOR_HIGHLIGHT : COLOR_NONE); } } }
/* * Class: org_codeworker_jni_ParseTree * Method: insertItem * Signature: (Ljava/lang/String;Lorg/codeworker/ParseTree;)Lorg/codeworker/ParseTree; */ JNIEXPORT jobject JNICALL Java_org_codeworker_jni_ParseTree_addItem(JNIEnv *pEnv, jobject jObject, jstring jKey) { GET_PARSETREE_HANDLE(Object); GET_STRING(Key); jobject result = createWrapper(pEnv, pObjectClass, pObjectInstance->addElement(tcKey)); RELEASE_STRING(Key); return result; }
/* * Class: org_codeworker_jni_ParseTree * Method: insertNode * Signature: (Ljava/lang/String;)Lorg/codeworker/ParseTree; */ JNIEXPORT jobject JNICALL Java_org_codeworker_jni_ParseTree_insertNode(JNIEnv *pEnv, jobject jObject, jstring jAttribute) { GET_PARSETREE_HANDLE(Object); GET_STRING(Attribute); jobject result = createWrapper(pEnv, pObjectClass, pObjectInstance->insertNode(tcAttribute)); RELEASE_STRING(Attribute); return result; }
CELL make_string(char *s) { size_t k = strlen(s); CELL cell = make_string_raw(k); memcpy(GET_STRING(cell)->data, s, k); return cell; }
static const char* ucnv_io_getAlias(const char* alias, uint16_t n, UErrorCode* pErrorCode) { if (haveAliasData(pErrorCode) && isAlias(alias, pErrorCode)) { uint32_t convNum = findConverter(alias, NULL, pErrorCode); if (convNum < gMainTable.converterListSize) { /* tagListNum - 1 is the ALL tag */ int32_t listOffset = gMainTable.taggedAliasArray[ (gMainTable.tagListSize - 1) * gMainTable.converterListSize + convNum]; if (listOffset) { uint32_t listCount = gMainTable.taggedAliasLists[listOffset]; /* +1 to skip listCount */ const uint16_t* currList = gMainTable.taggedAliasLists + listOffset + 1; if (n < listCount) { return GET_STRING(currList[n]); } *pErrorCode = U_INDEX_OUTOFBOUNDS_ERROR; } /* else this shouldn't happen. internal program error */ } /* else converter not found */ } return NULL; }
static uint16_t ucnv_io_getAliases(const char* alias, uint16_t start, const char** aliases, UErrorCode* pErrorCode) { if (haveAliasData(pErrorCode) && isAlias(alias, pErrorCode)) { uint32_t currAlias; uint32_t convNum = findConverter(alias, NULL, pErrorCode); if (convNum < gMainTable.converterListSize) { /* tagListNum - 1 is the ALL tag */ int32_t listOffset = gMainTable.taggedAliasArray[ (gMainTable.tagListSize - 1) * gMainTable.converterListSize + convNum]; if (listOffset) { uint32_t listCount = gMainTable.taggedAliasLists[listOffset]; /* +1 to skip listCount */ const uint16_t* currList = gMainTable.taggedAliasLists + listOffset + 1; for (currAlias = start; currAlias < listCount; currAlias++) { aliases[currAlias] = GET_STRING(currList[currAlias]); } } /* else this shouldn't happen. internal program error */ } /* else converter not found */ } return 0; }
CELL func_string_length(CELL frame) { if (!STRINGP(FV0)) { return make_exception("expects string"); } return make_int(GET_STRING(FV0)->len); }
void CGameMenu::DrawStartMenu() { GetScene()->SetVisible(FALSE); GET_SCENE("level")->SetVisible(FALSE); GET_SCENE("actor")->SetVisible(FALSE); GET_STRING()->SetVisible(FALSE); GET_ENGINE()->SetRTIntVar(NA_RT_GAME_STATE, GS_MENU); GET_SPRITE("stmback")->SetVisible(TRUE); GET_SPRITE("stmback")->SetZPos(6); m_pPLBut->DrawButton(50, 380 ,7); m_pOptBut->DrawButton(50, 340, 7); m_pHelpBut->DrawButton(50, 300, 7); m_pQBut->DrawButton(50, 260, 7); DrawMiniLevel(GET_ENGINE()->GetRTIntVar(NA_RT_CURR_LEVEL_NUMBER)); if (strcmp(GET_ENGINE()->GetRTStringVar(NA_RT_BACK_MUSIC), "backlogo") != 0) { GET_AUDIO()->StopMusic(GET_ENGINE()->GetRTStringVar(NA_RT_BACK_MUSIC)); GET_ENGINE()->SetRTStringVar(NA_RT_BACK_MUSIC, "backlogo"); int iMusVol; GET_ENGINE()->GetVars("config")->GetInt(L_GROUP, "config", "musvol", 0, &iMusVol); GET_AUDIO()->SetMusicVolume(GET_ENGINE()->GetRTStringVar(NA_RT_BACK_MUSIC), iMusVol); GET_AUDIO()->PlayMusic(GET_ENGINE()->GetRTStringVar(NA_RT_BACK_MUSIC)); } }
void QueryWindow::onNickMessage(Event *pEvent) { Message msg = DCAST(MessageEvent, pEvent)->getMessage(); // Will print a nick change message to the PM window // if we get a NICK message, which will only be if we're in // a channel with the person (or if the nick being changed is ours). QString oldNick = parseMsgPrefix(msg.m_prefix, MsgPrefixName); QString textToPrint = GET_STRING("message.nick") .arg(oldNick) .arg(msg.m_params[0]); if(m_pSession->isMyNick(oldNick)) { printOutput(textToPrint, MESSAGE_IRC_NICK); } else { // If the target nick has changed and there isn't another query with that name // already open, then we can safely change the target's nick. bool queryWindowExists = DCAST(StatusWindow, m_pManager->getParentWindow(this))->childIrcWindowExists(msg.m_params[0]); if(isTargetNick(oldNick) && !queryWindowExists) { setTargetNick(msg.m_params[0]); printOutput(textToPrint, MESSAGE_IRC_NICK); } } }
static int DO_Printer_postScriptSettings (UiForm *dia, const wchar_t *sendingString_dummy, Interpreter *interpreter_dummy, const wchar_t *invokingButtonTitle, bool modified, void *dummy) { (void) sendingString_dummy; (void) interpreter_dummy; (void) invokingButtonTitle; (void) modified; (void) dummy; #if defined (_WIN32) || defined (macintosh) thePrinter. allowDirectPostScript = GET_INTEGER (L"Allow direct PostScript"); #endif thePrinter. spots = GET_ENUM (kGraphicsPostscript_spots, L"Grey resolution"); #if defined (UNIX) thePrinter. paperSize = GET_ENUM (kGraphicsPostscript_paperSize, L"Paper size"); if (thePrinter. paperSize == kGraphicsPostscript_paperSize_A3) { thePrinter. paperWidth = 842 * thePrinter. resolution / 72; thePrinter. paperHeight = 1191 * thePrinter. resolution / 72; } else if (thePrinter. paperSize == kGraphicsPostscript_paperSize_US_LETTER) { thePrinter. paperWidth = 612 * thePrinter. resolution / 72; thePrinter. paperHeight = 792 * thePrinter. resolution / 72; } else { thePrinter. paperWidth = 595 * thePrinter. resolution / 72; thePrinter. paperHeight = 842 * thePrinter. resolution / 72; } thePrinter. orientation = GET_ENUM (kGraphicsPostscript_orientation, L"Orientation"); thePrinter. magnification = GET_REAL (L"Magnification"); Site_setPrintCommand (GET_STRING (L"printCommand")); #endif thePrinter. fontChoiceStrategy = GET_ENUM (kGraphicsPostscript_fontChoiceStrategy, L"Font choice strategy"); #if defined (macintosh) thePrinter. epsFilesHavePreview = GET_INTEGER (L"EPS files include preview"); #endif return 1; }
static struct ParsedRecord* get_parsed_record(struct ParsedRecord* record, const struct KeyList* keys, struct internal_parse_data* params_array, int params_count){ assert(keys); int i; for(i=0; i < params_count; i++ ){ /*if key matched it return key index, in specified list of expecting keys so it's *guarantied that key always has determinded index even for unspecified their order*/ int key_index = keys->find(keys, params_array[i].key, params_array[i].keylen); /*if current key is wrong*/ if ( key_index < 0 ){ #ifdef PARSER_DEBUG_LOG ZRT_LOG(L_ERROR, "invalid key '%s'", GET_STRING(params_array[i].key, params_array[i].keylen ) ); #endif return NULL; /*error*/ } else{ /*save current param*/ record->parsed_params_array[key_index].key_index = key_index; /*param index*/ record->parsed_params_array[key_index].val = params_array[i].val; record->parsed_params_array[key_index].vallen = params_array[i].vallen; } } return record; }
static const char* U_CALLCONV ucnv_io_nextStandardAliases(UEnumeration *enumerator, int32_t* resultLength, UErrorCode * /*pErrorCode*/) { UAliasContext *myContext = (UAliasContext *)(enumerator->context); uint32_t listOffset = myContext->listOffset; if (listOffset) { uint32_t listCount = gMainTable.taggedAliasLists[listOffset]; const uint16_t *currList = gMainTable.taggedAliasLists + listOffset + 1; if (myContext->listIdx < listCount) { const char *myStr = GET_STRING(currList[myContext->listIdx++]); if (resultLength) { *resultLength = (int32_t)uprv_strlen(myStr); } return myStr; } } /* Either we accessed a zero length list, or we enumerated too far. */ if (resultLength) { *resultLength = 0; } return NULL; }
void CGameMenu::DrawWorldIntroStart(int iWorldId) { char buf[MAX_BUFFER]; GetScene()->SetVisible(FALSE); GET_SCENE("actor")->SetVisible(FALSE); GET_STRING()->SetVisible(FALSE); m_pOKBut->DrawButton(492, 20, 8); for (int i = 0; i < NA_WORLD_DESC_NUM_LINES; i++) { wsprintf(buf, "wdesc%i%i", iWorldId + 1, i + 1); GET_STRING()->ChangeFromTable(buf, m_iWorldDesc[i]); GET_STRING()->SetVisible(TRUE, m_iWorldDesc[i]); } }
U_CFUNC const char * ucnv_io_getConverterName(const char *alias, UBool *containsOption, UErrorCode *pErrorCode) { const char *aliasTmp = alias; int32_t i = 0; for (i = 0; i < 2; i++) { if (i == 1) { /* * After the first unsuccess converter lookup, check to see if * the name begins with 'x-'. If it does, strip it off and try * again. This behaviour is similar to how ICU4J does it. */ if (aliasTmp[0] == 'x' || aliasTmp[1] == '-') { aliasTmp = aliasTmp+2; } else { break; } } if(haveAliasData(pErrorCode) && isAlias(aliasTmp, pErrorCode)) { uint32_t convNum = findConverter(aliasTmp, containsOption, pErrorCode); if (convNum < gMainTable.converterListSize) { return GET_STRING(gMainTable.converterList[convNum]); } /* else converter not found */ } else { break; } } return NULL; }
JSBool ejsaudio_LTX_onLoad(JSContext* cx, JSObject* module) { AudioConfig ac; jsval val; #define GET_STRING(prop) do{ \ if (!ejs_evalExpression(cx,module,"ejs.config.Audio."#prop,&val)) \ JS_ClearPendingException(cx); \ else{ \ JSString* s=NULL;char *cstr=NULL; \ if ((!(s=JS_ValueToString(cx,val))) \ || (!(cstr=JS_GetStringBytes(s)))) return JS_FALSE; \ ac.prop=cstr; \ } \ }while(0) GET_STRING(sdriver); GET_STRING(sdevice); #define GET_INT32(prop) do{ \ int32 i; \ if (!ejs_evalExpression(cx,module,"ejs.config.Audio."#prop,&val)) \ JS_ClearPendingException(cx); \ else{ \ if (!JS_ValueToECMAInt32(cx,val,&i)) return JS_FALSE; \ ac.prop=i; \ } \ }while(0) GET_INT32(srate); GET_INT32(sbits); GET_INT32(sbuffers); if (!ejs_evalExpression(cx,module,"ejs.config.Audio.stereo",&val)) JS_ClearPendingException(cx); else{ JSBool jsb; if (!JS_ValueToBoolean(cx, val, &jsb)) return JS_FALSE; ac.stereo=jsb; } Audio::init(ac); if (!JS_DefineFunctions(cx, module, static_methods)) return JS_FALSE; return JS_TRUE; }
// Handles the printing/sending of the PRIVMSG ACTION message. void QueryWindow::handleAction(const QString &text) { QString textToPrint = GET_STRING("message.action") .arg(m_pSession->getNick()) .arg(text); printOutput(textToPrint, MESSAGE_IRC_ACTION_SELF); m_pSession->sendAction(getWindowName(), text); }
// Handles the printing/sending of the PRIVMSG message. void QueryWindow::handleSay(const QString &text) { QString textToPrint = GET_STRING("message.say") .arg(m_pSession->getNick()) .arg(text); printOutput(textToPrint, MESSAGE_IRC_SAY_SELF); m_pSession->sendPrivmsg(getWindowName(), text); }
CELL make_string_raw(size_t k) { CELL cell = gc_alloc_extra(STRING, k+1); STRING* p = GET_STRING(cell); p->len = k; p->data[k] = '\0'; return cell; }
void CGameMenu::DrawWinScreen() { GetScene()->SetVisible(FALSE); GET_SCENE("level")->SetVisible(FALSE); GET_SCENE("actor")->SetVisible(FALSE); GET_STRING()->SetVisible(FALSE); GET_ENGINE()->SetRTIntVar(NA_RT_GAME_STATE, GS_WINSCR); GET_SPRITE("winscr")->SetVisible(TRUE); GET_SPRITE("winscr")->SetZPos(7); GET_STRING()->SetVisible(TRUE, m_iWinId); m_pOKBut->DrawButton(492, 20, 8); }
static void menu_cb_searchForPage (EDITOR_ARGS) { EDITOR_IAM (HyperPage); EDITOR_FORM (L"Search for page", 0) TEXTFIELD (L"Page", L"a") EDITOR_OK EDITOR_DO HyperPage_goToPage (me, GET_STRING (L"Page")); // BUG EDITOR_END }
void CGameMenu::DrawFailedLevel() { GetScene()->SetVisible(FALSE); GET_SCENE("level")->SetVisible(FALSE); GET_SCENE("actor")->SetVisible(FALSE); GET_STRING()->SetVisible(FALSE); GET_ENGINE()->SetRTIntVar(NA_RT_GAME_STATE, GS_MENU); GET_SPRITE("fmback")->SetVisible(TRUE); GET_SPRITE("fmback")->SetZPos(7); GET_STRING()->SetVisible(TRUE, m_iTryAgainId); m_pRLBut->DrawButton(150, 200, 8); m_pBTMBut->DrawButton(362, 200, 8); }
// 1: lattice // 2: filename // return: reader, file metadata static int qopqdp_lattice_reader(lua_State *L) { BEGIN_ARGS; GET_LATTICE(lat); GET_STRING(fn); END_ARGS; qopqdp_reader_create(L, fn, lat); return 2; }
U_CAPI const char * U_EXPORT2 ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode) { if (haveAliasData(pErrorCode)) { if (n < gMainTable.tagListSize - UCNV_NUM_HIDDEN_TAGS) { return GET_STRING(gMainTable.tagList[n]); } *pErrorCode = U_INDEX_OUTOFBOUNDS_ERROR; } return NULL; }