char *quiz_op_get(bot_t * bot, char *name, int recnum) { xdb_pair_t *pair = NULL, *pair_2 = NULL; dlist_t *dptr; DB *db = NULL; char *str = NULL; int count; debug(bot, "quiz_op_get: Entered: %s, %i\n", name, recnum); if (!bot || !name || recnum < 0) { return NULL; } if (!dl_quiz_pairs) return NULL; if (!_strcmp(name, "*")) { dptr = dlist_node_rand(dl_quiz_pairs); if (!dptr) goto cleanup; pair = (xdb_pair_t *) dlist_data(dptr); if (!pair) goto cleanup; } else { dlist_fornext(dl_quiz_pairs, dptr) { pair = (xdb_pair_t *) dlist_data(dptr); if (!pair) continue; if (!pair->key) continue; if (!strcasecmp(pair->key, name)) { break; } pair = NULL; } }
int main(void) { ssize_t ret; unsigned char *enc; char buf[50] = { 0 }; fprintf(stderr, "Password: "******"Correct! Token is: "); print_token(buf); } else { printf("Wrong password!"); } printf("\n"); return 0; }
void set_video_mode_s(char *argp){ if(_strcmp(argp,"0")){ SetConsoleMode(0); } if(_strcmp(argp,"1")){ SetConsoleMode(1); } if(_strcmp(argp,"2")){ SetConsoleMode(2); } if(_strcmp(argp,"3")){ SetConsoleMode(3); } if(_strcmp(argp,"4")){ SetConsoleMode(4); } if(_strcmp(argp,"5")){ SetConsoleMode(5); } }
static bool _match_part_data(sinfo_data_t *sinfo_ptr, partition_info_t* part_ptr) { if (params.list_reasons) /* Don't care about partition */ return true; if (part_ptr == sinfo_ptr->part_info) /* identical partition */ return true; if ((part_ptr == NULL) || (sinfo_ptr->part_info == NULL)) return false; if (params.match_flags.partition_flag && (_strcmp(part_ptr->name, sinfo_ptr->part_info->name))) return false; if (params.match_flags.avail_flag && (part_ptr->state_up != sinfo_ptr->part_info->state_up)) return false; if (params.match_flags.groups_flag && (_strcmp(part_ptr->allow_groups, sinfo_ptr->part_info->allow_groups))) return false; if (params.match_flags.job_size_flag && (part_ptr->min_nodes != sinfo_ptr->part_info->min_nodes)) return false; if (params.match_flags.job_size_flag && (part_ptr->max_nodes != sinfo_ptr->part_info->max_nodes)) return false; if (params.match_flags.default_time_flag && (part_ptr->default_time != sinfo_ptr->part_info->default_time)) return false; if (params.match_flags.max_time_flag && (part_ptr->max_time != sinfo_ptr->part_info->max_time)) return false; if (params.match_flags.root_flag && ((part_ptr->flags & PART_FLAG_ROOT_ONLY) != (sinfo_ptr->part_info->flags & PART_FLAG_ROOT_ONLY))) return false; if (params.match_flags.share_flag && (part_ptr->max_share != sinfo_ptr->part_info->max_share)) return false; if (params.match_flags.preempt_mode_flag && (part_ptr->preempt_mode != sinfo_ptr->part_info->preempt_mode)) return false; if (params.match_flags.priority_flag && (part_ptr->priority != sinfo_ptr->part_info->priority)) return false; if (params.match_flags.max_cpus_per_node_flag && (part_ptr->max_cpus_per_node != sinfo_ptr->part_info->max_cpus_per_node)) return false; return true; }
static bool _match_node_data(sinfo_data_t *sinfo_ptr, node_info_t *node_ptr) { if (params.match_flags.hostnames_flag || params.match_flags.node_addr_flag) return false; if (sinfo_ptr->nodes && params.match_flags.features_flag && (_strcmp(node_ptr->features, sinfo_ptr->features))) return false; if (sinfo_ptr->nodes && params.match_flags.gres_flag && (_strcmp(node_ptr->gres, sinfo_ptr->gres))) return false; if (sinfo_ptr->nodes && params.match_flags.reason_flag && (_strcmp(node_ptr->reason, sinfo_ptr->reason))) return false; if (sinfo_ptr->nodes && params.match_flags.reason_timestamp_flag && (node_ptr->reason_time != sinfo_ptr->reason_time)) return false; if (sinfo_ptr->nodes && params.match_flags.reason_user_flag && node_ptr->reason_uid != sinfo_ptr->reason_uid) { return false; } if (params.match_flags.state_flag) { char *state1, *state2; state1 = node_state_string(node_ptr->node_state); state2 = node_state_string(sinfo_ptr->node_state); if (strcmp(state1, state2)) return false; } /* If no need to exactly match sizes, just return here * otherwise check cpus, disk, memory and weigth individually */ if (!params.exact_match) return true; if (params.match_flags.cpus_flag && (node_ptr->cpus != sinfo_ptr->min_cpus)) return false; if (params.match_flags.sockets_flag && (node_ptr->sockets != sinfo_ptr->min_sockets)) return false; if (params.match_flags.cores_flag && (node_ptr->cores != sinfo_ptr->min_cores)) return false; if (params.match_flags.threads_flag && (node_ptr->threads != sinfo_ptr->min_threads)) return false; if (params.match_flags.sct_flag && ((node_ptr->sockets != sinfo_ptr->min_sockets) || (node_ptr->cores != sinfo_ptr->min_cores) || (node_ptr->threads != sinfo_ptr->min_threads))) return false; if (params.match_flags.disk_flag && (node_ptr->tmp_disk != sinfo_ptr->min_disk)) return false; if (params.match_flags.memory_flag && (node_ptr->real_memory != sinfo_ptr->min_mem)) return false; if (params.match_flags.weight_flag && (node_ptr->weight != sinfo_ptr->min_weight)) return false; if (params.match_flags.cpu_load_flag && (node_ptr->cpu_load != sinfo_ptr->min_cpu_load)) return false; if (params.match_flags.version_flag && (node_ptr->version != sinfo_ptr->version)) return false; return true; }
/* * _build_sinfo_data - make a sinfo_data entry for each unique node * configuration and add it to the sinfo_list for later printing. * sinfo_list IN/OUT - list of unique sinfo_data records to report * partition_msg IN - partition info message * node_msg IN - node info message * RET zero or error code */ static int _build_sinfo_data(List sinfo_list, partition_info_msg_t *partition_msg, node_info_msg_t *node_msg) { pthread_attr_t attr_sinfo; pthread_t thread_sinfo; build_part_info_t *build_struct_ptr; node_info_t *node_ptr = NULL; partition_info_t *part_ptr = NULL; int j; g_node_scaling = node_msg->node_scaling; /* by default every partition is shown, even if no nodes */ if ((!params.node_flag) && params.match_flags.partition_flag) { part_ptr = partition_msg->partition_array; for (j=0; j<partition_msg->record_count; j++, part_ptr++) { if ((!params.partition) || (_strcmp(params.partition, part_ptr->name) == 0)) { list_append(sinfo_list, _create_sinfo( part_ptr, (uint16_t) j, NULL, node_msg->node_scaling)); } } } if (params.filtering) { for (j = 0; j < node_msg->record_count; j++) { node_ptr = &(node_msg->node_array[j]); if (node_ptr->name && _filter_out(node_ptr)) xfree(node_ptr->name); } } /* make sinfo_list entries for every node in every partition */ for (j=0; j<partition_msg->record_count; j++, part_ptr++) { part_ptr = &(partition_msg->partition_array[j]); if (params.filtering && params.partition && _strcmp(part_ptr->name, params.partition)) continue; if (node_msg->record_count == 1) { /* node_name_single */ int pos = -1; uint16_t subgrp_size = 0; hostlist_t hl; node_ptr = &(node_msg->node_array[0]); if ((node_ptr->name == NULL) || (part_ptr->nodes == NULL)) continue; hl = hostlist_create(part_ptr->nodes); pos = hostlist_find(hl, node_msg->node_array[0].name); hostlist_destroy(hl); if (pos < 0) continue; if (select_g_select_nodeinfo_get( node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBGRP_SIZE, 0, &subgrp_size) == SLURM_SUCCESS && subgrp_size) { _handle_subgrps(sinfo_list, (uint16_t) j, part_ptr, node_ptr, node_msg-> node_scaling); } else { _insert_node_ptr(sinfo_list, (uint16_t) j, part_ptr, node_ptr, node_msg-> node_scaling); } continue; } /* Process each partition using a separate thread */ build_struct_ptr = xmalloc(sizeof(build_part_info_t)); build_struct_ptr->node_msg = node_msg; build_struct_ptr->part_num = (uint16_t) j; build_struct_ptr->part_ptr = part_ptr; build_struct_ptr->sinfo_list = sinfo_list; slurm_mutex_lock(&sinfo_cnt_mutex); sinfo_cnt++; slurm_mutex_unlock(&sinfo_cnt_mutex); slurm_attr_init(&attr_sinfo); if (pthread_attr_setdetachstate (&attr_sinfo, PTHREAD_CREATE_DETACHED)) error("pthread_attr_setdetachstate error %m"); while (pthread_create(&thread_sinfo, &attr_sinfo, _build_part_info, (void *) build_struct_ptr)) { error("pthread_create error %m"); usleep(10000); /* sleep and retry */ } slurm_attr_destroy(&attr_sinfo); } slurm_mutex_lock(&sinfo_cnt_mutex); while (sinfo_cnt) { pthread_cond_wait(&sinfo_cnt_cond, &sinfo_cnt_mutex); } slurm_mutex_unlock(&sinfo_cnt_mutex); _sort_hostlist(sinfo_list); return SLURM_SUCCESS; }
/* * _build_sinfo_data - make a sinfo_data entry for each unique node * configuration and add it to the sinfo_list for later printing. * sinfo_list IN/OUT - list of unique sinfo_data records to report * partition_msg IN - partition info message * node_msg IN - node info message * RET zero or error code */ static int _build_sinfo_data(List sinfo_list, partition_info_msg_t *partition_msg, node_info_msg_t *node_msg) { node_info_t *node_ptr = NULL; partition_info_t *part_ptr = NULL; int j, j2; g_node_scaling = node_msg->node_scaling; /* by default every partition is shown, even if no nodes */ if ((!params.node_flag) && params.match_flags.partition_flag) { part_ptr = partition_msg->partition_array; for (j=0; j<partition_msg->record_count; j++, part_ptr++) { if ((!params.partition) || (_strcmp(params.partition, part_ptr->name) == 0)) { list_append(sinfo_list, _create_sinfo( part_ptr, (uint16_t) j, NULL, node_msg->node_scaling)); } } } /* make sinfo_list entries for every node in every partition */ for (j=0; j<partition_msg->record_count; j++, part_ptr++) { part_ptr = &(partition_msg->partition_array[j]); if (params.filtering && params.partition && _strcmp(part_ptr->name, params.partition)) continue; j2 = 0; while (part_ptr->node_inx[j2] >= 0) { int i2 = 0; uint16_t subgrp_size = 0; for (i2 = part_ptr->node_inx[j2]; i2 <= part_ptr->node_inx[j2+1]; i2++) { if (i2 >= node_msg->record_count) { /* This can happen if info for single * node name is loaded */ break; } node_ptr = &(node_msg->node_array[i2]); if ((node_ptr->name == NULL) || (params.filtering && _filter_out(node_ptr))) continue; if (select_g_select_nodeinfo_get( node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBGRP_SIZE, 0, &subgrp_size) == SLURM_SUCCESS && subgrp_size) { _handle_subgrps(sinfo_list, (uint16_t) j, part_ptr, node_ptr, node_msg-> node_scaling); } else { _insert_node_ptr(sinfo_list, (uint16_t) j, part_ptr, node_ptr, node_msg-> node_scaling); } } j2 += 2; } } _sort_hostlist(sinfo_list); return SLURM_SUCCESS; }
int strcmp(const char *s1, const char *s2) { return _strcmp(s1, s2); }