Exemple #1
0
void bear_write_message(int fd, bear_message_t const * e)
{
    write_pid(fd, e->pid);
    write_pid(fd, e->ppid);
    write_string(fd, e->fun);
    write_string(fd, e->cwd);
    write_string_array(fd, e->cmd);
}
/**
 * Store content handler information into a registry.
 *
 * @param handler description of a registering handler. Implementation MUST NOT 
 * retain pointed object
 * @return JSR211_OK if content handler registered successfully
 */
jsr211_result jsr211_register_handler(const JSR211_content_handler* handler) {
  long current_position;
  unsigned int record_size = sizeof(int);

  if (open_table_file(1) != JSR211_OK) {
    return JSR211_FAILED;
  }
  storagePosition(&io_error_message, table_file, 
                                storageSizeOf(&io_error_message, table_file));
  current_position = storageRelativePosition(&io_error_message, table_file, 0);
  storageWrite(&io_error_message, table_file, (char *)&record_size, 
                        sizeof(record_size)); /* Placeholder for record size */

  record_size += write_string(&(handler->id));
  record_size += write_int(handler->flag);
  record_size += write_int(handler->suite_id);
  record_size += write_string(&(handler->class_name));
  record_size += write_string_array(handler->type_num, handler->types);
  record_size += write_string_array(handler->suff_num, handler->suffixes);
  record_size += write_string_array(handler->act_num, handler->actions);
  record_size += write_string_array(handler->locale_num, handler->locales);
  record_size += write_string_array(handler->locale_num * handler->act_num, 
                                                           handler->action_map);
  record_size += write_string_array(handler->access_num, handler->accesses);

  storagePosition(&io_error_message, table_file, current_position);
  storageWrite(&io_error_message, table_file, (char *)&record_size, 
                                                           sizeof(record_size));
  storageRelativePosition(&io_error_message, table_file, record_size - 
                                                                   sizeof(int));
  
  close_table_file();
  return JSR211_OK;
}