void match_list_lengths( sai_object_type_t object_type, uint32_t get_attr_count, sai_attribute_t* get_attr_list, uint32_t attr_count, sai_attribute_t* attr_list) { SWSS_LOG_ENTER(); if (get_attr_count != attr_count) { SWSS_LOG_THROW("list number don't match %u != %u", get_attr_count, attr_count); } for (uint32_t i = 0; i < attr_count; ++i) { sai_attribute_t &get_attr = get_attr_list[i]; sai_attribute_t &attr = attr_list[i]; auto meta = sai_metadata_get_attr_metadata(object_type, attr.id); if (meta == NULL) { SWSS_LOG_THROW("unable to get metadata for object type %s, attribute %d", sai_serialize_object_type(object_type).c_str(), attr.id); } switch (meta->attrvaluetype) { case SAI_ATTR_VALUE_TYPE_OBJECT_LIST: CHECK_LIST(value.objlist); break; case SAI_ATTR_VALUE_TYPE_UINT8_LIST: CHECK_LIST(value.u8list); break; case SAI_ATTR_VALUE_TYPE_INT8_LIST: CHECK_LIST(value.s8list); break; case SAI_ATTR_VALUE_TYPE_UINT16_LIST: CHECK_LIST(value.u16list); break; case SAI_ATTR_VALUE_TYPE_INT16_LIST: CHECK_LIST(value.s16list); break; case SAI_ATTR_VALUE_TYPE_UINT32_LIST: CHECK_LIST(value.u32list); break; case SAI_ATTR_VALUE_TYPE_INT32_LIST: CHECK_LIST(value.s32list); break; case SAI_ATTR_VALUE_TYPE_VLAN_LIST: CHECK_LIST(value.vlanlist); break; case SAI_ATTR_VALUE_TYPE_QOS_MAP_LIST: CHECK_LIST(value.qosmap); break; case SAI_ATTR_VALUE_TYPE_TUNNEL_MAP_LIST: CHECK_LIST(value.tunnelmap); break; case SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_OBJECT_LIST: CHECK_LIST(value.aclfield.data.objlist); break; case SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_UINT8_LIST: CHECK_LIST(value.aclfield.data.u8list); CHECK_LIST(value.aclfield.mask.u8list); break; case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_OBJECT_LIST: CHECK_LIST(value.aclaction.parameter.objlist); break; default: break; } } }
Lisp_Object mswindows_handle_page_setup_dialog_box (struct frame *UNUSED (f), Lisp_Object keys) { Lisp_Object device = Qunbound, settings = Qunbound; Lisp_Object plist = Qnil; { EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys) { if (EQ (key, Q_device)) { device = wrap_device (decode_device (value)); CHECK_MSPRINTER_DEVICE (device); } else if (EQ (key, Q_printer_settings)) { CHECK_DEVMODE (value); settings = value; } else if (EQ (key, Q_properties)) { CHECK_LIST (value); plist = value; } else invalid_constant ("Unrecognized page-setup dialog keyword", key); } } if ((UNBOUNDP (device) && UNBOUNDP (settings)) || (!UNBOUNDP (device) && !UNBOUNDP (settings))) sferror ("Exactly one of :device and :printer-settings must be given", keys); if (UNBOUNDP (device)) device = settings; { Lisp_Devmode *ldm = decode_devmode (device); PAGESETUPDLGW pd; Extbyte measure[2 * MAX_XETCHAR_SIZE]; int data; qxeGetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IMEASURE, measure, sizeof (measure) / XETCHAR_SIZE); data = qxetcscmp (measure, XETEXT ("0")); memset (&pd, 0, sizeof (pd)); pd.lStructSize = sizeof (pd); pd.hwndOwner = mswindows_get_selected_frame_hwnd (); pd.Flags = PSD_MARGINS; pd.rtMargin.left = plist_get_margin (plist, Qleft_margin, !data); pd.rtMargin.top = plist_get_margin (plist, Qtop_margin, !data); pd.rtMargin.right = plist_get_margin (plist, Qright_margin, !data); pd.rtMargin.bottom = plist_get_margin (plist, Qbottom_margin, !data); pd.hDevMode = devmode_to_hglobal (ldm); if (!qxePageSetupDlg (&pd)) { global_free_2_maybe (pd.hDevNames, pd.hDevMode); return Qnil; } if (pd.hDevMode) handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode); /* Finally, build the resulting plist */ { Lisp_Object result = Qnil; int mm_p = pd.Flags & PSD_INHUNDREDTHSOFMILLIMETERS; result = plist_set_margin (result, Qbottom_margin, pd.rtMargin.bottom, mm_p); result = plist_set_margin (result, Qright_margin, pd.rtMargin.right, mm_p); result = plist_set_margin (result, Qtop_margin, pd.rtMargin.top, mm_p); result = plist_set_margin (result, Qleft_margin, pd.rtMargin.left, mm_p); return result; } } }
LispObj * Lisp_XawListChange(LispBuiltin *builtin) /* xaw-list-change widget list &optional longest resize */ { Widget widget; String *list; int i, nitems; int longest; Boolean resize; LispObj *object; WidgetData *data; LispObj *owidget, *olist, *olongest, *oresize; oresize = ARGUMENT(3); olongest = ARGUMENT(2); olist = ARGUMENT(1); owidget = ARGUMENT(0); if (!CHECKO(owidget, xawWidget_t)) LispDestroy("%s: cannot convert %s to Widget", STRFUN(builtin), STROBJ(owidget)); widget = (Widget)(owidget->data.opaque.data); CHECK_LIST(olist); for (nitems = 0, object = olist; CONSP(object); ++nitems, object = CDR(object)) CHECK_STRING(CAR(object)); if (olongest != UNSPEC) { CHECK_INDEX(olongest); longest = FIXNUM_VALUE(olongest); } else XtVaGetValues(widget, XtNlongest, &longest, NULL, 0); resize = oresize != UNSPEC && oresize != NIL; /* No errors in arguments, build string list */ list = (String*)XtMalloc(sizeof(String) * nitems); for (i = 0, object = olist; CONSP(object); i++, object = CDR(object)) list[i] = THESTR(CAR(object)); /* Check if xaw-list-change was already called * for this widget and free previous data */ for (i = 0; i < num_list_data; i++) if ((Widget)CAR(list_data[i]->object)->data.opaque.data == widget) { XtRemoveCallback(widget, XtNdestroyCallback, LispXawCleanupCallback, list_data[i]); LispXawCleanupCallback(widget, list_data[i], NULL); break; } if (i >= num_list_data) { ++num_list_data; list_data = (WidgetData**)XtRealloc((XtPointer)list_data, sizeof(WidgetData*) * num_list_data); } data = (WidgetData*)XtMalloc(sizeof(WidgetData)); data->data = list; list_data[i] = data; data->object = CONS(owidget, olist); PROTECT(owidget, data->object); XtAddCallback(widget, XtNdestroyCallback, LispXawCleanupCallback, data); XawListChange(widget, list, nitems, longest, resize); return (olist); }
int main(void) { wn_sll list, sll, sll2; long ll; int i; setbuf(stdout, NULL); setbuf(stderr, NULL); printf("testing lists ...\n"); wn_gpmake("general_free"); list = NULL; wn_sllins(&list, (ptr) 5); wn_sllins(&list, (ptr) 4); wn_sllins(&list, (ptr) 3); { int a[] = { 3, 4, 5 }; CHECK_LIST(list, a); } wn_mksll(&sll); sll->contents = (ptr) 2; wn_slleins(&list, sll); { int a[] = { 2, 3, 4, 5 }; CHECK_LIST(list, a); } wn_slldel(&list, (ptr) 3); { int a[] = { 2, 4, 5 }; CHECK_LIST(list, a); } wn_sllins(&list->next, (ptr) 3); { int a[] = { 2, 3, 4, 5 }; CHECK_LIST(list, a); } wn_slledel(&list->next->next); { int a[] = { 2, 3, 5 }; CHECK_LIST(list, a); } wn_slleunlink(&list->next); { int a[] = { 2, 5 }; CHECK_LIST(list, a); } wn_sllins(&list->next, (ptr) 4); wn_sllins(&list->next, (ptr) 3); { int a[] = { 2, 3, 4, 5 }; CHECK_LIST(list, a); } wn_sllindex((ptr *) &ll, list, 2); wn_assert(4 == ll); wn_slleindex(&sll, list, 2); { int a[] = { 4, 5 }; CHECK_LIST(sll, a); } wn_sllget_index(&i, list, (ptr) 4); wn_assert(2 == i); wn_sllrev(&list); { int a[] = { 5, 4, 3, 2 }; CHECK_LIST(list, a); } sll = NULL; wn_sllins(&sll, (ptr) 6); wn_sllins(&sll, (ptr) 7); wn_sllins(&sll, (ptr) 8); wn_sllcpy(&sll2, sll); wn_sllcat(&sll, list); { int a[] = { 8, 7, 6, 5, 4, 3, 2 }; CHECK_LIST(sll, a); } { int a[] = { 8, 7, 6 }; CHECK_LIST(sll2, a); } { int a[] = { 5, 4, 3, 2 }; CHECK_LIST(list, a); } sll = NULL; wn_sllins(&sll, (ptr) 6); wn_sllins(&sll, (ptr) 7); wn_sllins_sll(&list, sll); wn_assert(list == sll); { int a[] = { 7, 6, 5, 4, 3, 2 }; CHECK_LIST(list, a); } wn_slllast(&sll, list); { int a[] = { 2 }; CHECK_LIST(sll, a); } wn_assert(6 == wn_sllcount(list)); wn_gpfree(); printf(" ok!!!!!!\n"); return(0); } /* main */