void Activator::update(const double val) { if (val > high) { active = true; } else if (val < low) { active = false; } return do_func(); }
int var_foreach(int (*do_func)(var_entry_t * ve)) { size_t i; for (i = 0; i < TABLE_LEN; i++) { if (!_[i].used) continue; if (do_func(_ + i)) return 1; } return 0; }
void func(int depth, char *ptr) { if (depth == 3) { do_func( depth+1, ptr ); return; } if (depth == 5) { int i; for( i=0;i<11;i++) { CTEST_ASSERT_EQ( check_stack_pointer( ptr, i ) , 0 ); } // have to add for function argument, and there is some padding between args and locals! CTEST_ASSERT_EQ( check_stack_pointer( ptr, 50 ) , -1 ); // 25 return; } func( depth+1, ptr ); }
/** * gst_buffer_list_iterator_do: * @it: a #GstBufferListIterator * @do_func: the function to be called * @user_data: the gpointer to optional user data. * * Calls the given function for the last buffer returned by * gst_buffer_list_iterator_next(). gst_buffer_list_iterator_next() must have * been called on @it before this function is called. * gst_buffer_list_iterator_remove() and gst_buffer_list_iterator_steal() must * not have been called since the last call to gst_buffer_list_iterator_next(). * * See #GstBufferListDoFunction for more details. * * Returns: the return value from @do_func * * Since: 0.10.24 */ GstBuffer * gst_buffer_list_iterator_do (GstBufferListIterator * it, GstBufferListDoFunction do_func, gpointer user_data) { GstBuffer *buffer; g_return_val_if_fail (it != NULL, NULL); g_return_val_if_fail (it->last_returned != NULL, NULL); g_return_val_if_fail (it->last_returned->data != STOLEN, NULL); g_return_val_if_fail (do_func != NULL, NULL); g_return_val_if_fail (gst_buffer_list_is_writable (it->list), NULL); g_assert (it->last_returned->data != GROUP_START); buffer = gst_buffer_list_iterator_steal (it); buffer = do_func (buffer, user_data); if (buffer == NULL) { gst_buffer_list_iterator_remove (it); } else { gst_buffer_list_iterator_take (it, buffer); } return buffer; }
int main(int argc, char *argv[]) { int c, id, mode, err = 0; char *check; struct passwd *pw; struct group *gr; static struct option long_options[] = { {"help", 0, 0, 'h'}, {"version", 0, 0, 'v'}, {"master", 0, 0, 'M'}, {"slave", 1, 0, 'S'}, {"state", 1, 0, 's'}, {"chroot", 1, 0, 'r'}, {"reboot", 0, 0, 'R'}, {"halt", 0, 0, 'H'}, {"pwroff", 0, 0, 'P'}, {"mode", 1, 0, 'm'}, {"user", 1, 0, 'u'}, {"group", 1, 0, 'g'}, {"reconnect", 1, 0, 3}, {0, 0, 0, 0} }; while ((c = getopt_long(argc, argv, "hvVMS:r:s:RHPm:u:g:f", long_options, 0)) != EOF) { switch (c) { case 'h': Usage(argv[0]); exit(0); case 'V': case 'v': printf("%s version %s\n", argv[0], PACKAGE_VERSION); exit(0); case 'M': if (bproc_nodespec(&node_list, "master")) exit(1); break; case 'S': if (bproc_nodespec(&node_list, optarg)) exit(1); break; case 'r': err |= do_func(slave_chroot, optarg); break; case 's': err |= do_func(slave_set_status, (void *)optarg); break; case 'R': err |= do_func(slave_reboot, 0); break; case 'H': err |= do_func(slave_halt, 0); break; case 'P': err |= do_func(slave_pwroff, 0); break; case 'm': mode = check_strtol(optarg, 8); err |= do_func(slave_set_mode, (void *)(long)mode); break; case 'u': pw = getpwnam(optarg); if (pw) { id = pw->pw_uid; } else { id = strtol(optarg, &check, 0); if (*check) { fprintf(stderr, "Invalid user id: %s\n", optarg); exit(1); } } err |= do_func(slave_set_user_id, (void *)(long)id); break; case 'g': gr = getgrnam(optarg); if (gr) { id = gr->gr_gid; } else { id = strtol(optarg, &check, 0); if (*check) { fprintf(stderr, "Invalid user id: %s\n", optarg); exit(1); } } err |= do_func(slave_set_group_id, (void *)(long)id); break; case 3: if (slave_reconnect_argprocess(optarg)) { fprintf(stderr, "Invalid argument: %s\n", optarg); exit(1); } err |= do_func(slave_reconnect, &addr); break; case 'f': /* ignore silently for backward compatibility */ break; default: exit(1); } } exit(err ? 1 : 0); }