void op_bitand() { DESCRIPTOR * arg1; DESCRIPTOR * arg2; arg1 = e_stack - 1; GetInt32(arg1); arg2 = e_stack - 2; GetInt32(arg2); arg2->data.value &= arg1->data.value; k_pop(1); }
/*********************************************************************\ Function name : CArrowSettings::Command Description : Created at : 12.08.01, @ 21:55:31 Created by : Thomas Kunert Modified by : \*********************************************************************/ Bool CArrowSettings::Command(Int32 lID, const BaseContainer &msg) { switch (lID) { case IDS_ARROW_SMALL_CHK: case IDS_ARROW_TYPE_COMBO: { Bool b; Int32 l; GetBool(IDS_ARROW_SMALL_CHK, b); GetInt32(IDS_ARROW_TYPE_COMBO, l); m_pArrow->m_lArrowType = l + 1 + (b ? 4 : 0); m_pArrow->ItemChanged(); break; } case IDC_IS_POPUP_CHK: GetBool(IDC_IS_POPUP_CHK, m_pArrow->m_bIsPopupButton); Enable(IDS_ARROW_SMALL_CHK, !m_pArrow->m_bIsPopupButton); Enable(IDS_ARROW_TYPE_COMBO, !m_pArrow->m_bIsPopupButton); Enable(IDC_ARROW_CHILD_ITEMS, m_pArrow->m_bIsPopupButton); m_pArrow->ItemChanged(); break; case IDC_ARROW_CHILD_ITEMS: { String str; GetString(IDC_ARROW_CHILD_ITEMS, str); m_pArrow->GetChildren()->FromString(str);//>GetChildItems(str); m_pArrow->ItemChanged(); break; } } return true; }
int Configer::PrintConfig(void) { int32_t result = S_SUCCESS; int32_t i = 0; if (GetInt32("print_config", 0) == 0) { result = E_ERROR; goto ExitError; } std::cout << "Total configuratino items count: " << total_item_count_ << std::endl; for (ValueIt it(value_list_.begin()); it != value_list_.end(); ++it) { std::cout.width(3); std::cout << i++ << ">"; std::cout.width(32); std::cout << it->first << " " << it->second << std::endl; } result = S_SUCCESS; ExitError: return result; }
hashcode_t HashCode::hashcodeByUnRepeatedField(const Message* msg, const FieldDescriptor* field) { auto reflect = msg->GetReflection(); switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_UINT64: return stl_hashcode(reflect->GetUInt64(*msg, field)); case FieldDescriptor::CPPTYPE_INT64: return stl_hashcode(reflect->GetInt64(*msg, field)); case FieldDescriptor::CPPTYPE_UINT32: return stl_hashcode(reflect->GetUInt32(*msg, field)); case FieldDescriptor::CPPTYPE_INT32: return stl_hashcode(reflect->GetInt32(*msg, field)); case FieldDescriptor::CPPTYPE_STRING: return stl_hashcode(reflect->GetString(*msg, field)); case FieldDescriptor::CPPTYPE_DOUBLE: return stl_hashcode(reflect->GetDouble(*msg, field)); case FieldDescriptor::CPPTYPE_FLOAT: return stl_hashcode(reflect->GetFloat(*msg, field)); case FieldDescriptor::CPPTYPE_BOOL: return stl_hashcode(reflect->GetBool(*msg, field)); case FieldDescriptor::CPPTYPE_ENUM: return stl_hashcode(reflect->GetEnum(*msg, field)->number()); case FieldDescriptor::CPPTYPE_MESSAGE: return stl_hashcode(reflect->GetMessage(*msg, field)); default: LOG(ERROR)<< "The type of protobuf is not supported"; return 0; } }
Array<Array<int>*>* Combination::GetIndexes(int n,int m) { if (n < 0 || n < m || m < 0) { return new Array<Array<int>*>(0,0); } if (n == 0 || m == 0) { return new Array<Array<int>*>(0,0); } int i=0; int* temp1 = new int[m]; int* temp2 = new int[m]; for ( i = m - 1; i > -1; i--) { temp1[i] = i; temp2[i] = i + (n - m); } int p = 0; Array<int>** reArray = new Array<int>*[GetInt32(n, m)]; int maxIndex = m - 1; int index = maxIndex; int* cache=new int[m]; while (index > -1) { if (index == maxIndex) { for (int j = 0; j < m; j++) { cache[j] = temp1[j]; } reArray[p]=new Array<int>(cache,m); p++; } if (temp2[index] > temp1[index]) { temp1[index]++; while (index < maxIndex) { temp1[index + 1] = temp1[index] + 1; index++; } } else if (temp2[index] == temp1[index]) { index--; continue; } } delete[] temp1; delete[] temp2; delete[] cache; Array<Array<int>*>* reValue=new Array<Array<int>*>(); reValue->Set(reArray,p); return reValue; }
INT32 MgdSqlDataReader::GetInt32(INT32 index) { INT32 ret = 0; MG_FEATURE_SERVICE_TRY() STRING propertyName = GetPropertyName(index); ret = GetInt32(propertyName); MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdSqlDataReader::GetInt32") return ret; }
/*********************************************************************\ Function name : CCustomSubDialog::Command Description : Created at : 27.03.02, @ 12:41:37 Created by : Thomas Kunert Modified by : \*********************************************************************/ Bool CCustomSubDialog::Command(Int32 id,const BaseContainer &msg) { if (!m_pElement) return true; CCustomElements* pElement = g_pCustomElements->GetItem(m_pElement->m_lElement); if (!pElement) return true; if (!m_pElement->m_pbcGUI) return true; BaseContainer* pBC = &m_pElement->m_pbcGUI[m_pElement->m_lElement]; if (id == IDC_CUSTOM_OPEN_CLOSE) { GetBool(IDC_CUSTOM_OPEN_CLOSE, pElement->m_bIsOpen); m_pElement->ItemChanged(); return true; } if (id >= FIRST_CUSTOM_ELEMENT_ID) { // find the correct property Int32 lID = FIRST_CUSTOM_ELEMENT_ID; Int32 s=0; CustomProperty* pProp = nullptr; for (Int32 i = 0; m_pProp && m_pProp[i].type != CUSTOMTYPE_END; i++) { switch (pElement->m_pProp[id - FIRST_CUSTOM_ELEMENT_ID].type) { case CUSTOMTYPE_FLAG: case CUSTOMTYPE_LONG: case CUSTOMTYPE_REAL: case CUSTOMTYPE_STRING: s = 1; break; case CUSTOMTYPE_VECTOR: s = 3; break; } if (lID <= id && id < lID + s) { pProp = &pElement->m_pProp[i]; break; } lID += s; } if (pProp) { if (pProp->type == CUSTOMTYPE_FLAG) GetBool(lID, pBC, pProp->id); else if (pProp->type == CUSTOMTYPE_LONG) GetInt32(lID, pBC, pProp->id); else if (pProp->type == CUSTOMTYPE_REAL) GetFloat(lID, pBC, pProp->id); else if (pProp->type == CUSTOMTYPE_STRING) GetString(lID, pBC, pProp->id); else if (pProp->type == CUSTOMTYPE_VECTOR) GetVector(lID, lID + 1, lID + 2, pBC, pProp->id); } m_pElement->ItemChanged(); } return true; }
void op_bitnot() { DESCRIPTOR * arg1; arg1 = e_stack - 1; GetInt32(arg1); arg1->data.value = ~(arg1->data.value); }
WaveHeader::WaveHeader( AxBuffer<aafUInt8>& buf ) { // no can do yet if ( buf.GetSize() != HEADER_SIZE ) { throw L"Wave header length too long (or not supported)"; } _headerSize = buf.GetSize(); memcpy( &_header, buf.GetPtr().get(), _headerSize ); _bitsPerSample = GetInt16( BITS_PER_SAMPLE ); _sampleRate = GetInt32( SAMPLE_RATE_IDX ); _numChannels = GetInt16( NUM_CHANNELS_IDX ); _bytesPerSample = GetInt32( BYTE_RATE_IDX ) / _numChannels / _sampleRate; _numSamples = GetInt32( SUB_CHUNK2_ID_SIZE_IDX ) / _numChannels / _bytesPerSample; }
void CMdbResult::GetNumber(void* v, register uint32 nFieldNo) { switch(GetType(nFieldNo)) { case MDB_INT8_FIELD: *(int8*)v = GetInt8(nFieldNo); break; case MDB_INT16_FIELD: *(int16*)v = GetInt16(nFieldNo); break; case MDB_INT32_FIELD: *(int32*)v = GetInt32(nFieldNo); break; case MDB_INT64_FIELD: *(int64*)v = GetInt64(nFieldNo); break; case MDB_UINT8_FIELD: *(uint8*)v = GetUInt8(nFieldNo); break; case MDB_UINT16_FIELD: *(uint16*)v = GetUInt16(nFieldNo); break; case MDB_UINT32_FIELD: *(uint32*)v = GetUInt32(nFieldNo); break; case MDB_UINT64_FIELD: *(uint64*)v = GetUInt64(nFieldNo); break; case MDB_FLOAT_FIELD: *(float*)v = GetFloat(nFieldNo); break; case MDB_DOUBLE_FIELD: case MDB_DATETIME_FIELD: *(double*)v = GetDouble(nFieldNo); break; case MDB_DATE_FIELD: case MDB_TIME_FIELD: *(int32*)v = GetInt32(nFieldNo); break; } }
void op_bitset() { DESCRIPTOR * descr; int bitno; descr = e_stack - 1; GetInt(descr); bitno = descr->data.value; descr = e_stack - 2; GetInt32(descr); descr->data.value |= 1 << bitno; k_pop(1); }
void op_bittest() { DESCRIPTOR * descr; int bitno; descr = e_stack - 1; GetInt(descr); bitno = descr->data.value; descr = e_stack - 2; GetInt32(descr); descr->data.value = ((descr->data.value & (1 << bitno)) != 0); k_pop(1); }
Value *GetDefaultValue(CodeGenerator *codegen, AstTypeNode *typeNode) { switch (typeNode->getTypeType()) { default: return nullptr; case node_boolean: return codegen->getBuilder().getFalse(); case node_float: return GetFloat(codegen, 0.0f); case node_double: return GetDouble(codegen, 0.0); case node_signed_integer8: return GetInt8(codegen, 0); case node_signed_integer16: return GetInt16(codegen, 0); case node_signed_integer32: return GetInt32(codegen, 0); case node_signed_integer64: return GetInt64(codegen, 0); case node_unsigned_integer8: return GetUInt8(codegen, 0); case node_unsigned_integer16: return GetUInt16(codegen, 0); case node_unsigned_integer32: return GetUInt32(codegen, 0); case node_unsigned_integer64: return GetUInt64(codegen, 0); case node_string: return GetString(codegen, ""); } }
// Creates a Value* of integer32 type with a value of two. Value *GetTwo_32(CodeGenerator *codegen) { return GetInt32(codegen, 2); }
/*********************************************************************\ Function name : CGroupSettings::Command Description : Created at : 12.08.01, @ 09:31:10 Created by : Thomas Kunert Modified by : \*********************************************************************/ Bool CGroupSettings::Command(Int32 lID, const BaseContainer &msg) { switch (lID) { case IDC_GROUP_TYPE_TAB: GetInt32(IDC_GROUP_TYPE_TAB, m_pGroup->m_lGroupType); ((CItemSettingsDialog*)m_pSettingsDialog)->SetSelItem(m_pGroup); //SetInt32(IDC_BORDER_TAB, IDC_BORDER_SETTINGS1); Enable(IDC_SIMPLE_GROUP_BORDER_CHK, m_pGroup->m_lGroupType != 1); Enable(IDC_SIMPLE_GROUP_BORDER_COMBO, m_pGroup->m_lGroupType != 1); Enable(IDC_SIMPLE_GROUP_BORDER_NO_TITLE_CHK, (m_pGroup->m_lGroupType == 0) && m_pGroup->m_bHasBorder); Enable(IDC_HAS_BORDER_CHECKBOX, (m_pGroup->m_lGroupType == 0) && m_pGroup->m_bHasBorder && !m_pGroup->m_bBorderNoTitle); m_pGroup->ItemChanged(); break; case IDC_GROUP_ROWS_EDIT: GetInt32(IDC_GROUP_ROWS_EDIT, m_pGroup->m_lRows); m_pGroup->m_lCols = 0; SetInt32(IDC_GROUP_COLS_EDIT, m_pGroup->m_lCols); SetInt32(IDC_GROUP_COLS_EDIT1, m_pGroup->m_lCols); m_pGroup->ItemChanged(); break; case IDC_GROUP_COLS_EDIT: GetInt32(IDC_GROUP_COLS_EDIT, m_pGroup->m_lCols); m_pGroup->m_lRows = 0; SetInt32(IDC_GROUP_ROWS_EDIT, m_pGroup->m_lRows); SetInt32(IDC_GROUP_ROWS_EDIT1, m_pGroup->m_lRows); m_pGroup->ItemChanged(); break; case IDC_GROUP_ROWS_EDIT1: GetInt32(IDC_GROUP_ROWS_EDIT1, m_pGroup->m_lRows); m_pGroup->m_lCols = 0; SetInt32(IDC_GROUP_ROWS_EDIT, m_pGroup->m_lRows); SetInt32(IDC_GROUP_COLS_EDIT, m_pGroup->m_lCols); SetInt32(IDC_GROUP_COLS_EDIT1, m_pGroup->m_lCols); m_pGroup->ItemChanged(); break; case IDC_GROUP_COLS_EDIT1: GetInt32(IDC_GROUP_COLS_EDIT1, m_pGroup->m_lCols); m_pGroup->m_lRows = 0; SetInt32(IDC_GROUP_COLS_EDIT, m_pGroup->m_lCols); SetInt32(IDC_GROUP_ROWS_EDIT, m_pGroup->m_lRows); SetInt32(IDC_GROUP_ROWS_EDIT1, m_pGroup->m_lRows); m_pGroup->ItemChanged(); break; case IDC_GROUP_EQUALCOLS_CHK: case IDC_GROUP_EQUALROWS_CHK: case IDC_GROUP_ALLOW_WEIGHTS_CHK: { Bool b; m_pGroup->m_lGroupFlags = 0; GetBool(IDC_GROUP_EQUALCOLS_CHK, b); if (b) m_pGroup->m_lGroupFlags |= BFV_GRIDGROUP_EQUALCOLS; GetBool(IDC_GROUP_EQUALROWS_CHK, b); if (b) m_pGroup->m_lGroupFlags |= BFV_GRIDGROUP_EQUALROWS; GetBool(IDC_GROUP_ALLOW_WEIGHTS_CHK, b); if (b) m_pGroup->m_lGroupFlags |= BFV_GRIDGROUP_ALLOW_WEIGHTS; m_pGroup->ItemChanged(); break; } case IDC_TAB_GROUP_TYPE_COMBO: GetInt32(IDC_TAB_GROUP_TYPE_COMBO, m_pGroup->m_lTabType); m_pGroup->ItemChanged(); break; case IDC_SCROLL_GROUP_VERT_CHK: case IDC_SCROLL_GROUP_HORZ_CHK: case IDC_SCROLL_GROUP_NOBLIT_CHK: case IDC_SCROLL_GROUP_LEFT_CHK: case IDC_SCROLL_GROUP_BORDERIN_CHK: case IDC_SCROLL_GROUP_STATUSBAR_CHK: case IDC_SCROLL_GROUP_AUTOHORIZ_CHK: case IDC_SCROLL_GROUP_AUTOVERT_CHK: { Bool b; m_pGroup->m_lScrollType = 0; GetBool(IDC_SCROLL_GROUP_VERT_CHK, b); if (b) m_pGroup->m_lScrollType |= SCROLLGROUP_VERT; GetBool(IDC_SCROLL_GROUP_HORZ_CHK, b); if (b) m_pGroup->m_lScrollType |= SCROLLGROUP_HORIZ; GetBool(IDC_SCROLL_GROUP_NOBLIT_CHK, b); if (b) m_pGroup->m_lScrollType |= SCROLLGROUP_NOBLIT; GetBool(IDC_SCROLL_GROUP_LEFT_CHK, b); if (b) m_pGroup->m_lScrollType |= SCROLLGROUP_LEFT; GetBool(IDC_SCROLL_GROUP_BORDERIN_CHK, b); if (b) m_pGroup->m_lScrollType |= SCROLLGROUP_BORDERIN; GetBool(IDC_SCROLL_GROUP_STATUSBAR_CHK, b); if (b) m_pGroup->m_lScrollType |= SCROLLGROUP_STATUSBAR; GetBool(IDC_SCROLL_GROUP_AUTOHORIZ_CHK, b); if (b) m_pGroup->m_lScrollType |= SCROLLGROUP_AUTOHORIZ; GetBool(IDC_SCROLL_GROUP_AUTOVERT_CHK, b); if (b) m_pGroup->m_lScrollType |= SCROLLGROUP_AUTOVERT; m_pGroup->ItemChanged(); break; } case IDC_SIMPLE_GROUP_BORDER_CHK: GetBool(IDC_SIMPLE_GROUP_BORDER_CHK, m_pGroup->m_bHasBorder); Enable(IDC_SIMPLE_GROUP_BORDER_COMBO, m_pGroup->m_bHasBorder); Enable(IDC_SIMPLE_GROUP_BORDER_NO_TITLE_CHK, (m_pGroup->m_lGroupType == 0) && m_pGroup->m_bHasBorder); Enable(IDC_HAS_BORDER_CHECKBOX, (m_pGroup->m_lGroupType == 0) && m_pGroup->m_bHasBorder && !m_pGroup->m_bBorderNoTitle); m_pGroup->ItemChanged(); break; case IDC_SIMPLE_GROUP_BORDER_COMBO: GetInt32(IDC_SIMPLE_GROUP_BORDER_COMBO, m_pGroup->m_lBorderStyle); if (m_pGroup->m_lLeftBorder == 0 && m_pGroup->m_lRightBorder == 0 && m_pGroup->m_lTopBorder == 0 && m_pGroup->m_lBottomBorder == 0 && m_pGroup->m_lBorderStyle != BORDER_NONE) { m_pGroup->m_lLeftBorder = m_pGroup->m_lRightBorder = m_pGroup->m_lTopBorder = m_pGroup->m_lBottomBorder = 4; SetInt32(IDC_BW_LEFT_EDIT, m_pGroup->m_lLeftBorder); SetInt32(IDC_BW_RIGHT_EDIT, m_pGroup->m_lRightBorder); SetInt32(IDC_BW_TOP_EDIT, m_pGroup->m_lTopBorder); SetInt32(IDC_BW_BOTTOM_EDIT, m_pGroup->m_lBottomBorder); } // lint -fallthrough case IDC_SIMPLE_GROUP_BORDER_NO_TITLE_CHK: GetBool(IDC_SIMPLE_GROUP_BORDER_NO_TITLE_CHK, m_pGroup->m_bBorderNoTitle); Enable(IDC_HAS_BORDER_CHECKBOX, (m_pGroup->m_lGroupType == 0) && m_pGroup->m_bHasBorder && !m_pGroup->m_bBorderNoTitle); m_pGroup->ItemChanged(); break; case IDC_BW_LEFT_EDIT: case IDC_BW_RIGHT_EDIT: case IDC_BW_TOP_EDIT: case IDC_BW_BOTTOM_EDIT: GetInt32(IDC_BW_LEFT_EDIT, m_pGroup->m_lLeftBorder); GetInt32(IDC_BW_RIGHT_EDIT, m_pGroup->m_lRightBorder); GetInt32(IDC_BW_TOP_EDIT, m_pGroup->m_lTopBorder); GetInt32(IDC_BW_BOTTOM_EDIT, m_pGroup->m_lBottomBorder); m_pGroup->ItemChanged(); break; case IDC_SPACE_X_EDIT: case IDC_SPACE_Y_EDIT: GetInt32(IDC_SPACE_X_EDIT, m_pGroup->m_lSpaceX); GetInt32(IDC_SPACE_Y_EDIT, m_pGroup->m_lSpaceY); m_pGroup->ItemChanged(); break; case IDC_HAS_BORDER_CHECKBOX: GetBool(IDC_HAS_BORDER_CHECKBOX, m_pGroup->m_bHasTitleCheckbox); m_pGroup->ItemChanged(); break; } return true; }
Bool ExecuteAutoConnect() { ConnectOptions options; Bool addDynamicsTag = false, inheritDynamicsTag = true; GetInt32(CMB_FORCE, options.forcePluginId); GetInt32(CMB_TYPE, options.forceType); GetInt32(CMB_MODE, options.connectMode); GetInt32(EDT_MAXCONN, options.maxConnections); GetFloat(EDT_RADIUS, options.radius); GetBool(CHK_CLOSED, options.closedChain); GetBool(CHK_ADDDYNAMICS, addDynamicsTag); GetBool(CHK_COMPOUND, inheritDynamicsTag); // Create an InExcludeData for the selection object. GeData ge_selection(CUSTOMGUI_INEXCLUDE_LIST, DEFAULTVALUE); auto selectionList = static_cast<InExcludeData*>( ge_selection.GetCustomDataType(CUSTOMGUI_INEXCLUDE_LIST)); if (!selectionList) return false; // Get the active document and object. BaseDocument* doc = GetActiveDocument(); if (!doc) return false; BaseObject* op = doc->GetActiveObject(); if (!op) return false; // Create the root object that will contain the connectors. AutoFree<BaseObject> root(BaseObject::Alloc(Onull)); if (!root) return false; // Function to create a dynamics tag. auto fAddDynamicsTag = [doc] (BaseObject* op, Int32 mode) { // Create a dynamics tag for the root object if it // does not already exist. BaseTag* dyn = op->GetTag(ID_RIGIDBODY); if (!dyn) { dyn = op->MakeTag(ID_RIGIDBODY); if (dyn) doc->AddUndo(UNDOTYPE_NEW, dyn); } // Update the parameters. if (dyn) { dyn->SetParameter(RIGID_BODY_HIERARCHY, mode, DESCFLAGS_SET_0); doc->AddUndo(UNDOTYPE_CHANGE_SMALL, dyn); } }; // This list will contain all objects that should be connected. // While collecting, create the dynamics tags. maxon::BaseArray<BaseObject*> objects; doc->StartUndo(); for (BaseObject* child=op->GetDown(); child; child=child->GetNext()) { objects.Append(child); if (addDynamicsTag && inheritDynamicsTag) fAddDynamicsTag(child, RIGID_BODY_HIERARCHY_COMPOUND); } if (addDynamicsTag && !inheritDynamicsTag) fAddDynamicsTag(op, RIGID_BODY_HIERARCHY_INHERIT); // If no objects where collected, quit already. if (objects.GetCount() <= 0) { doc->EndUndo(); doc->DoUndo(false); return true; } // Create the connection objects. ConnectObjects(op->GetName() + ": ", objects, options); // Fill the selection list and insert the objects. for (auto it=options.output.Begin(); it != options.output.End(); ++it) { (*it)->InsertUnderLast(root); doc->AddUndo(UNDOTYPE_NEW, *it); selectionList->InsertObject(*it, 0); } root->SetName(op->GetName() + ": " + root->GetName() + " (" + options.forceName + ")"); doc->InsertObject(root, nullptr, nullptr); doc->AddUndo(UNDOTYPE_NEW, root); // Create the selection object. if (selectionList->GetObjectCount() > 0) { BaseObject* selection = BaseObject::Alloc(Oselection); if (selection) { selection->SetParameter(SELECTIONOBJECT_LIST, ge_selection, DESCFLAGS_SET_0); selection->SetName(op->GetName() + ": " + options.forceName + " (" + selection->GetName() + ")"); doc->InsertObject(selection, nullptr, nullptr); doc->AddUndo(UNDOTYPE_NEW, selection); } ActiveObjectManager_SetMode(ACTIVEOBJECTMODE_OBJECT, false); doc->SetActiveObject(selection); } else doc->SetActiveObject(root); root.Release(); doc->EndUndo(); EventAdd(); return true; }
void UpdateGadgets(Bool relevants=false) { Int32 mode; Bool add_dynamics; GetBool(CHK_ADDDYNAMICS, add_dynamics); GetInt32(CMB_MODE, mode); BaseDocument* doc = GetActiveDocument(); BaseObject* op = doc ? doc->GetActiveObject() : nullptr; Enable(EDT_MAXCONN, mode != CMB_MODE_CHAIN); Enable(EDT_RADIUS, mode != CMB_MODE_CHAIN); Enable(CHK_CLOSED, mode == CMB_MODE_CHAIN); Enable(CHK_COMPOUND, add_dynamics); // Need at least two child objects on the active object. Bool execEnabled = op != nullptr && op->GetDown() != nullptr && op->GetDown()->GetNext() != nullptr; Enable(BTN_EXECUTE, execEnabled); if (relevants) { FreeChildren(CMB_TYPE); Int32 pluginid; GetInt32(CMB_FORCE, pluginid); do { BaseObject* op = BaseObject::Alloc(pluginid); if (!op) break; AutoFree<BaseObject> free(op); AutoAlloc<Description> desc; if (!op->GetDescription(desc, DESCFLAGS_DESC_0)) break; BaseContainer temp; AutoAlloc<AtomArray> arr; const BaseContainer* param = desc->GetParameter(FORCE_TYPE, temp, arr); if (!param) break; const BaseContainer* cycle = param->GetContainerInstance(DESC_CYCLE); if (!cycle) break; const BaseContainer* icons = param->GetContainerInstance(DESC_CYCLEICONS); Int32 i = 0; Int32 last_id = -1; while (true) { Int32 id = cycle->GetIndexId(i++); if (id == NOTOK) break; Int32 icon = icons ? icons->GetInt32(id) : -1; String name = cycle->GetString(id); if (name.Content()) { if (icon > 0) name += "&i" + String::IntToString(icon); if (last_id < 0) last_id = id; AddChild(CMB_TYPE, id, name); } } SetInt32(CMB_TYPE, last_id); } while (0); LayoutChanged(CMB_TYPE); } }
void PaletteSubDialog::PaletteLayout() { if(m_rowArea != NULL){ GetInt32(m_rowArea, m_rows); } if(m_layoutArea != NULL){ GetInt32(m_layoutArea, m_layout); } if(m_labelCheckArea != NULL){ GetBool(m_labelCheckArea,m_showLabel); } if(m_searchText != NULL){ GetString(m_searchText, m_searchString); } if(m_showControls && !m_controlsShown){ LayoutFlushGroup(1); GroupBegin(51, BFV_SCALEFIT, 1, 0, String(), 0); m_nameArea = AddEditText(IDC_NAME, BFH_SCALEFIT); SetString(IDC_NAME, m_palette.m_name); GroupBegin(123,BFH_SCALEFIT,0,1,String(),0); String rowText("Rows"); if(m_layout == 1){ rowText = String("Columns"); } AddStaticText(9, BFH_LEFT, 0, 0, rowText, 0); m_rowArea = AddEditNumberArrows(IDC_ROWS, BFH_RIGHT); GroupEnd(); SetInt32(m_rowArea, m_rows,1,99); m_layoutArea = AddComboBox(IDC_LAYOUT_DIRECTION,BFH_LEFT); AddChild(m_layoutArea, 0, String("Horizontal")); AddChild(m_layoutArea, 1, String("Vertical")); SetInt32(m_layoutArea, m_layout); m_labelCheckArea = AddCheckbox(IDC_LABELCHECKBOX,BFH_LEFT,0,0,String("Show Labels")); SetBool(m_labelCheckArea, m_showLabel); AddStaticText(IDC_FILTERLABEL, BFH_CENTER, 0, 0, String("Filter:"), 0); m_searchText = AddEditText(IDC_SEARCHTEXT, BFH_SCALEFIT); SetString(m_searchText, m_searchString); m_controlsShown = TRUE; GroupBegin(142,BFV_SCALEFIT,1,0,String(),0); GroupBorderNoTitle(BORDER_THIN_IN); AddButton(IDC_CREATEMATERIAL, BFH_CENTER, 0, 0, String("Create Materials")); m_linkColor = AddCheckbox(IDC_LINKMATERIALS,BFH_LEFT,0,0,String("Link colors")); GroupEnd(); AddButton(IDC_HIDE, BFH_CENTER, 0, 0, String("Hide Controls")); GroupEnd(); GroupBegin(3,BFV_SCALEFIT,1,0,String(),0); m_actionPopup = AddPopupButton(3,BFH_LEFT); m_trashArea = AddUserArea(4, BFH_CENTER); AttachUserArea(m_trash, m_trashArea); GroupEnd(); LayoutChanged(1); } if(!m_showControls && m_controlsShown){ LayoutFlushGroup(1); GroupBegin(3,BFV_SCALEFIT,1,0,String(),0); m_actionPopup = AddPopupButton(3,BFH_LEFT); m_trashArea = AddUserArea(4, BFH_CENTER); AttachUserArea(m_trash, m_trashArea); GroupEnd(); LayoutChanged(1); m_rowArea = NULL; m_layoutArea = NULL; m_labelCheckArea = NULL; m_searchText = NULL; m_controlsShown = FALSE; } LayoutFlushGroup(6); LayoutPalette(); LayoutChanged(6); }
void CHPGLParser::PenMoveCommand(uint8_t cmdidx) { Plotter.Resume(); switch (cmdidx) { case PU: Plotter.DelayPenUp(); _state.FeedRate = _state.FeedRateUp; break; case PD: Plotter.PenDown(); _state.FeedRate = _state.FeedRateDown; break; case PA: _state._HPGLIsAbsolut = true; break; case PR: _state._HPGLIsAbsolut = false; break; } if (IsToken(F("PD"), false, false)) { PenMoveCommand(PD); return; } if (IsToken(F("PU"), false, false)) { PenMoveCommand(PU); return; } if (IsToken(F("PA"), false, false)) { PenMoveCommand(PA); return; } if (IsToken(F("PR"), false, false)) { PenMoveCommand(PR); return; } while (IsInt(_reader->GetChar())) { long xIn = GetInt32(); //all blank or colon if (IsInt(_reader->SkipSpaces())) { // only blank as seperator } else if (_reader->GetChar() == ',' && IsInt(_reader->GetNextCharSkipScaces())) { // Colon } else { ERROR_MISSINGARGUMENT: Error(F("Missing or invalid parameter")); return; } long yIn = GetInt32(); if (_reader->IsError()) goto ERROR_MISSINGARGUMENT; mm1000_t x = HPGLToMM1000X(xIn); mm1000_t y = HPGLToMM1000Y(yIn); if (_state._HPGLIsAbsolut) { if (x != CMotionControlBase::GetInstance()->GetPosition(X_AXIS) || y != CMotionControlBase::GetInstance()->GetPosition(Y_AXIS)) { Plotter.DelayPenNow(); CMotionControlBase::GetInstance()->MoveAbsEx(_state.FeedRate , X_AXIS, x, Y_AXIS, y, -1); } } else { if (x != 0 || y != 0) { Plotter.DelayPenNow(); CMotionControlBase::GetInstance()->MoveRelEx(_state.FeedRate,X_AXIS,x, Y_AXIS, y, -1); } } if (_reader->SkipSpaces() != ',') break; _reader->GetNextCharSkipScaces(); } }
void GlPrefs::Initialize() { gWhite.red = gWhite.green = gWhite.blue = gWhite.alpha = 255; // --------- INT32s --------- const BFont* font = be_plain_font; if (font) mInt32s[ARP_FULLFONT_Y] = int32(font->Size()); mInt32s[ARP_CHECKBOX_Y] = GetInt32(ARP_FULLFONT_Y) + 5; mInt32s[ARP_INTCTRL_Y] = GetInt32(ARP_FULLFONT_Y) + 3; mInt32s[ARP_MENUCTRL_Y] = GetInt32(ARP_FULLFONT_Y) + 10; mInt32s[ARP_TEXTCTRL_Y] = GetInt32(ARP_FULLFONT_Y) + 10; mInt32s[ARP_BUTTON_Y] = GetInt32(ARP_FULLFONT_Y) + 14; mInt32s[ARP_PADX] = 2; mInt32s[ARP_PADY] = 2; // --------- Floats --------- mFloats[ARP_PADX_F] = 2.0f; mFloats[ARP_PADY_F] = 2.0f; #if 0 // --------- SIZES --------- mPrefSizes[EG_HANDLE_XY] = 3; mPrefSizes[FONT_Y] = 10; const BFont* font = be_plain_font; if (font) mPrefSizes[FONT_Y] = font->Size(); mPrefSizes[FULL_FONT_Y] = Size(FONT_Y); mPrefSizes[MAINMENU_Y] = Size(FULL_FONT_Y) + 7; mPrefSizes[V_SCROLLBAR_X] = 12; mPrefSizes[H_SCROLLBAR_Y] = 12; mPrefSizes[MENUFIELD_Y] = Size(FONT_Y) + 8; mPrefSizes[MENUBAR_Y] = Size(FONT_Y) + 5; mPrefSizes[TEXTCTRL_Y] = Size(FONT_Y) + 8; mPrefSizes[INT_CTRL_Y] = Size(FONT_Y) + 3; mPrefSizes[BOX_CTRL_Y] = Size(FONT_Y) + 5; /* FIX: What's the way to determine the button * height? */ mPrefSizes[BUTTON_Y] = 24; mPrefSizes[BORDER_X] = 5; mPrefSizes[BORDER_Y] = 5; mPrefSizes[BUTTON_BORDER_X] = 8; mPrefSizes[BUTTON_BORDER_Y] = 8; mPrefSizes[SPACE_X] = 5; mPrefSizes[SPACE_Y] = 5; mPrefSizes[BLANK_Y] = 10; mPrefSizes[TAB_X] = 15; mPrefSizes[KNOB_X] = 0; mPrefSizes[KNOB_Y] = 0; mPrefSizes[KNOB_RING_X] = 0; mPrefSizes[KNOB_RING_Y] = 0; mPrefSizes[KNOB_RING_TIGHT_X] = 0; mPrefSizes[KNOB_RING_TIGHT_Y] = 0; mPrefSizes[CHECK_BOX_X] = 12; mPrefSizes[CHECK_BOX_Y] = 12; mPrefSizes[PROP_FIELD_X] = 0; mPrefSizes[PROP_FIELD_Y] = 0; #endif // --------- COLORS --------- SetColor(ARP_BG_C, 180, 180, 180); SetColor(ARP_FG_C, 0, 0, 0); SetColor(ARP_INT_BG_C, tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_2_TINT)); SetColor(ARP_INT_BGF_C, 255, 255, 255); SetColor(ARP_INT_FG_C, 0, 0, 0); SetColor(ARP_INT_FGF_C, 0, 0, 0); SetColor(ARP_WIN_BG_C, tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); }
// Creates a Value* of integer32 type with a value of one. Value *GetOne_32(CodeGenerator *codegen) { return GetInt32(codegen, 1); }
int main(int argc, char **argv) { register afs_int32 code; char op[8]; char name[PR_MAXNAMELEN]; afs_int32 id, oid = ANONYMOUSID, gid; afs_int32 pos; unsigned int i; int n; struct prentry entry; prlist alist; idlist lid; namelist lnames; struct hostent *hostinfo; struct in_addr *hostaddr; afs_int32 *ptr; char *foo; afs_int32 over; char *cell; #ifdef AFS_AIX32_ENV /* * The following signal action for AIX is necessary so that in case of a * crash (i.e. core is generated) we can include the user's data section * in the core dump. Unfortunately, by default, only a partial core is * generated which, in many cases, isn't too useful. */ struct sigaction nsa; sigemptyset(&nsa.sa_mask); nsa.sa_handler = SIG_DFL; nsa.sa_flags = SA_FULLDUMP; sigaction(SIGSEGV, &nsa, NULL); #endif whoami = argv[0]; initialize_PT_error_table(); strcpy(confdir, AFSDIR_CLIENT_ETC_DIRPATH); cell = 0; n = 1; while (n < argc) { int arglen = strlen(argv[n]); char arg[256]; lcstring(arg, argv[n], sizeof(arg)); #define IsArg(a) (strncmp (arg,a, arglen) == 0) if (IsArg("-testconfdir")) strncpy(confdir, argv[++n], sizeof(confdir)); else if (IsArg("client")) strncpy(confdir, AFSDIR_CLIENT_ETC_DIRPATH, sizeof(confdir)); else if (IsArg("server")) strncpy(confdir, AFSDIR_SERVER_ETC_DIRPATH, sizeof(confdir)); else if (IsArg("0") || IsArg("1") || IsArg("2")) security = atoi(argv[n]); else if (IsArg("-ignoreexist")) ignoreExist++; else if (IsArg("-cell")) cell = argv[++n]; else { printf ("Usage is: 'prclient [-testconfdir <dir> | server | client] [0 | 1 | 2] [-ignoreExist] [-cell <cellname>]\n"); exit(1); } n++; } printf("Using CellServDB file in %s\n", confdir); if (security == 0) printf("Making unauthenticated connection to prserver\n"); code = pr_Initialize(security, confdir, cell); if (code) { afs_com_err(whoami, code, "Couldn't initialize protection library"); exit(1); } while (1) { char *s; printf("pr> "); s = fgets(line, sizeof(line), stdin); if (s == NULL) break; lineProgress = 0; code = GetString(op, sizeof(op)); if (code) { afs_com_err(whoami, PRBADARG, "error reading opcode in line '%s', got '%.*s'", line, sizeof(op), op); exit(1); } if (strlen(op) == 0) continue; /* no input */ if (!strcmp(op, "cr")) { if (GetString(name, sizeof(name)) || GetInt32(&id) || GetInt32(&oid)) code = PRBADARG; /* use ubik_Call to do the work, finding an up server and handling * the job of finding a sync site, if need be */ else code = ubik_PR_INewEntry(pruclient, 0, name, id, oid); if (CodeOk(code)) afs_com_err(whoami, code, "on %s %s %d %d", op, name, id, oid); } else if (!strcmp(op, "sf")) { afs_int32 mask, access, gq, uq; if (GetInt32(&id) || GetXInt32(&mask) || GetXInt32(&access) || GetInt32(&gq) || GetInt32(&uq)) code = PRBADARG; else code = ubik_PR_SetFieldsEntry(pruclient, 0, id, mask, access, gq, uq, 0, 0); if (CodeOk(code)) afs_com_err(whoami, code, "on %s %d %x %x %d %d", op, id, mask, access, gq, uq); } else if (!strcmp(op, "ce")) { char newname[PR_MAXNAMELEN]; afs_int32 newid; if (GetInt32(&id) || GetString(newname, sizeof(newname)) || GetInt32(&oid) || GetInt32(&newid)) code = PRBADARG; else code = ubik_PR_ChangeEntry(pruclient, 0, id, newname, oid, newid); if (CodeOk(code)) afs_com_err(whoami, code, "on %s %d %s %d %d", op, id, newname, oid, newid); } else if (!strcmp(op, "wh")) { /* scanf("%d",&id); */ if (GetInt32(&id)) code = PRBADARG; else code = ubik_PR_WhereIsIt(pruclient, 0, id, &pos); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); else printf("location %d\n", pos); } else if (!strcmp(op, "du")) { memset(&entry, 0, sizeof(entry)); /* scanf("%d",&pos); */ if (GetInt32(&pos)) code = PRBADARG; else code = ubik_PR_DumpEntry(pruclient, 0, pos, (struct prdebugentry *)&entry); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) { PrintEntry(pos, &entry, /*indent */ 0); #if 0 printf("The contents of the entry for %d are:\n", entry.id); printf("flags %d next %d\n", entry.flags, entry.next); printf("Groups (or members) \n"); for (i = 0; i < PRSIZE; i++) printf("%d\n", entry.entries[i]); printf("nextID %d nextname %d name %s\n", entry.nextID, entry.nextName, entry.name); printf("owner %d creator %d\n", entry.owner, entry.creator); #endif } } else if (!strcmp(op, "add") || !strcmp(op, "au")) { /* scanf("%d %d",&id,&gid); */ if (GetInt32(&id) || GetInt32(&gid)) code = PRBADARG; else code = ubik_PR_AddToGroup(pruclient, 0, id, gid); if (CodeOk(code)) afs_com_err(whoami, code, "on %s %d %d", op, id, gid); } else if (!strcmp(op, "iton")) { lid.idlist_val = (afs_int32 *) malloc(20 * sizeof(afs_int32)); ptr = lid.idlist_val; lid.idlist_len = 0; foo = line; skip(&foo); while ((lid.idlist_len < 20) && (sscanf(foo, "%d", ptr) != EOF)) { lid.idlist_len++; skip(&foo); ptr++; } if (*foo) { fprintf(stderr, "too many values specified; max is %d\n", 20); } lnames.namelist_val = 0; lnames.namelist_len = 0; code = ubik_PR_IDToName(pruclient, 0, &lid, &lnames); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) { for (i = 0; i < lnames.namelist_len; i++) { printf("id %d name %s\n", lid.idlist_val[i], lnames.namelist_val[i]); } free(lnames.namelist_val); } free(lid.idlist_val); lid.idlist_val = 0; lid.idlist_len = 0; } else if (!strcmp(op, "ntoi")) { lnames.namelist_val = (prname *) malloc(PR_MAXLIST * PR_MAXNAMELEN); lnames.namelist_len = 0; foo = line; skip(&foo); for (i = 0; ((lnames.namelist_len < PR_MAXLIST) && (sscanf(foo, "%s", lnames.namelist_val[i]) != EOF)); i++) { lnames.namelist_len++; skip(&foo); } if (*foo) { fprintf(stderr, "too many values specified; max is %d\n", PR_MAXLIST); } lid.idlist_val = 0; lid.idlist_len = 0; code = ubik_PR_NameToID(pruclient, 0, &lnames, &lid); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) { for (i = 0; i < lid.idlist_len; i++) printf("name %s id %d\n", lnames.namelist_val[i], lid.idlist_val[i]); free(lid.idlist_val); } free(lnames.namelist_val); lnames.namelist_val = 0; lnames.namelist_len = 0; } else if (!strcmp(op, "del")) { /* scanf("%d",&id); */ if (GetInt32(&id)) code = PRBADARG; else code = ubik_PR_Delete(pruclient, 0, id); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); } else if (!strcmp(op, "dg")) { /* scanf("%d",&id); */ if (GetInt32(&id)) code = PRBADARG; else code = ubik_PR_Delete(pruclient, 0, id); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); } else if (!strcmp(op, "rm")) { /* scanf("%d %d",&id,&gid); */ if (GetInt32(&id) || GetInt32(&gid)) code = PRBADARG; else code = ubik_PR_RemoveFromGroup(pruclient, 0, id, gid); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); } #if defined(SUPERGROUPS) else if (!strcmp(op, "lsg")) { alist.prlist_len = 0; alist.prlist_val = 0; /* scanf("%d",&id); */ if (GetInt32(&id)) code = PRBADARG; else code = ubik_PR_ListSuperGroups(pruclient, 0, id, &alist, &over); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) { ptr = alist.prlist_val; if (over) { printf("Number of groups greater than PR_MAXGROUPS!\n"); printf("Excess of %d.\n", over); } for (i = 0; i < alist.prlist_len; i++, ptr++) printf("%d\n", *ptr); free(alist.prlist_val); alist.prlist_len = 0; alist.prlist_val = 0; } } #endif /* SUPERGROUPS */ else if (!strcmp(op, "l")) { alist.prlist_len = 0; alist.prlist_val = 0; /* scanf("%d",&id); */ if (GetInt32(&id)) code = PRBADARG; else code = ubik_PR_GetCPS(pruclient, 0, id, &alist, &over); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) { ptr = alist.prlist_val; if (over) { printf("Number of groups greater than PR_MAXGROUPS!\n"); printf("Excess of %d.\n", over); } for (i = 0; i < alist.prlist_len; i++, ptr++) printf("%d\n", *ptr); free(alist.prlist_val); alist.prlist_len = 0; alist.prlist_val = 0; } } else if (!strcmp(op, "lh")) { alist.prlist_len = 0; alist.prlist_val = 0; /* scanf("%d",&id); */ if (GetString(name, sizeof(name))) code = PRBADARG; else if (!(hostinfo = gethostbyname(name))) code = PRBADARG; else { hostaddr = (struct in_addr *)hostinfo->h_addr_list[0]; id = ntohl(hostaddr->s_addr); code = ubik_PR_GetHostCPS(pruclient, 0, id, &alist, &over); } if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) { ptr = alist.prlist_val; if (over) { printf("Number of groups greater than PR_MAXGROUPS!\n"); printf("Excess of %d.\n", over); } for (i = 0; i < alist.prlist_len; i++, ptr++) printf("%d\n", *ptr); free(alist.prlist_val); alist.prlist_len = 0; alist.prlist_val = 0; } } #if defined(SUPERGROUPS) else if (!strcmp(op, "m")) { alist.prlist_len = 0; alist.prlist_val = 0; /* scanf("%d",&id); */ if (GetInt32(&id)) code = PRBADARG; else code = ubik_PR_ListElements(pruclient, 0, id, &alist, &over); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) { ptr = alist.prlist_val; if (over) { printf("Number of groups greater than PR_MAXGROUPS!\n"); printf("Excess of %d.\n", over); } for (i = 0; i < alist.prlist_len; i++, ptr++) printf("%d\n", *ptr); free(alist.prlist_val); alist.prlist_len = 0; alist.prlist_val = 0; } } #endif /* SUPERGROUPS */ else if (!strcmp(op, "nu")) { /* scanf("%s",name); */ if (GetString(name, sizeof(name))) code = PRBADARG; else code = pr_CreateUser(name, &id); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) printf("Id is %d.\n", id); } else if (!strcmp(op, "ng")) { /* scanf("%s",name); */ if (GetString(name, sizeof(name))) code = PRBADARG; else code = ubik_PR_NewEntry(pruclient, 0, name, 1, oid, &id); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) printf("Id is %d.\n", id); } else if (!strcmp(op, "lm")) { code = ubik_PR_ListMax(pruclient, 0, &id, &gid); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) printf("Max user id is %d, max (really min) group is %d.\n", id, gid); } else if (!strcmp(op, "smu")) { /* scanf("%d",&id); */ if (GetInt32(&id)) code = PRBADARG; else code = ubik_PR_SetMax(pruclient, 0, id, 0); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); } else if (!strcmp(op, "smg")) { /* scanf("%d",&id); */ if (GetInt32(&id)) code = PRBADARG; else code = ubik_PR_SetMax(pruclient, 0, id, 1); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); } else if (!strcmp(op, "sin")) { /* scanf("%d",&id); */ if (GetInt32(&id)) code = PRBADARG; else code = pr_SIdToName(id, name); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) printf("id %d name %s\n", id, name); } else if (!strcmp(op, "sni")) { /* scanf("%s",name); */ if (GetString(name, sizeof(name))) code = PRBADARG; else code = pr_SNameToId(name, &id); if (CodeOk(code)) printf("%s\n", pr_ErrorMsg(code)); if (code == PRSUCCESS) printf("name %s id %d\n", name, id); } else if (!strcmp(op, "fih")) { char tname[128]; struct PrUpdateEntry uentry; memset(&uentry, 0, sizeof(uentry)); /* scanf("%s",name); */ if (GetString(name, sizeof(name))) { code = PRBADARG; continue; } code = pr_SNameToId(name, &id); if (CodeOk(code)) { printf("%s\n", pr_ErrorMsg(code)); continue; } code = pr_SIdToName(id, tname); if (code == PRSUCCESS) { printf ("Warning: Id hash for %s (id %d) seems correct at the db; rehashing it anyway\n", name, id); /* continue;*/ } uentry.Mask = PRUPDATE_IDHASH; code = ubik_PR_UpdateEntry(pruclient, 0, 0, name, &uentry); if (code) { printf("Failed to update entry %s (err=%d)\n", name, code); continue; } } else if (!strcmp(op, "fnh")) { int tid; struct PrUpdateEntry uentry; memset(&uentry, 0, sizeof(uentry)); /* scanf("%d", &id); */ if (GetInt32(&id)) { code = PRBADARG; continue; } code = pr_SIdToName(id, name); if (CodeOk(code)) { printf("%s\n", pr_ErrorMsg(code)); continue; } code = pr_SNameToId(name, &tid); if (code == PRSUCCESS) { printf ("Name hash for %d (name is %s) seems correct at the db; rehashing it anyway\n", id, name); /* continue;*/ } uentry.Mask = PRUPDATE_NAMEHASH; code = ubik_PR_UpdateEntry(pruclient, 0, id, "_foo_", &uentry); if (code) { printf("Failed to update entry with id %d (err=%d)\n", id, code); continue; } } #if defined(SUPERGROUPS) else if (!strcmp(op, "fih")) { char tname[128]; struct PrUpdateEntry uentry; memset(&uentry, 0, sizeof(uentry)); /* scanf("%s",name); */ if (GetString(name, sizeof(name))) { code = PRBADARG; continue; } code = pr_SNameToId(name, &id); if (CodeOk(code)) { printf("%s\n", pr_ErrorMsg(code)); continue; } code = pr_SIdToName(id, tname); if (code == PRSUCCESS) { printf ("Warning: Id hash for %s (id %d) seems correct at the db; rehashing it anyway\n", name, id); /* continue;*/ } uentry.Mask = PRUPDATE_IDHASH; code = ubik_PR_UpdateEntry(pruclient, 0, 0, name, &uentry); if (code) { printf("Failed to update entry %s (err=%d)\n", name, code); continue; } } else if (!strcmp(op, "fnh")) { int tid; struct PrUpdateEntry uentry; memset(&uentry, 0, sizeof(uentry)); /* scanf("%d", &id); */ if (GetInt32(&id)) { code = PRBADARG; continue; } code = pr_SIdToName(id, name); if (CodeOk(code)) { printf("%s\n", pr_ErrorMsg(code)); continue; } code = pr_SNameToId(name, &tid); if (code == PRSUCCESS) { printf ("Name hash for %d (name is %s) seems correct at the db; rehashing it anyway\n", id, name); /* continue;*/ } uentry.Mask = PRUPDATE_NAMEHASH; code = ubik_PR_UpdateEntry(pruclient, 0, id, "_foo_", &uentry); if (code) { printf("Failed to update entry with id %d (err=%d)\n", id, code); continue; } } #endif /* SUPERGROUPS */ else if (!strcmp(op, "?")) PrintHelp(); else if (!strcmp(op, "q")) exit(0); else printf("Unknown op: '%s'! ? for help\n", op); } }
void Pb2Json::Message2Json(const ProtobufMsg& message, Json& json, bool enum2str) { auto descriptor = message.GetDescriptor(); auto reflection = message.GetReflection(); if (nullptr == descriptor || nullptr == descriptor) return; auto count = descriptor->field_count(); for (auto i = 0; i < count; ++i) { const auto field = descriptor->field(i); if (field->is_repeated()) { if (reflection->FieldSize(message, field) > 0) RepeatedMessage2Json(message, field, reflection, json[field->name()], enum2str); continue; } if (!reflection->HasField(message, field)) { continue; } switch (field->type()) { case ProtobufFieldDescriptor::TYPE_MESSAGE: { const ProtobufMsg& tmp_message = reflection->GetMessage(message, field); if (0 != tmp_message.ByteSize()) Message2Json(tmp_message, json[field->name()]); } break; case ProtobufFieldDescriptor::TYPE_BOOL: json[field->name()] = reflection->GetBool(message, field) ? true : false; break; case ProtobufFieldDescriptor::TYPE_ENUM: { auto* enum_value_desc = reflection->GetEnum(message, field); if (enum2str) { json[field->name()] = enum_value_desc->name(); } else { json[field->name()] = enum_value_desc->number(); } } break; case ProtobufFieldDescriptor::TYPE_INT32: case ProtobufFieldDescriptor::TYPE_SINT32: case ProtobufFieldDescriptor::TYPE_SFIXED32: json[field->name()] = reflection->GetInt32(message, field); break; case ProtobufFieldDescriptor::TYPE_UINT32: case ProtobufFieldDescriptor::TYPE_FIXED32: json[field->name()] = reflection->GetUInt32(message, field); break; case ProtobufFieldDescriptor::TYPE_INT64: case ProtobufFieldDescriptor::TYPE_SINT64: case ProtobufFieldDescriptor::TYPE_SFIXED64: json[field->name()] = reflection->GetInt64(message, field); break; case ProtobufFieldDescriptor::TYPE_UINT64: case ProtobufFieldDescriptor::TYPE_FIXED64: json[field->name()] = reflection->GetUInt64(message, field); break; case ProtobufFieldDescriptor::TYPE_FLOAT: json[field->name()] = reflection->GetFloat(message, field); break; case ProtobufFieldDescriptor::TYPE_STRING: case ProtobufFieldDescriptor::TYPE_BYTES: json[field->name()] = reflection->GetString(message, field); break; default: break; } } }
// Creates a Value* of integer32 type with a value of zero. Value *GetZero_32(CodeGenerator *codegen) { return GetInt32(codegen, 0); }