/* code to create classes C and D */ static void setup_classes() { #ifdef TAGGING pyobj zero = inject_int(0); pyobj one = inject_int(1); #else pyobj zero = create_int(0); pyobj one = create_int(1); #endif pyobj list0 = create_list(zero); pyobj list1 = create_list(one); // class C: // def m(self): // return self.f C = create_class(list0); // Add method m to the class. set_attr(C, "m", create_closure(C_m, list0)); // class D(C): // def m(self): // return self.f + 1 set_subscript(list1, zero, C); // list1[0] = C D = create_class(list1); pyobj D_m_closure = create_closure(D_m, list0); set_attr(D, "m", create_closure(D_m, list0)); pyobj D_n_closure = create_closure(D_n, list0); set_attr(D, "n", create_closure(D_n, list0)); }
static CK_RV sc_pkcs11_secret_key_set_attribute(struct sc_pkcs11_session *session, void *object, CK_ATTRIBUTE_PTR attr) { struct pkcs11_secret_key *key; CK_OBJECT_CLASS ck_class; CK_KEY_TYPE ck_key_type; CK_BBOOL ck_bbool; key = (struct pkcs11_secret_key *) object; switch (attr->type) { case CKA_CLASS: set_attr(ck_class, attr); if (ck_class != CKO_SECRET_KEY) return CKR_ATTRIBUTE_VALUE_INVALID; break; case CKA_KEY_TYPE: set_attr(ck_key_type, attr); if (ck_key_type != key->type) return CKR_ATTRIBUTE_VALUE_INVALID; break; case CKA_LABEL: if (key->label) free(key->label); key->label = strdup((const char *) attr->pValue); break; case CKA_TOKEN: set_attr(ck_bbool, attr); if (!ck_bbool) return CKR_ATTRIBUTE_VALUE_INVALID; break; case CKA_VALUE: if (key->value) free(key->value); key->value = (CK_BYTE *) malloc(attr->ulValueLen); if (key->value == NULL) return CKR_HOST_MEMORY; key->value_len = attr->ulValueLen; memcpy(key->value, attr->pValue, key->value_len); break; case CKA_ENCRYPT: case CKA_DECRYPT: case CKA_SIGN: case CKA_VERIFY: case CKA_WRAP: case CKA_UNWRAP: case CKA_EXTRACTABLE: case CKA_ALWAYS_SENSITIVE: case CKA_NEVER_EXTRACTABLE: /* We ignore these for now, just making sure the argument * has the right size */ set_attr(ck_bbool, attr); break; default: return CKR_ATTRIBUTE_TYPE_INVALID; } return CKR_OK; }
static void fmt_color(int color, const char *prefix, const char *fmt, va_list ap) { set_attr(color); if (message_style == MESSAGE_COMPACT) fprintf(stderr, "%c%s: ", tolower((int)prefix[0]), prefix + 1); else fprintf(stderr, "** %s: ", prefix); set_attr(ANSI_RESET); paginate_msg(fmt, ap, strlen(prefix) + 5, 10, (message_style == MESSAGE_COMPACT) ? INT_MAX : PAGINATE_RIGHT); }
bool __xmlcontext::set_double(const char *name, double value) { std::stringstream ss; ss << value; std::string str = ss.str(); return set_attr(name, str.c_str()); }
bool __xmlcontext::set_llong(const char *name, long long value) { std::stringstream ss; ss << value; std::string str = ss.str(); return set_attr(name, str.c_str()); }
static int ansi_emulate_write(int fd, const void *buf, size_t count) { int rv = 0, i; const char *s = (const char *)buf; char *pos, *str; size_t len, out_len; static size_t max_len = 0; static char *mem = NULL; /* if no special treatment is required output the string as-is */ for ( i=0; i<count; ++i ) { if ( s[i] == '\033' || s[i] > 0x7f ) { break; } } if ( i == count ) { return write(fd, buf, count); } /* make a writable copy of the data and retain it for reuse */ if ( count > max_len ) { free(mem); mem = malloc(count+1); max_len = count; } memcpy(mem, buf, count); mem[count] = '\0'; pos = str = mem; /* we're writing to the console so we assume the data isn't binary */ while (*pos) { pos = strstr(str, "\033["); if (pos) { len = pos - str; if (len) { CharToOemBuff(str, str, len); out_len = write(fd, str, len); rv += out_len; if (out_len < len) return rv; } str = pos + 2; rv += 2; pos = (char *)set_attr(str); rv += pos - str; str = pos; } else { len = strlen(str); rv += len; CharToOem(str, str); write(fd, str, len); return rv; } } return rv; }
PUBLIC L4_msg_tag Vlog::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f, Utcb const *r_msg, Utcb *s_msg) { L4_msg_tag const t = f->tag(); if (t.proto() == L4_msg_tag::Label_irq) return Icu_h<Vlog>::icu_invoke(ref, rights, f, r_msg, s_msg); else if (t.proto() != L4_msg_tag::Label_log) return commit_result(-L4_err::EBadproto); switch (r_msg->values[0]) { case 0: log_string(f, r_msg); return no_reply(); case 2: // set attr return set_attr(rights, f, r_msg); case 3: // get attr return get_attr(rights, f, s_msg); default: return get_input(rights, f, s_msg); } }
static int ansi_emulate(const char *str, FILE *stream) { int rv = 0; const char *pos = str; fflush(stream); while (*pos) { pos = strstr(str, "\033["); if (pos) { int len = (int) (pos - str); if (len) { int out_len = write_console(str, len); rv += out_len; if (out_len < len) return rv; } str = pos + 2; rv += 2; pos = set_attr(str); rv += (int) (pos - str); str = pos; } else { int len = (int) strlen(str); rv += write_console(str, len); return rv; } } return rv; }
static int ansi_emulate(const char *str, FILE *stream) { int rv = 0; const char *pos = str; while (*pos) { pos = strstr(str, "\033["); if (pos) { size_t len = pos - str; if (len) { size_t out_len = fwrite(str, 1, len, stream); rv += out_len; if (out_len < len) return rv; } str = pos + 2; rv += 2; fflush(stream); pos = set_attr(str); rv += pos - str; str = pos; } else { rv += strlen(str); fputs(str, stream); return rv; } } return rv; }
/*---------------------------------------------------------------------------*/ int neighbor_attr_add_neighbor(const rimeaddr_t *addr) { struct neighbor_attr *def; struct neighbor_addr *item; struct neighbor_addr *ptr; struct neighbor_addr *oldest = NULL; clock_time_t oldest_time; uint16_t i; if(neighbor_attr_has_neighbor(addr)) { return 0; } if(node_id_from_rimeaddr(addr) == 0) { return 0; } item = memb_alloc(&neighbor_addr_mem); oldest_time = clock_time(); /* no space available for new entry, look for oldest entry and take its place */ if(item == NULL) { item = list_head(neighbor_addrs); while(item != NULL) { if(item->last_lookup < oldest_time) { oldest = item; oldest_time = item->last_lookup; } item = item->next; } if(oldest != NULL) { item = oldest; } else { return -1; } } else { list_push(neighbor_addrs, item); } item->time = 0; item->last_lookup = clock_time(); rimeaddr_copy(&item->addr, addr); /* look up index and set default values */ ptr = neighbor_addr_mem.mem; for(i = 0; i < neighbor_addr_mem.num; ++i) { if(&ptr[i] == item) { break; } } item->index = i; for(def = list_head(neighbor_attrs); def != NULL; def = def->next) { set_attr(def, i); } return 1; }
void node::set_or_erase_attr(const std::string& key, const std::string& value) { if(value.empty() == false) { set_attr(key,value); } else { attr_.erase(key); } }
void init_screen(void) { fb = (void *)0xb8000; set_attr(CONS_BLACK, CONS_WHITE); clear_fb(); x = 0; y = 0; }
/* * def n(self, x): self.f = x; return None */ pyobj D_n(pyobj self, pyobj x) { set_attr(self, "f", x); #ifdef TAGGING return inject_big(0); /* None */ #else return NULL; #endif }
void set_attr (xml::element& element ,std::string const& name ,int value ) { set_attr(element, name, value_cast<std::string>(value)); }
int main(int argc, char **argv) { int input=-1; printf("\n===============WELCOME TO THE TEST INTERFACE TO VERIFY THE IPC================\n"); //list_receiver(1); while(1) { printf("\n -----Available Operations--- \n"); printf("\n 1. MESSAGE QUEUE Creation \n"); //this calls to the mq_open printf(" 2. Register Sender in the queue \n"); //this calls the msender system call printf(" 3. Register Receiver in the queue \n"); //this call the mreceiver system call printf(" 4. Send a message using the system call mq_send \n"); // This calls the mq_send system call printf(" 5. Clear and Close Message Queue\n"); //This calls the mq_close system call printf(" 6. Get Attributes of the message queue \n"); printf(" 7. Set Attributes of the message queue \n");//this calls to the mq_getattr system call printf(" 8. Notify system call \n"); printf(" 0. Exit the Program \n"); printf("Choose the operation you want to perform \t "); scanf(" %d",&input); switch(input) { case 1: list_queue(); break; case 2: list_sender(); break; case 3: list_receiver(0); break; case 4: mess_send(); //sender can be created dynamically also. break; case 5: message_clean(); break; case 6: get_attr(); break; case 7: set_attr(); break; case 8 : reqnotify(); break; case 0: exit(0); break; default : printf("\nIncorrect input. Try again. \n"); break; } } }
static void print_strings() { const int dx = rl.max_entry_len + 1 + (rl.suffix ? 1 : 0); set_attr(0); for(int row = 0; row < max_names_per_col; row++) { move_cursor(row, 0); clear_to_eol(); if (row < NAMES_PER_COL(page)) { for(int col = 0; col < NAMES_PER_LINE(page); col++) { if (PXY2N(page,col,row) < rl.cur_entries) { move_cursor(row, col * dx); const char * const p = rl.entries[PXY2N(page,col,row)]; if (rl.suffix) set_attr(p[strlen(p) - 1] == rl.suffix ? BOLD : 0); output_string(p, io_utf8); } } } } }
void set_aux(nfs_fh3 fh, fattr3 fat, char *path, int size) { sattr3 s; s.atime.set_atime_u.atime = fat.atime; s.gid.set_gid3_u.gid = fat.gid; s.mode.set_mode3_u.mode = fat.mode; s.mtime.set_mtime_u.mtime = fat.mtime; s.size.set_size3_u.size = size; s.uid.set_uid3_u.uid = fat.uid; set_attr(path, fh, s); }
static void print_strings() { int row,col; const char *p; set_attr(0); for(row = 0; row < max_names_per_col; row++) { move_cursor(row, 0); clear_to_eol(); if (row < NAMES_PER_COL(page)) { for(col = 0; col < NAMES_PER_LINE(page); col++) { if (PXY2N(page,col,row) < num_entries) { move_cursor(row, col * max_name_len); p = entries[PXY2N(page,col,row)]; if (mark_char) set_attr(p[strlen(p) - 1] == mark_char ? BOLD : 0); output_string(p, io_utf8); } } } } }
void metawriter_save(const metawriter_ptr &metawriter, ptree &metawriter_node, bool explicit_defaults) { metawriter_json *json = dynamic_cast<metawriter_json *>(metawriter.get()); if (json) { set_attr(metawriter_node, "type", "json"); std::string const& filename = path_processor_type::to_string(*(json->get_filename())); if (!filename.empty() || explicit_defaults) { set_attr(metawriter_node, "file", filename); } } metawriter_inmem *inmem = dynamic_cast<metawriter_inmem *>(metawriter.get()); if (inmem) { set_attr(metawriter_node, "type", "inmem"); } if (!metawriter->get_default_properties().empty() || explicit_defaults) { set_attr(metawriter_node, "default-output", metawriter->get_default_properties().to_string()); } }
/* * ptyからの出力strを端末に出力する * エスケープシーケンスを含む場合がある */ void put_pty_str(const char *str, int len) { if (len == 0) { return; } change_attr(&s_attr, &s_attr_pty); /* put_exit_uim_mode(); */ write(g_win_out, str, len); set_attr(str, len); g_commit = FALSE; s_cursor.row = s_cursor.col = UNDEFINED; debug(("<put_pty_str \"%s\">", str)); }
/*---------------------------------------------------------------------------*/ int neighbor_attr_register(struct neighbor_attr *def) { struct neighbor_addr *addr; list_push(neighbor_attrs, def); /* set default values for already existing neighbors */ for(addr = list_head(neighbor_addrs); addr != NULL; addr = addr->next) { set_attr(def, addr->index); } return 1; }
input_state* input_init(void) { input_state *input; input = malloc(sizeof(input_state)); input->history_current = input->history_first = NULL; input->cursor = 0; history_load(input); history_add(input); set_attr(input); reset_term(input, false); return input; }
CK_RV sc_pkcs11_create_secret_key(struct sc_pkcs11_session *session, const u8 *value, size_t value_len, CK_ATTRIBUTE_PTR _template, CK_ULONG attribute_count, struct sc_pkcs11_object **out) { struct pkcs11_secret_key *key; CK_ATTRIBUTE_PTR attr; int n, rv; key = (struct pkcs11_secret_key *) calloc(1, sizeof(*key)); if (!key) return CKR_HOST_MEMORY; key->value = (CK_BYTE *) malloc(value_len); if (!key->value) { pkcs11_secret_key_ops.release(key); return CKR_HOST_MEMORY; /* XXX correct? */ } memcpy(key->value, value, value_len); key->value_len = value_len; key->object.ops = &pkcs11_secret_key_ops; /* Make sure the key type is given in the template */ for (n = attribute_count, attr = _template; n--; attr++) { if (attr->type == CKA_KEY_TYPE) { set_attr(key->type, attr); break; } } if (n < 0) { pkcs11_secret_key_ops.release(key); return CKR_TEMPLATE_INCOMPLETE; } /* Set all the other attributes */ for (n = attribute_count, attr = _template; n--; attr++) { rv = key->object.ops->set_attribute(session, key, attr); if (rv != CKR_OK) { pkcs11_secret_key_ops.release(key); return rv; } } *out = (struct sc_pkcs11_object *) key; return CKR_OK; }
static Cyg_ErrNo termios_set_config(cyg_io_handle_t handle, cyg_uint32 key, const void *buf, cyg_uint32 *len) { cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; struct termios_private_info *priv = (struct termios_private_info *)t->priv; cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle; Cyg_ErrNo res = ENOERR; switch (key) { case CYG_IO_SET_CONFIG_TERMIOS: { setattr_struct *attr = (setattr_struct *)buf; int optact = attr->optact; if ( *len != sizeof( *attr ) ) { return -EINVAL; } CYG_ASSERT( (optact == TCSAFLUSH) || (optact == TCSADRAIN) || (optact == TCSANOW), "Invalid optact" ); cyg_drv_mutex_lock( &priv->lock ); if ( ( TCSAFLUSH == optact ) || ( TCSADRAIN == optact ) ) { res = cyg_io_get_config( chan, CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN, NULL, NULL ); CYG_ASSERT( ENOERR == res, "Drain request failed" ); } if ( TCSAFLUSH == optact ) { res = cyg_io_get_config( chan, CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH, NULL, NULL ); CYG_ASSERT( ENOERR == res, "Flush request failed" ); } res = set_attr( attr->termios_p, priv ); cyg_drv_mutex_unlock( &priv->lock ); return res; } default: // Pass on to serial driver res = cyg_io_set_config(chan, key, buf, len); } return res; }
int tty_sync_error(void) { int ch, trouble, ack; trouble = FALSE; for (;;) { tt_putp(tty_ENQ); /* send ENQ */ ch = getnext(STRIP_PARITY); event_start(TIME_SYNC); /* start the timer */ /* The timer doesn't start until we get the first character. After that I expect to get the remaining characters of the acknowledge string in a short period of time. If that is not true then these characters are coming from the user and we need to send the ENQ sequence out again. */ for (ack = 0; ; ) { if (ack < TTY_ACK_SIZE - 2) { tty_ACK[ack] = ch; tty_ACK[ack + 1] = '\0'; } if (ch == ACK_terminator) { return trouble; } if (++ack >= ACK_length) { return trouble; } ch = getnext(STRIP_PARITY); if (event_time(TIME_SYNC) > 400000) { break; } } set_attr(0); /* just in case */ put_crlf(); if (trouble) { /* The terminal won't sync. Life is not good. */ return TRUE; } put_str(" -- sync -- "); trouble = TRUE; } }
void about(void) { set_attr(0); clear_entire_screen(); displaying_info = true; int i; for(i = 0; NO_WARRANTY_msg[i]; i++) { if (i == ne_lines - 1) break; move_cursor(i, 0); output_string(NO_WARRANTY_msg[i], false); } reset_window(); char t[256] = ABOUT_MSG " Global directory"; char * const gprefs_dir = exists_gprefs_dir(); if (gprefs_dir) strncat(strncat(t, ": ", sizeof t - 1), gprefs_dir, sizeof t - 1); else strncat(strncat(strncat(t, " ", sizeof t - 1), get_global_dir(), sizeof t - 1), " not found!", sizeof t - 1); print_message(t); }
R_API void r_cons_canvas_write(RConsCanvas *c, const char *s) { char *p, ch; int orig_x, x; int left, slen, attr_len, piece_len; if (!c || !s || !*s) { return; } /* split the string into pieces of non-ANSI chars and print them normally, ** using the ANSI chars to set the attr of the canvas */ orig_x = c->x; do { const char *s_part = set_attr (c, s); ch = 0; piece_len = get_piece (s_part, &ch); if (piece_len == 0 && ch == '\0' && s_part == s) { break; } left = 0; p = prefixline (c, &left); slen = R_MIN (left, piece_len); attr_len = slen <= 0 && s_part != s? 1: slen; if (attr_len > 0) { stamp_attr (c, attr_len); } x = c->x - c->sx; if (G (x, c->y - c->sy)) { memcpy (p, s_part, slen); } s = s_part; if (ch == '\n') { c->y++; c->x = orig_x; s++; if (*s == '\0') { break; } } else { c->x += slen; } s += piece_len; } while (*s); c->x = orig_x; }
int main(int argc, char *argv[]) { int fd; char buf[1024]; int numRead; if ((fd = open("/dev/ttyUSB0", O_RDONLY)) == -1) errExit("open"); set_attr(fd); while (1) { if ((numRead = read(fd, buf, 1024)) > 0) write(STDOUT_FILENO, buf, numRead); sleep(1); } }
SETATTR3res *nfsproc3_setattr_3_svc(SETATTR3args * argp, struct svc_req * rqstp) { static SETATTR3res result; pre_op_attr pre; char *path; PREP(path, argp->object); pre = get_pre_cached(); result.status = join(in_sync(argp->guard, pre), exports_rw()); if (result.status == NFS3_OK) result.status = set_attr(path, argp->object, argp->new_attributes); /* overlaps with resfail */ result.SETATTR3res_u.resok.obj_wcc.before = pre; result.SETATTR3res_u.resok.obj_wcc.after = get_post_stat(path, rqstp); return &result; }
static int parse_cookie_attr( cookie c, const char* input, const char* look_for, int (*set_attr)(cookie, const char*), meta_error e) { cstring str; if( (str = cstring_new()) == NULL) return set_os_error(e, ENOMEM); else if(!get_cookie_attribute(input, look_for, str, e)) { cstring_free(str); return 0; } set_attr(c, c_str(str)); cstring_free(str); return 1; }