int op_create (const char *path, mode_t mode, struct fuse_file_info *fi) { int rt; struct ext2_vnode * vnode; ext2_filsys e2fs; FUSE_EXT2_LOCK; e2fs = current_ext2fs(); debugf("enter"); debugf("path = %s, mode: 0%o", path, mode); fi->fh = (unsigned long) (vnode = do_open(e2fs, path, fi->flags)); if (vnode != NULL) { debugf("leave"); FUSE_EXT2_UNLOCK; return 0; } rt = do_create(e2fs, path, mode, 0, NULL); if (rt != 0) { FUSE_EXT2_UNLOCK; return rt; } fi->fh = (unsigned long) (vnode = do_open(e2fs, path, fi->flags)); if (vnode == NULL) { debugf("op_open(path, fi); failed"); FUSE_EXT2_UNLOCK; return -EIO; } debugf("leave"); FUSE_EXT2_UNLOCK; return 0; }
SharedMemArray(server_mode_t, std::string const& name) : isManager(true), _name(name), _shm(do_create(_name.c_str())), _region(_shm, bip::read_write) { _data = new (_region.get_address()) data_t; }
hts_engine_impl::pointer hts_engine_impl::create() const { pointer p=do_create(); p->load_configs(); p->do_initialize(); return p; }
int op_create (const char *path, mode_t mode, struct fuse_file_info *fi) { int rt; ext2_filsys e2fs = current_ext2fs(); debugf("enter"); debugf("path = %s, mode: 0%o", path, mode); if (op_open(path, fi) == 0) { debugf("leave"); return 0; } rt = do_create(e2fs, path, mode, 0, NULL); if (rt != 0) { return rt; } if (op_open(path, fi)) { debugf("op_open(path, fi); failed"); return -EIO; } debugf("leave"); return 0; }
mmAttachmentDialog::mmAttachmentDialog (wxWindow* parent, const wxString& RefType, int RefId) : m_attachment_id(-1) , m_RefType(RefType) , m_RefId(RefId) #ifdef _DEBUG , debug_(true) #else , debug_(false) #endif { if (debug_) ColName_[ATTACHMENT_ID] = _("#"); ColName_[ATTACHMENT_DESCRIPTION] = _("Description"); ColName_[ATTACHMENT_FILENAME] = _("File"); do_create(parent); const wxString AttachmentsFolder = mmex::getPathAttachment(mmAttachmentManage::InfotablePathSetting()); if (AttachmentsFolder == wxEmptyString) { wxString msgStr = wxString() << _("Attachment folder not defined.") << "\n" << _("Please set it in Tools -> Options -> Attachments") << "\n"; wxMessageBox(msgStr, _("Attachment folder not defined"), wxICON_ERROR); } else if (!wxDirExists(AttachmentsFolder)) { wxString msgStr = wxString() << _("Unable to find attachments folder:") << "\n" << "'" << AttachmentsFolder << "'" << "\n" << "\n" << _("Please verify that above path is correct") << "\n"; wxMessageBox(msgStr, _("Attachments folder not found"), wxICON_ERROR); } }
static int rootfs_symlink(void *_ns, void *_dir, const char *name, const char *path) { nspace *ns; vnode *dir; int err; char *buf; vnode *vn; ns = (nspace *) _ns; dir = (vnode *) _dir; buf = (char *) malloc(strlen(path)+1); if (!buf) { err = ENOMEM; goto error1; } strcpy(buf, path); LOCK(ns->lock); err = do_create(ns, dir, name, MY_S_IFLNK, &vn); if (err) goto error2; vn->symlink = buf; UNLOCK(ns->lock); return 0; error2: UNLOCK(ns->lock); error1: return err; }
/** * l_nbranch (lower nbranch than nbranch) is write protected, create the dir path on * nbranch for an other COW operation. */ int path_create(const char *path, int nbranch_ro, int nbranch_rw) { DBG("%s\n", path); if (!uopt.cow_enabled) RETURN(0); char p[PATHLEN_MAX]; if (BUILD_PATH(p, uopt.branches[nbranch_rw].path, path)) RETURN(-ENAMETOOLONG); struct stat st; if (!stat(p, &st)) { // path does already exists, no need to create it RETURN(0); } char *walk = (char *)path; // first slashes, e.g. we have path = /dir1/dir2/, will set walk = dir1/dir2/ while (*walk == '/') walk++; do { // walk over the directory name, walk will now be /dir2 while (*walk != '\0' && *walk != '/') walk++; // +1 due to \0, which gets added automatically snprintf(p, (walk - path) + 1, "%s", path); // walk - path = strlen(/dir1) int res = do_create(p, nbranch_ro, nbranch_rw); if (res) RETURN(res); // creating the directory failed // as above the do loop, walk over the next slashes, walk = dir2/ while (*walk == '/') walk++; } while (*walk != '\0'); RETURN(0); }
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { LLInventoryModel* model = mPtr->getPanel()->getModel(); if(!model) return false; std::string type = userdata.asString(); do_create(model, mPtr->getPanel(), type); return true; }
mmWebAppDialog::mmWebAppDialog(wxWindow *parent) : m_webtran_id(-1) , m_maskTextCtrl() , webtranListBox_() , refreshRequested_(false) { do_create(parent); }
void task_fs(){ #ifdef DEBUG_FS printl("in task_fs\n"); #endif init_fs(); MESSAGE message; memset(&message,0,sizeof(message)); while(TRUE){ send_receive(RECEIVE,ANY,&message); int source_pid=message.source_pid; int fd; switch(message.type){ case INFO_FS_CREATE: message.res_bool=do_create(&message); break; case INFO_FS_UNLINK: message.res_bool=do_unlink(&message); break; case INFO_FS_LS: message.res_int=do_ls(&message); break; case INFO_FS_OPEN: fd=do_open(&message); message.fd=fd; break; case INFO_FS_READ: do_read(&message); break; case INFO_FS_WRITE: do_write(&message); break; case INFO_FS_SEEK: do_seek(&message); break; case INFO_FS_CLOSE: message.res_int=do_close(&message); break; default: printl("\n\n\nunknown message type:%d\n",message.type); assert(FALSE,"unknown message type!"); } if(message.type!=INFO_SUSPEND_PROCESS){ send_receive(SEND,source_pid,&message); }else{ printl("inof_suspend_process\n"); } } #ifndef _FS_H_ #define _FS_H_ #endif /* _FS_H_ */ while(1) ; spin("never here"); }
/* Really create the quadtree */ static quadtree_node do_create(float tlx, float tly, float brx, float bry, unsigned int level) { quadtree_node root; float midx = (brx+tlx)/2.0f; float midy = (bry+tly)/2.0f; if(level == 0) return NULL; root = calloc(1, sizeof(struct s_quadtree_node)); bbox2d_set(&root->box, tlx, tly, brx, bry); root->childs[0] = do_create(tlx, tly, midx, midy, level-1); root->childs[1] = do_create(midx, tly, brx, midy, level-1); root->childs[2] = do_create(tlx, midy, midx, bry, level-1); root->childs[3] = do_create(midx, midy, brx, bry, level-1); return root; }
Displayable::Displayable(Scene *s) : scene(s) { // Initialize scaling and other transformations, since we're a parent parent = NULL; scale = 1; globt[0] = globt[1] = globt[2] = 0; centt[0] = centt[1] = centt[2] = 0; // get values for this items as default values isOn = TRUE; doCent = doRot = doGlob = doScale = TRUE; do_create(); }
int op_mknod (const char *path, mode_t mode, dev_t dev) { int rt; ext2_filsys e2fs = current_ext2fs(); debugf("enter"); debugf("path = %s 0%o", path, mode); rt = do_create(e2fs, path, mode, dev, NULL); debugf("leave"); return rt; }
// ===================================================================================================================== static void terminal_handler(struct ipc_message* msg) { switch (msg->data[0]) { case MSG_TERMINAL_CREATE : do_create(msg); break; default : // let the async device manager library handle the rest libdevman_client_async_process(msg); break; } }
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { LLInventoryModel* model = mPtr->getPanel()->getModel(); if(!model) return false; std::string type = userdata.asString(); // <edit> if(type == "pretend") { LLFloaterNewLocalInventory* floater = new LLFloaterNewLocalInventory(); floater->center(); } else // </edit> do_create(model, mPtr->getPanel(), type); return true; }
static int rootfs_mkdir(void *_ns, void *_dir, const char *name, int perms) { nspace *ns; vnode *dir; int err; vnode *vn; ns = (nspace *) _ns; dir = (vnode *) _dir; LOCK(ns->lock); err = do_create(ns, dir, name, (perms & ~MY_S_IFMT) | MY_S_IFDIR, &vn); UNLOCK(ns->lock); return err; }
/** * * Creates path in the rw branch recursively (allows to modify each new dir created easier) * to create a full path, call this with path == walk ! * This version maintain the timestamps of all the path * path: path to be created in the rw branch * walk: how "far" the copy has been done * nbranch_ro: number of branch used as ro * nbranch_rw: number of branch used as rw */ int path_create_by_step(const char * path , const char * walk, int nbranch_ro, int nbranch_rw) { char p[PATHLEN_MAX]; while (*walk != '\0' && *walk == '/') walk++; if(*walk == '\0') RETURN(0); while (*walk != '\0' && *walk != '/') walk++; // +1 due to \0, which gets added automatically snprintf(p, (walk - path) + 1, "%s", path); // walk - path = strlen(/dir1) int res = do_create(p, nbranch_ro, nbranch_rw); if (res) RETURN(res); // creating the directory failed res = path_create_by_step(path, walk, nbranch_ro, nbranch_rw); if (res) RETURN(res); res = copy_ro_rw_stat(p, nbranch_ro, nbranch_rw); RETURN(res); }
static void e_book_backend_vcf_create_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *vcard, EContact **contact, GError **perror) { EBookBackendVCF *bvcf = E_BOOK_BACKEND_VCF (backend); *contact = do_create(bvcf, vcard, TRUE); if (!*contact) { /* XXX need a different call status for this case, i think */ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND)); } }
SCM scm_mmr_create_this_path(SCM path ,SCM mode) #define FUNC_NAME "create-this-path" { char *p = NULL; char *b = NULL; char *buf = NULL; SCM ret = SCM_BOOL_F; int m = 0777; int len = 0; int n = 0; SCM_VALIDATE_STRING(1 ,path); if(!SCM_UNBNDP(mode)) { SCM_VALIDATE_NUMBER(2 ,mode); m = scm_to_int(mode); } scm_dynwind_begin(0); p = scm_to_locale_string(path); scm_dynwind_free(p); len = strlen(p); buf = (char*)malloc(len+1); // Don't forget +1 for '\0' n = get_path_levels(p ,len); while(n >= 0) { int l = 0; b = get_parent_path(p ,&n ,len); l = b-p; memcpy(buf ,b ,l); buf[l+1] = '\0'; do_create(buf ,len); } free(buf); buf = NULL; scm_dynwind_end(); return ret; }
int main(int argc, char **argv) { int rv = SUCCESS; (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */ #endif (void) textdomain(TEXT_DOMAIN); /* Running from within a non-global zone is not supported yet. */ if (getzoneid() != GLOBAL_ZONEID) { (void) fprintf(stderr, gettext("Error: Configuring KSSL from within a non-global " "zone is not supported.\nPlease run the command from " "the global zone.\n")); return (ERROR_USAGE); } if (argc < 2) { usage_all(); return (ERROR_USAGE); } if (strcmp(argv[1], "create") == 0) { rv = do_create(argc, argv); } else if (strcmp(argv[1], "delete") == 0) { rv = do_delete(argc, argv); } else if (strcmp(argv[1], "-V") == 0) { (void) printf("%s\n", KSSLCFG_VERSION); } else if (strcmp(argv[1], "-?") == 0) { usage_all(); } else { (void) fprintf(stderr, gettext("Error: Unknown subcommand -- %s\n"), argv[1]); usage_all(); rv = ERROR_USAGE; } return (rv); }
static int oid_module_init(CONF_IMODULE *md, const CONF *cnf) { int i; const char *oid_section; STACK_OF(CONF_VALUE) *sktmp; CONF_VALUE *oval; oid_section = CONF_imodule_get_value(md); if (!(sktmp = NCONF_get_section(cnf, oid_section))) { ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION); return 0; } for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { oval = sk_CONF_VALUE_value(sktmp, i); if (!do_create(oval->value, oval->name)) { ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT); return 0; } } return 1; }
/** * l_nbranch (lower nbranch than nbranch) is write protected, create the dir path on * nbranch for an other COW operation. */ int path_create(const char *path, int nbranch_ro, int nbranch_rw) { DBG_IN(); if (!uopt.cow_enabled) return 0; if (strlen(path) + strlen(uopt.branches[nbranch_rw].path) > PATHLEN_MAX || strlen(path) + strlen(uopt.branches[nbranch_ro].path) > PATHLEN_MAX) { // TODO: how to handle that? return 1; } char p[PATHLEN_MAX]; snprintf(p, PATHLEN_MAX, "%s%s", uopt.branches[nbranch_rw].path, path); struct stat st; if (!stat(p, &st)) { // path does already exists, no need to create it return 0; } char *walk = (char *)path; // first slashes, e.g. we have path = /dir1/dir2/, will set walk = dir1/dir2/ while (*walk != '\0' && *walk == '/') walk++; do { // walk over the directory name, walk will now be /dir2 while (*walk != '\0' && *walk != '/') walk++; // +1 due to \0, which gets added automatically snprintf(p, (walk - path) + 1, "%s", path); // walk - path = strlen(/dir1) int res = do_create(p, nbranch_ro, nbranch_rw); if (res) return res; // creating the directory failed // as above the do loop, walk over the next slashes, walk = dir2/ while (*walk != '\0' && *walk == '/') walk++; } while (*walk != '\0'); return 0; }
Displayable::Displayable(Displayable *pops) : scene(pops->scene) { _needUpdate = 1; // default to needing an update parent = pops; // get copies of all of parents tranformation matrices from parent vec_copy(centt, parent->centt); rotm = parent->rotm; vec_copy(globt, parent->globt); scale = parent->scale; tm = parent->tm; isOn = parent->displayed(); doCent = parent->doCent; doRot = parent->doRot; doGlob = parent->doGlob; doScale = parent->doScale; // do common creation action do_create(); // take initial material settings from parent cmdList->ambient = parent->cmdList->ambient; cmdList->specular = parent->cmdList->specular; cmdList->diffuse = parent->cmdList->diffuse; cmdList->shininess = parent->cmdList->shininess; cmdList->mirror = parent->cmdList->mirror; cmdList->opacity = parent->cmdList->opacity; cmdList->outline = parent->cmdList->outline; cmdList->outlinewidth = parent->cmdList->outlinewidth; cmdList->transmode = parent->cmdList->transmode; cmdList->materialtag = parent->cmdList->materialtag; // inherit cacheability from parent cmdList->cacheskip = parent->cmdList->cacheskip; // finally, add this Displayable as a child to the parent parent->add_child(this); }
epoller(io_service* io_service) : ep_handle_(do_create()), io_service_(io_service) { };
int main (int argc, char **argv) { int exit = 0; char *buffer = g_new (char, 1024) ; GIOChannel *ioc; guint watch_id = 0; GOptionContext *ctx = NULL; GError *error = NULL; /* default to interactive on a terminal */ interactive = isatty (0); ctx = g_option_context_new("test-vfs"); g_option_context_add_main_entries(ctx, options, NULL); if (!g_option_context_parse(ctx, &argc, &argv, &error)) { g_printerr("main: %s\n", error->message); g_error_free(error); g_option_context_free(ctx); return 1; } g_option_context_free(ctx); files = g_hash_table_new (g_str_hash, g_str_equal); if (noninteractive) interactive = FALSE; if (interactive) vfserr = stderr; else vfserr = stdout; if (!mate_vfs_init ()) { fprintf (vfserr, "Cannot initialize mate-vfs.\n"); return 1; } mate_vfs_module_callback_push (MATE_VFS_MODULE_CALLBACK_AUTHENTICATION, authentication_callback, NULL, NULL); if (argc == 1) cur_dir = g_get_current_dir (); else cur_dir = g_strdup(argv[1]); if (cur_dir && !G_IS_DIR_SEPARATOR (cur_dir [strlen (cur_dir) - 1])) cur_dir = g_strconcat (cur_dir, G_DIR_SEPARATOR_S, NULL); if (interactive == TRUE) { main_loop = g_main_loop_new (NULL, TRUE); ioc = g_io_channel_unix_new (0 /* stdin */); g_io_channel_set_encoding (ioc, NULL, NULL); g_io_channel_set_buffered (ioc, FALSE); watch_id = g_io_add_watch (ioc, G_IO_IN | G_IO_HUP | G_IO_ERR, callback, buffer); g_io_channel_unref (ioc); } while (!exit) { char *ptr; if (interactive) { fprintf (stdout,"\n%s > ", cur_dir); fflush (stdout); strcpy (buffer, ""); g_main_loop_run (main_loop); } else { /* In non-interactive mode we just do this evil * thingie */ buffer[0] = '\0'; fgets (buffer, 1023, stdin); if (!buffer [0]) { exit = 1; continue; } } if (!buffer || buffer [0] == '#') continue; arg_data = g_strsplit (g_strchomp (buffer), delim, -1); arg_cur = 0; if ((!arg_data || !arg_data[0]) && interactive) continue; if (!interactive) printf ("Command : '%s'\n", arg_data [0]); ptr = arg_data[arg_cur++]; if (!ptr) continue; if (g_ascii_strcasecmp (ptr, "ls") == 0) do_ls (); else if (g_ascii_strcasecmp (ptr, "cd") == 0) do_cd (); else if (g_ascii_strcasecmp (ptr, "dump") == 0) do_dump (); else if (g_ascii_strcasecmp (ptr, "type") == 0 || g_ascii_strcasecmp (ptr, "cat") == 0) do_cat (); else if (g_ascii_strcasecmp (ptr, "cp") == 0) do_cp (); else if (g_ascii_strcasecmp (ptr, "rm") == 0) do_rm (); else if (g_ascii_strcasecmp (ptr, "mkdir") == 0) do_mkdir (); else if (g_ascii_strcasecmp (ptr, "rmdir") == 0) do_rmdir (); else if (g_ascii_strcasecmp (ptr, "mv") == 0) do_mv (); else if (g_ascii_strcasecmp (ptr, "info") == 0 || g_ascii_strcasecmp (ptr, "stat") == 0) do_info (); else if (g_ascii_strcasecmp (ptr, "findtrash") == 0) do_findtrash (); else if (g_ascii_strcasecmp (ptr, "ssl") == 0) do_ssl (); else if (g_ascii_strcasecmp (ptr, "sync") == 0) fprintf (vfserr, "a shell is like a boat, it lists or syncs (RMS)\n"); else if (g_ascii_strcasecmp (ptr,"help") == 0 || g_ascii_strcasecmp (ptr,"?") == 0 || g_ascii_strcasecmp (ptr,"info") == 0 || g_ascii_strcasecmp (ptr,"man") == 0) list_commands (); else if (g_ascii_strcasecmp (ptr,"exit") == 0 || g_ascii_strcasecmp (ptr,"quit") == 0 || g_ascii_strcasecmp (ptr,"q") == 0 || g_ascii_strcasecmp (ptr,"bye") == 0) exit = 1; /* File ops */ else if (g_ascii_strcasecmp (ptr, "open") == 0) do_open (); else if (g_ascii_strcasecmp (ptr, "create") == 0) do_create (); else if (g_ascii_strcasecmp (ptr, "close") == 0) do_close (); else if (g_ascii_strcasecmp (ptr, "handleinfo") == 0) do_handleinfo (); else if (g_ascii_strcasecmp (ptr, "read") == 0) do_read (); else if (g_ascii_strcasecmp (ptr, "seek") == 0) do_seek (); else fprintf (vfserr, "Unknown command '%s'", ptr); g_strfreev (arg_data); arg_data = NULL; } if (interactive) { g_source_remove (watch_id); g_main_loop_unref (main_loop); main_loop = NULL; } g_free (buffer); g_free (cur_dir); close_files (); return 0; }
int restore_line(const char *filename,uint64_t lv,char *line) { char *ptr; uint32_t ts; int status; char* errormsgs[]={ ERROR_STRINGS }; status = ERROR_MISMATCH; ptr = line; EAT(ptr,filename,lv,':'); EAT(ptr,filename,lv,' '); GETU32(ts,ptr); EAT(ptr,filename,lv,'|'); switch (*ptr) { case 'A': if (strncmp(ptr,"ACCESS",6)==0) { status = do_access(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"ATTR",4)==0) { status = do_attr(filename,lv,ts,ptr+4); } else if (strncmp(ptr,"APPEND",6)==0) { status = do_append(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"ACQUIRE",7)==0) { status = do_acquire(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"AQUIRE",6)==0) { status = do_acquire(filename,lv,ts,ptr+6); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'C': if (strncmp(ptr,"CREATE",6)==0) { status = do_create(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"CUSTOMER",8)==0) { // deprecated status = do_session(filename,lv,ts,ptr+8); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'E': if (strncmp(ptr,"EMPTYTRASH",10)==0) { status = do_emptytrash(filename,lv,ts,ptr+10); } else if (strncmp(ptr,"EMPTYRESERVED",13)==0) { status = do_emptyreserved(filename,lv,ts,ptr+13); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'F': if (strncmp(ptr,"FREEINODES",10)==0) { status = do_freeinodes(filename,lv,ts,ptr+10); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'I': if (strncmp(ptr,"INCVERSION",10)==0) { status = do_incversion(filename,lv,ts,ptr+10); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'L': if (strncmp(ptr,"LENGTH",6)==0) { status = do_length(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"LINK",4)==0) { status = do_link(filename,lv,ts,ptr+4); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'M': if (strncmp(ptr,"MOVE",4)==0) { status = do_move(filename,lv,ts,ptr+4); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'P': if (strncmp(ptr,"PURGE",5)==0) { status = do_purge(filename,lv,ts,ptr+5); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'Q': if (strncmp(ptr,"QUOTA",5)==0) { status = do_quota(filename,lv,ts,ptr+5); } break; case 'R': if (strncmp(ptr,"RELEASE",7)==0) { status = do_release(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"REPAIR",6)==0) { status = do_repair(filename,lv,ts,ptr+6); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'S': if (strncmp(ptr,"SETEATTR",8)==0) { status = do_seteattr(filename,lv,ts,ptr+8); } else if (strncmp(ptr,"SETGOAL",7)==0) { status = do_setgoal(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"SETPATH",7)==0) { status = do_setpath(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"SETTRASHTIME",12)==0) { status = do_settrashtime(filename,lv,ts,ptr+12); } else if (strncmp(ptr,"SETXATTR",8)==0) { status = do_setxattr(filename,lv,ts,ptr+8); } else if (strncmp(ptr,"SNAPSHOT",8)==0) { status = do_snapshot(filename,lv,ts,ptr+8); } else if (strncmp(ptr,"SYMLINK",7)==0) { status = do_symlink(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"SESSION",7)==0) { status = do_session(filename,lv,ts,ptr+7); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'T': if (strncmp(ptr,"TRUNC",5)==0) { status = do_trunc(filename,lv,ts,ptr+5); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'U': if (strncmp(ptr,"UNLINK",6)==0) { status = do_unlink(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"UNDEL",5)==0) { status = do_undel(filename,lv,ts,ptr+5); } else if (strncmp(ptr,"UNLOCK",6)==0) { status = do_unlock(filename,lv,ts,ptr+6); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'W': if (strncmp(ptr,"WRITE",5)==0) { status = do_write(filename,lv,ts,ptr+5); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; default: printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } if (status>STATUS_OK) { printf("%s:%"PRIu64": error: %d (%s)\n",filename,lv,status,errormsgs[status]); } return status; }
/********************************************************************/ /** * Prepares and calls do_create command. ********************************************************************** */ int do_create_cmd(int args, char* argv[]) { ARG_CHECK(args, 2); char* filename = argv[1]; args -= 2; argv += 2; uint32_t max_files = FILE_DEFAULT; uint16_t x_thumb_res = THUMB_DEFAULT; uint16_t y_thumb_res = THUMB_DEFAULT; uint16_t x_small_res = SMALL_DEFAULT; uint16_t y_small_res = SMALL_DEFAULT; // Use of int instead of size_t for the comparison with args // For each command line argument, checks if there are enough arguments // remaining, converts the arguments to integers and assigns them to the // variable, and then checks if the variable is valid. for (int i = 0; i < args; ++i) { switch (parse_create_options(argv[i])) { case MAX_FILES: OPTION_ARG_CHECK(args, i, 1); max_files = atouint32(argv[i + 1]); if (max_files == 0 || max_files > MAX_MAX_FILES) { return ERR_MAX_FILES; } i += 1; break; case THUMB_RES: OPTION_ARG_CHECK(args, i, 2); x_thumb_res = atouint16(argv[i + 1]); y_thumb_res = atouint16(argv[i + 2]); RES_CHECK(x_thumb_res, y_thumb_res, THUMB_MAX); i += 2; break; case SMALL_RES: OPTION_ARG_CHECK(args, i, 2); x_small_res = atouint16(argv[i + 1]); y_small_res = atouint16(argv[i + 2]); RES_CHECK(x_small_res, y_small_res, SMALL_MAX); i += 2; break; case INVALID_OPTION: return ERR_INVALID_ARGUMENT; } } puts("Create"); struct pictdb_header db_header = { .max_files = max_files, .res_resized = { x_thumb_res, y_thumb_res, x_small_res, y_small_res } }; struct pictdb_file db_file = {.header = db_header }; int ret = do_create(filename, &db_file); if (ret == 0) { print_header(&db_file.header); } do_close(&db_file); return ret; }
void process_command(int descr, dbref player, char *command) { char *arg1; char *arg2; char *full_command; char *p; /* utility */ char pbuf[BUFFER_LEN]; char xbuf[BUFFER_LEN]; char ybuf[BUFFER_LEN]; struct timeval starttime; struct timeval endtime; double totaltime; if (command == 0) abort(); /* robustify player */ if (player < 0 || player >= db_top || (Typeof(player) != TYPE_PLAYER && Typeof(player) != TYPE_THING)) { log_status("process_command: bad player %d", player); return; } if ((tp_log_commands || Wizard(OWNER(player)))) { if (!(FLAGS(player) & (INTERACTIVE | READMODE))) { if (!*command) { return; } log_command("%s: %s", whowhere(player), command); } else { if (tp_log_interactive) { log_command("%s: %s%s", whowhere(player), (FLAGS(player) & (READMODE)) ? "[READ] " : "[INTERP] ", command); } } } if (FLAGS(player) & INTERACTIVE) { interactive(descr, player, command); return; } /* eat leading whitespace */ while (*command && isspace(*command)) command++; /* Disable null command once past READ line */ if (!*command) return; /* check for single-character commands */ if (!tp_enable_prefix) { if (*command == SAY_TOKEN) { snprintf(pbuf, sizeof(pbuf), "say %s", command + 1); command = &pbuf[0]; } else if (*command == POSE_TOKEN) { snprintf(pbuf, sizeof(pbuf), "pose %s", command + 1); command = &pbuf[0]; } else if (*command == EXIT_DELIMITER) { snprintf(pbuf, sizeof(pbuf), "delimiter %s", command + 1); command = &pbuf[0]; } } /* profile how long command takes. */ gettimeofday(&starttime, NULL); /* if player is a wizard, and uses overide token to start line... */ /* ... then do NOT run actions, but run the command they specify. */ if (!(TrueWizard(OWNER(player)) && (*command == OVERIDE_TOKEN))) { if (can_move(descr, player, command, 0)) { do_move(descr, player, command, 0); /* command is exact match for exit */ *match_args = 0; *match_cmdname = 0; } else { if (tp_enable_prefix) { if (*command == SAY_TOKEN) { snprintf(pbuf, sizeof(pbuf), "say %s", command + 1); command = &pbuf[0]; } else if (*command == POSE_TOKEN) { snprintf(pbuf, sizeof(pbuf), "pose %s", command + 1); command = &pbuf[0]; } else if (*command == EXIT_DELIMITER) { snprintf(pbuf, sizeof(pbuf), "delimiter %s", command + 1); command = &pbuf[0]; } else { goto bad_pre_command; } if (can_move(descr, player, command, 0)) { do_move(descr, player, command, 0); /* command is exact match for exit */ *match_args = 0; *match_cmdname = 0; } else { goto bad_pre_command; } } else { goto bad_pre_command; } } } else { bad_pre_command: if (TrueWizard(OWNER(player)) && (*command == OVERIDE_TOKEN)) command++; full_command = strcpyn(xbuf, sizeof(xbuf), command); for (; *full_command && !isspace(*full_command); full_command++) ; if (*full_command) full_command++; /* find arg1 -- move over command word */ command = strcpyn(ybuf, sizeof(ybuf), command); for (arg1 = command; *arg1 && !isspace(*arg1); arg1++) ; /* truncate command */ if (*arg1) *arg1++ = '\0'; /* remember command for programs */ strcpyn(match_args, sizeof(match_args), full_command); strcpyn(match_cmdname, sizeof(match_cmdname), command); /* move over spaces */ while (*arg1 && isspace(*arg1)) arg1++; /* find end of arg1, start of arg2 */ for (arg2 = arg1; *arg2 && *arg2 != ARG_DELIMITER; arg2++) ; /* truncate arg1 */ for (p = arg2 - 1; p >= arg1 && isspace(*p); p--) *p = '\0'; /* go past delimiter if present */ if (*arg2) *arg2++ = '\0'; while (*arg2 && isspace(*arg2)) arg2++; switch (command[0]) { case '@': switch (command[1]) { case 'a': case 'A': /* @action, @armageddon, @attach */ switch (command[2]) { case 'c': case 'C': Matched("@action"); NOGUEST("@action", player); BUILDERONLY("@action", player); do_action(descr, player, arg1, arg2); break; case 'r': case 'R': if (strcmp(command, "@armageddon")) goto bad; /* WIZARDONLY("@armageddon", player); PLAYERONLY("@armageddon", player); */ do_armageddon(player, full_command); break; case 't': case 'T': Matched("@attach"); NOGUEST("@attach", player); BUILDERONLY("@attach", player); do_attach(descr, player, arg1, arg2); break; default: goto bad; } break; case 'b': case 'B': /* @bless, @boot */ switch (command[2]) { case 'l': case 'L': Matched("@bless"); WIZARDONLY("@bless", player); PLAYERONLY("@bless", player); NOFORCE("@bless", force_level, player); do_bless(descr, player, arg1, arg2); break; case 'o': case 'O': Matched("@boot"); WIZARDONLY("@boot", player); PLAYERONLY("@boot", player); do_boot(player, arg1); break; default: goto bad; } break; case 'c': case 'C': /* @chlock, @chown, @chown_lock, @clone, @conlock, @contents, @create, @credits */ switch (command[2]) { case 'h': case 'H': switch (command[3]) { case 'l': case 'L': Matched("@chlock"); NOGUEST("@chlock", player); set_standard_lock(descr, player, arg1, MESGPROP_CHLOCK, "Chown Lock", arg2); break; case 'o': case 'O': if(strlen(command) < 7) { Matched("@chown"); do_chown(descr, player, arg1, arg2); } else { Matched("@chown_lock"); NOGUEST("@chown_lock", player); set_standard_lock(descr, player, arg1, MESGPROP_CHLOCK, "Chown Lock", arg2); } break; default: goto bad; } break; case 'l': case 'L': Matched("@clone"); NOGUEST("@clone", player); BUILDERONLY("@clone", player); do_clone(descr, player, arg1); break; case 'o': case 'O': switch (command[4]) { case 'l': case 'L': Matched("@conlock"); NOGUEST("@conlock", player); set_standard_lock(descr, player, arg1, MESGPROP_CONLOCK, "Container Lock", arg2); break; case 't': case 'T': Matched("@contents"); do_contents(descr, player, arg1, arg2); break; default: goto bad; } break; case 'r': case 'R': if (string_compare(command, "@credits")) { Matched("@create"); NOGUEST("@create", player); BUILDERONLY("@create", player); do_create(player, arg1, arg2); } else { do_credits(player); } break; default: goto bad; } break; case 'd': case 'D': /* @dbginfo, @describe, @dig, @doing, @drop, @dump */ switch (command[2]) { #ifdef DISKBASE case 'b': case 'B': Matched("@dbginfo"); WIZARDONLY("@dbginfo", player); diskbase_debug(player); break; #endif case 'e': case 'E': Matched("@describe"); NOGUEST("@describe", player); set_standard_property(descr, player, arg1, MESGPROP_DESC, "Object Description", arg2); break; case 'i': case 'I': Matched("@dig"); NOGUEST("@dig", player); BUILDERONLY("@dig", player); do_dig(descr, player, arg1, arg2); break; case 'o': case 'O': Matched("@doing"); if (!tp_who_doing) goto bad; NOGUEST("@doing", player); set_standard_property(descr, player, arg1, MESGPROP_DOING, "Doing", arg2); break; case 'r': case 'R': Matched("@drop"); NOGUEST("@drop", player); set_standard_property(descr, player, arg1, MESGPROP_DROP, "Drop Message", arg2); break; case 'u': case 'U': Matched("@dump"); WIZARDONLY("@dump", player); PLAYERONLY("@dump", player); do_dump(player, full_command); break; default: goto bad; } break; case 'e': case 'E': /* @edit, @entrances, @examine */ switch (command[2]) { case 'd': case 'D': Matched("@edit"); NOGUEST("@edit", player); PLAYERONLY("@edit", player); MUCKERONLY("@edit", player); do_edit(descr, player, arg1); break; case 'n': case 'N': Matched("@entrances"); do_entrances(descr, player, arg1, arg2); break; case 'x': case 'X': Matched("@examine"); GODONLY("@examine", player); sane_dump_object(player, arg1); break; default: goto bad; } break; case 'f': case 'F': /* @fail, @find, @flock, @force, @force_lock */ switch (command[2]) { case 'a': case 'A': Matched("@fail"); NOGUEST("@fail", player); set_standard_property(descr, player, arg1, MESGPROP_FAIL, "Fail Message", arg2); break; case 'i': case 'I': Matched("@find"); do_find(player, arg1, arg2); break; case 'l': case 'L': Matched("@flock"); NOGUEST("@flock", player); NOFORCE("@flock", force_level, player); set_standard_lock(descr, player, arg1, MESGPROP_FLOCK, "Force Lock", arg2); break; case 'o': case 'O': if(strlen(command) < 7) { Matched("@force"); do_force(descr, player, arg1, arg2); } else { Matched("@force_lock"); NOGUEST("@force_lock", player); NOFORCE("@force_lock", force_level, player); set_standard_lock(descr, player, arg1, MESGPROP_FLOCK, "Force Lock", arg2); } break; default: goto bad; } break; case 'h': case 'H': /* @hashes */ Matched("@hashes"); do_hashes(player, arg1); break; case 'i': case 'I': /* @idescribe */ Matched("@idescribe"); NOGUEST("@idescribe", player); set_standard_property(descr, player, arg1, MESGPROP_IDESC, "Inside Description", arg2); break; case 'k': case 'K': /* @kill */ Matched("@kill"); do_dequeue(descr, player, arg1); break; case 'l': case 'L': /* @link, @list, @lock */ switch (command[2]) { case 'i': case 'I': switch (command[3]) { case 'n': case 'N': Matched("@link"); NOGUEST("@link", player); do_link(descr, player, arg1, arg2); break; case 's': case 'S': Matched("@list"); match_and_list(descr, player, arg1, arg2); break; default: goto bad; } break; case 'o': case 'O': Matched("@lock"); NOGUEST("@lock", player); set_standard_lock(descr, player, arg1, MESGPROP_LOCK, "Lock", arg2); break; default: goto bad; } break; case 'm': case 'M': /* @mcpedit, @mcpprogram, @memory, @mpitops, @muftops */ switch (command[2]) { #ifdef MCP_SUPPORT case 'c': case 'C': if (string_prefix("@mcpedit", command)) { Matched("@mcpedit"); NOGUEST("@mcpedit", player); PLAYERONLY("@mcpedit", player); MUCKERONLY("@mcpedit", player); do_mcpedit(descr, player, arg1); break; } else { Matched("@mcpprogram"); NOGUEST("@mcpprogram", player); PLAYERONLY("@mcpprogram", player); MUCKERONLY("@mcpprogram", player); do_mcpprogram(descr, player, arg1); break; } #endif #ifndef NO_MEMORY_COMMAND case 'e': case 'E': Matched("@memory"); WIZARDONLY("@memory", player); do_memory(player); break; #endif case 'p': case 'P': Matched("@mpitops"); WIZARDONLY("@mpitops", player); do_mpi_topprofs(player, arg1); break; case 'u': case 'U': Matched("@muftops"); WIZARDONLY("@muftops", player); do_muf_topprofs(player, arg1); break; default: goto bad; } break; case 'n': case 'N': /* @name, @newpassword */ switch (command[2]) { case 'a': case 'A': Matched("@name"); NOGUEST("@name", player); do_name(descr, player, arg1, arg2); break; case 'e': case 'E': if (strcmp(command, "@newpassword")) goto bad; WIZARDONLY("@newpassword", player); PLAYERONLY("@newpassword", player); do_newpassword(player, arg1, arg2); break; default: goto bad; } break; case 'o': case 'O': /* @odrop, @oecho, @ofail, @open, @osuccess, @owned */ switch (command[2]) { case 'd': case 'D': Matched("@odrop"); NOGUEST("@odrop", player); set_standard_property(descr, player, arg1, MESGPROP_ODROP, "ODrop Message", arg2); break; case 'e': case 'E': Matched("@oecho"); NOGUEST("@oecho", player); set_standard_property(descr, player, arg1, MESGPROP_OECHO, "Outside-echo Prefix", arg2); break; case 'f': case 'F': Matched("@ofail"); NOGUEST("@ofail", player); set_standard_property(descr, player, arg1, MESGPROP_OFAIL, "OFail Message", arg2); break; case 'p': case 'P': Matched("@open"); NOGUEST("@open", player); BUILDERONLY("@open", player); do_open(descr, player, arg1, arg2); break; case 's': case 'S': Matched("@osuccess"); NOGUEST("@osuccess", player); set_standard_property(descr, player, arg1, MESGPROP_OSUCC, "OSuccess Message", arg2); break; case 'w': case 'W': Matched("@owned"); do_owned(player, arg1, arg2); break; default: goto bad; } break; case 'p': case 'P': /* @password, @pcreate, @pecho, @program, @propset, @ps */ switch (command[2]) { case 'a': case 'A': Matched("@password"); PLAYERONLY("@password", player); NOGUEST("@password", player); do_password(player, arg1, arg2); break; case 'c': case 'C': Matched("@pcreate"); WIZARDONLY("@pcreate", player); PLAYERONLY("@pcreate", player); do_pcreate(player, arg1, arg2); break; case 'e': case 'E': Matched("@pecho"); NOGUEST("@pecho", player); set_standard_property(descr, player, arg1, MESGPROP_PECHO, "Puppet-echo Prefix", arg2); break; case 'r': case 'R': if (string_prefix("@program", command)) { Matched("@program"); NOGUEST("@program", player); PLAYERONLY("@program", player); MUCKERONLY("@program", player); do_prog(descr, player, arg1); break; } else { Matched("@propset"); NOGUEST("@propset", player); do_propset(descr, player, arg1, arg2); break; } case 's': case 'S': Matched("@ps"); list_events(player); break; default: goto bad; } break; case 'r': case 'R': /* @recycle, @reconfiguressl, @relink, @restart, @restrict */ switch (command[3]) { case 'c': case 'C': #ifdef USE_SSL if (!strcmp(command, "@reconfiguressl")) { WIZARDONLY("@reconfiguressl", player); PLAYERONLY("@reconfiguressl", player); do_reconfigure_ssl(player); break; } #endif Matched("@recycle"); NOGUEST("@recycle", player); do_recycle(descr, player, arg1); break; case 'l': case 'L': Matched("@relink"); NOGUEST("@relink", player); do_relink(descr, player, arg1, arg2); break; case 's': case 'S': if (!strcmp(command, "@restart")) { /* WIZARDONLY("@restart", player); PLAYERONLY("@restart", player); */ do_restart(player); } else if (!strcmp(command, "@restrict")) { WIZARDONLY("@restrict", player); PLAYERONLY("@restrict", player); do_restrict(player, arg1); } else { goto bad; } break; default: goto bad; } break; case 's': case 'S': /* @sanity, @sanchange, @sanfix, @set, @shutdown, @stats, @success, @sweep */ switch (command[2]) { case 'a': case 'A': if (!strcmp(command, "@sanity")) { GODONLY("@sanity", player); sanity(player); } else if (!strcmp(command, "@sanchange")) { GODONLY("@sanchange", player); sanechange(player, full_command); } else if (!strcmp(command, "@sanfix")) { GODONLY("@sanfix", player); sanfix(player); } else { goto bad; } break; case 'e': case 'E': Matched("@set"); NOGUEST("@set", player); do_set(descr, player, arg1, arg2); break; case 'h': case 'H': if (strcmp(command, "@shutdown")) goto bad; /* WIZARDONLY("@shutdown", player); PLAYERONLY("@shutdown", player); */ do_shutdown(player); break; case 't': case 'T': Matched("@stats"); do_stats(player, arg1); break; case 'u': case 'U': Matched("@success"); NOGUEST("@success", player); set_standard_property(descr, player, arg1, MESGPROP_SUCC, "Success Message", arg2); break; case 'w': case 'W': Matched("@sweep"); do_sweep(descr, player, arg1); break; default: goto bad; } break; case 't': case 'T': /* @teleport, @toad, @trace, @tune */ switch (command[2]) { case 'e': case 'E': Matched("@teleport"); do_teleport(descr, player, arg1, arg2); break; case 'o': case 'O': if (!strcmp(command, "@toad")) { WIZARDONLY("@toad", player); PLAYERONLY("@toad", player); do_toad(descr, player, arg1, arg2); } else if (!strcmp(command, "@tops")) { WIZARDONLY("@tops", player); do_all_topprofs(player, arg1); } else { goto bad; } break; case 'r': case 'R': Matched("@trace"); do_trace(descr, player, arg1, atoi(arg2)); break; case 'u': case 'U': Matched("@tune"); WIZARDONLY("@tune", player); PLAYERONLY("@tune", player); do_tune(player, arg1, arg2, !!strchr(full_command, ARG_DELIMITER)); break; default: goto bad; } break; case 'u': case 'U': /* @unbless, @unlink, @unlock, @uncompile, @usage */ switch (command[2]) { case 'N': case 'n': if (string_prefix(command, "@unb")) { Matched("@unbless"); WIZARDONLY("@unbless", player); PLAYERONLY("@unbless", player); NOFORCE("@unbless", force_level, player); do_unbless(descr, player, arg1, arg2); } else if (string_prefix(command, "@unli")) { Matched("@unlink"); NOGUEST("@unlink", player); do_unlink(descr, player, arg1); } else if (string_prefix(command, "@unlo")) { Matched("@unlock"); NOGUEST("@unlock", player); set_standard_lock(descr, player, arg1, MESGPROP_LOCK, "Lock", ""); } else if (string_prefix(command, "@uncom")) { Matched("@uncompile"); WIZARDONLY("@uncompile", player); PLAYERONLY("@uncompile", player); do_uncompile(player); } else { goto bad; } break; #ifndef NO_USAGE_COMMAND case 'S': case 's': Matched("@usage"); WIZARDONLY("@usage", player); do_usage(player); break; #endif default: goto bad; break; } break; case 'v': case 'V': /* @version */ Matched("@version"); do_version(player); break; case 'w': case 'W': /* @wall */ if (strcmp(command, "@wall")) goto bad; WIZARDONLY("@wall", player); PLAYERONLY("@wall", player); do_wall(player, full_command); break; default: goto bad; } break; case 'd': case 'D': /* disembark, drop */ switch (command[1]) { case 'i': case 'I': Matched("disembark"); do_leave(descr, player); break; case 'r': case 'R': Matched("drop"); do_drop(descr, player, arg1, arg2); break; default: goto bad; } break; case 'e': case 'E': /* examine */ Matched("examine"); do_examine(descr, player, arg1, arg2); break; case 'g': case 'G': /* get, give, goto, gripe */ switch (command[1]) { case 'e': case 'E': Matched("get"); do_get(descr, player, arg1, arg2); break; case 'i': case 'I': Matched("give"); do_give(descr, player, arg1, atoi(arg2)); break; case 'o': case 'O': Matched("goto"); do_move(descr, player, arg1, 0); break; case 'r': case 'R': if (string_compare(command, "gripe")) goto bad; do_gripe(player, full_command); break; default: goto bad; } break; case 'h': case 'H': /* help */ Matched("help"); do_help(player, arg1, arg2); break; case 'i': case 'I': /* inventory, info */ if (string_compare(command, "info")) { Matched("inventory"); do_inventory(player); } else { Matched("info"); do_info(player, arg1, arg2); } break; case 'k': case 'K': /* kill */ Matched("kill"); do_kill(descr, player, arg1, atoi(arg2)); break; case 'l': case 'L': /* leave, look */ if (string_prefix("look", command)) { Matched("look"); do_look_at(descr, player, arg1, arg2); break; } else { Matched("leave"); do_leave(descr, player); break; } case 'm': case 'M': /* man, motd, move, mpi */ if (string_prefix(command, "move")) { do_move(descr, player, arg1, 0); break; } else if (!string_compare(command, "motd")) { do_motd(player, full_command); break; } else if (!string_compare(command, "mpi")) { do_mpihelp(player, arg1, arg2); break; } else { if (string_compare(command, "man")) goto bad; do_man(player, (!*arg1 && !*arg2 && arg1 != arg2) ? "=" : arg1, arg2); } break; case 'n': case 'N': /* news */ Matched("news"); do_news(player, arg1, arg2); break; case 'p': case 'P': /* page, pose, put */ switch (command[1]) { case 'a': case 'A': Matched("page"); do_page(player, arg1, arg2); break; case 'o': case 'O': Matched("pose"); do_pose(player, full_command); break; case 'u': case 'U': Matched("put"); do_drop(descr, player, arg1, arg2); break; default: goto bad; } break; case 'r': case 'R': /* read, rob */ switch (command[1]) { case 'e': case 'E': Matched("read"); /* undocumented alias for look */ do_look_at(descr, player, arg1, arg2); break; case 'o': case 'O': Matched("rob"); do_rob(descr, player, arg1); break; default: goto bad; } break; case 's': case 'S': /* say, score */ switch (command[1]) { case 'a': case 'A': Matched("say"); do_say(player, full_command); break; case 'c': case 'C': Matched("score"); do_score(player); break; default: goto bad; } break; case 't': case 'T': /* take, throw */ switch (command[1]) { case 'a': case 'A': Matched("take"); do_get(descr, player, arg1, arg2); break; case 'h': case 'H': Matched("throw"); do_drop(descr, player, arg1, arg2); break; default: goto bad; } break; case 'w': case 'W': /* whisper */ Matched("whisper"); do_whisper(descr, player, arg1, arg2); break; default: bad: if (tp_m3_huh != 0) { char hbuf[BUFFER_LEN]; snprintf(hbuf,BUFFER_LEN,"HUH? %s", command); if(can_move(descr, player, hbuf, 3)) { do_move(descr, player, hbuf, 3); *match_args = 0; *match_cmdname = 0; break; } } notify(player, tp_huh_mesg); if (tp_log_failed_commands && !controls(player, LOCATION(player))) { log_status("HUH from %s(%d) in %s(%d)[%s]: %s %s", NAME(player), player, NAME(LOCATION(player)), LOCATION(player), NAME(OWNER(LOCATION(player))), command, full_command); } break; } } /* calculate time command took. */ gettimeofday(&endtime, NULL); if (starttime.tv_usec > endtime.tv_usec) { endtime.tv_usec += 1000000; endtime.tv_sec -= 1; } endtime.tv_usec -= starttime.tv_usec; endtime.tv_sec -= starttime.tv_sec; totaltime = endtime.tv_sec + (endtime.tv_usec * 1.0e-6); if (totaltime > (tp_cmd_log_threshold_msec / 1000.0)) { log2file(LOG_CMD_TIMES, "%6.3fs, %.16s: %s: %s", totaltime, ctime((time_t *)&starttime.tv_sec), whowhere(player), command); } }
/** * rb_ext_db_key_create_storage: * @field: required field name * @value: value for field * * Creates a new metadata storage key with a single field. * Use @rb_ext_db_key_add_field to add more. * * Return value: the new key */ RBExtDBKey * rb_ext_db_key_create_storage (const char *field, const char *value) { return do_create (field, value, FALSE); }
static int process_requests(int sock) { int flags; int size = 0; int retval = 0; uint64_t offset; ProxyHeader header; int mode, uid, gid; V9fsString name, value; struct timespec spec[2]; V9fsString oldpath, path; struct iovec in_iovec, out_iovec; in_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); in_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ; out_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); out_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ; while (1) { /* * initialize the header type, so that we send * response to proper request type. */ header.type = 0; retval = read_request(sock, &in_iovec, &header); if (retval < 0) { goto err_out; } switch (header.type) { case T_OPEN: retval = do_open(&in_iovec); break; case T_CREATE: retval = do_create(&in_iovec); break; case T_MKNOD: case T_MKDIR: case T_SYMLINK: retval = do_create_others(header.type, &in_iovec); break; case T_LINK: v9fs_string_init(&path); v9fs_string_init(&oldpath); retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "ss", &oldpath, &path); if (retval > 0) { retval = link(oldpath.data, path.data); if (retval < 0) { retval = -errno; } } v9fs_string_free(&oldpath); v9fs_string_free(&path); break; case T_LSTAT: case T_STATFS: retval = do_stat(header.type, &in_iovec, &out_iovec); break; case T_READLINK: retval = do_readlink(&in_iovec, &out_iovec); break; case T_CHMOD: v9fs_string_init(&path); retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sd", &path, &mode); if (retval > 0) { retval = chmod(path.data, mode); if (retval < 0) { retval = -errno; } } v9fs_string_free(&path); break; case T_CHOWN: v9fs_string_init(&path); retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sdd", &path, &uid, &gid); if (retval > 0) { retval = lchown(path.data, uid, gid); if (retval < 0) { retval = -errno; } } v9fs_string_free(&path); break; case T_TRUNCATE: v9fs_string_init(&path); retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sq", &path, &offset); if (retval > 0) { retval = truncate(path.data, offset); if (retval < 0) { retval = -errno; } } v9fs_string_free(&path); break; case T_UTIME: v9fs_string_init(&path); retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sqqqq", &path, &spec[0].tv_sec, &spec[0].tv_nsec, &spec[1].tv_sec, &spec[1].tv_nsec); if (retval > 0) { retval = utimensat(AT_FDCWD, path.data, spec, AT_SYMLINK_NOFOLLOW); if (retval < 0) { retval = -errno; } } v9fs_string_free(&path); break; case T_RENAME: v9fs_string_init(&path); v9fs_string_init(&oldpath); retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "ss", &oldpath, &path); if (retval > 0) { retval = rename(oldpath.data, path.data); if (retval < 0) { retval = -errno; } } v9fs_string_free(&oldpath); v9fs_string_free(&path); break; case T_REMOVE: v9fs_string_init(&path); retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "s", &path); if (retval > 0) { retval = remove(path.data); if (retval < 0) { retval = -errno; } } v9fs_string_free(&path); break; case T_LGETXATTR: case T_LLISTXATTR: retval = do_getxattr(header.type, &in_iovec, &out_iovec); break; case T_LSETXATTR: v9fs_string_init(&path); v9fs_string_init(&name); v9fs_string_init(&value); retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sssdd", &path, &name, &value, &size, &flags); if (retval > 0) { retval = lsetxattr(path.data, name.data, value.data, size, flags); if (retval < 0) { retval = -errno; } } v9fs_string_free(&path); v9fs_string_free(&name); v9fs_string_free(&value); break; case T_LREMOVEXATTR: v9fs_string_init(&path); v9fs_string_init(&name); retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "ss", &path, &name); if (retval > 0) { retval = lremovexattr(path.data, name.data); if (retval < 0) { retval = -errno; } } v9fs_string_free(&path); v9fs_string_free(&name); break; case T_GETVERSION: retval = do_getversion(&in_iovec, &out_iovec); break; default: goto err_out; break; } if (process_reply(sock, header.type, &out_iovec, retval) < 0) { goto err_out; } } err_out: g_free(in_iovec.iov_base); g_free(out_iovec.iov_base); return -1; }