void CSAX2ParserNSP::HandleStartElement(const XML_Char* name, const XML_Char** atts) { csl_assert (name != NULL && atts != NULL); if (m_pContentHandler) { CAttributesImpl attrList; const XMLChar* attName; const XMLChar* attValue; int i = 0; int nSpecified = GetSpecifiedAttributeCount() / 2; while (*atts) { attName = *(atts++); attValue = *(atts++); XMLString attURI; XMLString attLocal; SplitName(attName, attURI, attLocal); const XMLString& prefix = m_namespaceSupport.GetPrefix(attURI); if (prefix.empty()) attrList.AddAttribute(attURI, attLocal, attLocal, TYPE_CDATA, attValue, i < nSpecified); else attrList.AddAttribute(attURI, attLocal, prefix + COLON + attLocal, TYPE_CDATA, attValue, i < nSpecified); i++; } XMLString uri; XMLString local; SplitName(name, uri, local); const XMLString& prefix = m_namespaceSupport.GetPrefix(uri); if (prefix.empty()) m_pContentHandler->StartElement(uri, local, local, attrList); else m_pContentHandler->StartElement(uri, local, prefix + COLON + local, attrList); } }
void CSAX2ParserNSP::HandleEndElement(const XML_Char* name) { csl_assert (name != NULL); if (m_pContentHandler) { XMLString uri; XMLString local; SplitName(name, uri, local); const XMLString& prefix = m_namespaceSupport.GetPrefix(uri); if (prefix.empty()) m_pContentHandler->EndElement(uri, local, local); else m_pContentHandler->EndElement(uri, local, prefix + COLON + local); } }
UsdGeomXformOp::UsdGeomXformOp(const UsdAttribute &attr, bool isInverseOp) : _attr(attr), _isInverseOp(isInverseOp) { if (!attr) { TF_CODING_ERROR("UsdGeomXformOp created with invalid UsdAttribute."); return; } // _Initialize _opType. const TfToken &name = GetName(); const std::vector<std::string> &opNameComponents = SplitName(); if (_IsNamespaced(name)) { _opType = GetOpTypeEnum(TfToken(opNameComponents[1])); } else { TF_CODING_ERROR("Invalid xform op: <%s>.", attr.GetPath().GetText()); } }
/** * __unix_to_amiga_path_name() */ int __unix_to_amiga_path_name(char *path, char **newpath) { int result = -1; char *amigapath = NULL; LONG pos, lastpos; char buffer[1024]; if (newpath) *newpath = NULL; if (path) { D(bug("\npath = '%s'\n", path)); //DEBUG if ((path[0] == '/') && (strlen(path) == 1)) return result; /* Pfad == rootdir ? */ amigapath = malloc(PATH_MAX * 2); /* Speicher für temporären Speicher anfordern */ if (amigapath) { //added by Alfkil: memset(amigapath, 0x0, PATH_MAX*2); if (path[0] == '/') { /* Laufwerksbezeichnung handhaben */ lastpos = SplitName(path, '/', (STRPTR) &buffer, 1, 256); /* Noch weitere Bestandteile vorhanden ? */ if (lastpos != -1) { /* ja */ strcpy(amigapath, (char *) &buffer); } else { /* nein */ strcpy(amigapath, path + 1); lastpos = strlen(path); } strcat(amigapath, ":"); D(bug("Drive: '%s' (amigapath = '%s')\n", (char *) &buffer, amigapath)); //DEBUG } else lastpos = 0; while ((pos = SplitName(path, '/', (STRPTR) &buffer, lastpos, 256)) != -1) { /* Pfadbestandteile umwandeln */ if (!strcmp((char *) &buffer, "..")) { D(bug(" handle '..'\n")); //DEBUG AddPart(amigapath, "/", PATH_MAX * 2); } else if (!strcmp((char *) &buffer, ".")) { D(bug(" skip '.'\n")); //DEBUG } else { D(bug(" adding '%s'\n", (char *) &buffer)); //DEBUG AddPart(amigapath, (STRPTR) &buffer, PATH_MAX * 2); } lastpos = pos; } /* Noch ein Dateiname vorhanden ? */ if (lastpos != strlen(path)) { /* ja */ if (!strcmp((char *) (lastpos + path), "..")) { D(bug(" handle filename '..'\n")); //DEBUG AddPart(amigapath, "/", PATH_MAX * 2); } else if (!strcmp((char *) (lastpos + path), ".")) { D(bug(" skip filename '.'\n")); //DEBUG } else { D(bug(" add filename '%s'\n", (char *) (lastpos + path))); //DEBUG AddPart(amigapath, (STRPTR) (lastpos + path), PATH_MAX * 2); } } D(bug("amigapath = '%s'\n", amigapath)); //DEBUG if (newpath) { /* Neuen Pfad duplizieren */ if ((*newpath = strdup(amigapath)) != NULL) result = 1; } else { /* Neuen Pfad übertragen */ if (strlen(path) >= strlen(amigapath)) { D(bug("overwrite path...\n")); //DEBUG strcpy(path, amigapath); result = 1; } } } if (amigapath) free(amigapath); /* temporären Speicher freigeben */ } return(result); }
struct DiskIO *DIO_Setup(CONST_STRPTR name, const struct TagItem *tags) { DEBUGF("DIO_Setup('%s', %#p)\n", name, tags); if (name == NULL || name[0] == '\0' || name[0] == ':') { DEBUGF("DIO_Setup: No valid name argument specified.\n"); return NULL; } struct DiskIO *dio; struct TagItem *tstate; const struct TagItem *tag; #ifndef DISABLE_DOSTYPE_CHECK ULONG check_dostype = 0; ULONG dostype_mask = ~0; #endif struct DosList *dol; struct DeviceNode *dn = NULL; struct FileSysStartupMsg *fssm = NULL; struct DosEnvec *de = NULL; struct MsgPort *mp = NULL; struct IOExtTD *iotd = NULL; char devname[256]; struct NSDeviceQueryResult nsdqr; int error = DIO_ERROR_UNSPECIFIED; int *error_storage; dio = AllocMem(sizeof(*dio), MEMF_PUBLIC|MEMF_CLEAR); if (dio == NULL) { error = DIO_ERROR_NOMEM; goto cleanup; } tstate = (struct TagItem *)tags; while ((tag = NextTagItem(&tstate)) != NULL) { switch (tag->ti_Tag) { #ifndef DISABLE_BLOCK_CACHE case DIOS_Cache: dio->no_cache = !tag->ti_Data; break; case DIOS_WriteCache: dio->no_write_cache = !tag->ti_Data; break; #endif case DIOS_Inhibit: dio->inhibit = !!tag->ti_Data; break; #ifndef DISABLE_DOSTYPE_CHECK case DIOS_DOSType: check_dostype = tag->ti_Data; break; case DIOS_DOSTypeMask: dostype_mask = tag->ti_Data; break; #endif case DIOS_ReadOnly: dio->read_only = !!tag->ti_Data; break; } } /* Remove possible colon from name and anything else that might follow it */ SplitName(name, ':', dio->devname, 0, sizeof(dio->devname)); /* Find device node */ dol = LockDosList(LDF_DEVICES|LDF_READ); if (dol != NULL) { dn = (struct DeviceNode *)FindDosEntry(dol, dio->devname, LDF_DEVICES|LDF_READ); UnLockDosList(LDF_DEVICES|LDF_READ); } if (dn == NULL) { error = DIO_ERROR_GETFSD; goto cleanup; } /* Add back trailing colon for Inhibit() */ strlcat((char *)dio->devname, ":", sizeof(dio->devname)); /* Check that device node has the necessary data */ if ((fssm = BADDR(dn->dn_Startup)) == NULL || (de = BADDR(fssm->fssm_Environ)) == NULL || de->de_TableSize < DE_UPPERCYL) { error = DIO_ERROR_GETFSD; goto cleanup; } if (dio->inhibit) { if (!Inhibit(dio->devname, TRUE)) { error = DIO_ERROR_INHIBIT; goto cleanup; } dio->uninhibit = TRUE; /* So Cleanup() knows that it should uninhibit */ } dio->diskmp = mp = CreateMsgPort(); dio->diskiotd = iotd = CreateIORequest(dio->diskmp, sizeof(*iotd)); if (iotd == NULL) { error = DIO_ERROR_NOMEM; goto cleanup; } FbxCopyStringBSTRToC(fssm->fssm_Device, (STRPTR)devname, sizeof(devname)); if (OpenDevice((CONST_STRPTR)devname, fssm->fssm_Unit, (struct IORequest *)iotd, fssm->fssm_Flags) != 0) { DEBUGF("DIO_Setup: Failed to open %s unit %u using flags 0x%x.\n", fssm->fssm_Device, (unsigned int)fssm->fssm_Unit, (unsigned int)fssm->fssm_Flags); error = DIO_ERROR_OPENDEVICE; goto cleanup; } dio->disk_device = iotd->iotd_Req.io_Device; if (de->de_LowCyl == 0) { dio->use_full_disk = TRUE; DEBUGF("de_LowCyl == 0 => using full disk\n"); } else { UQUAD sector_size = de->de_SizeBlock * sizeof(ULONG); UQUAD cylinder_size = (UQUAD)de->de_BlocksPerTrack * (UQUAD)de->de_Surfaces * sector_size; dio->use_full_disk = FALSE; SetSectorSize(dio, sector_size); dio->partition_start = (UQUAD)de->de_LowCyl * cylinder_size; dio->partition_size = (UQUAD)(de->de_HighCyl - de->de_LowCyl + 1) * cylinder_size; dio->total_sectors = dio->partition_size / dio->sector_size; DEBUGF("partiton start: %llu partition size: %llu cylinder size: %llu sector size: %lu total sectors: %llu\n", dio->partition_start, dio->partition_size, cylinder_size, dio->sector_size, dio->total_sectors); } DEBUGF("Trying NSD query command\n"); iotd->iotd_Req.io_Command = NSCMD_DEVICEQUERY; iotd->iotd_Req.io_Data = &nsdqr; iotd->iotd_Req.io_Length = sizeof(nsdqr); bzero(&nsdqr, sizeof(nsdqr)); /* Required for usbscsi.device */ if (DoIO((struct IORequest *)iotd) == 0) { if (nsdqr.DeviceType != NSDEVTYPE_TRACKDISK) { DEBUGF("Not a trackdisk device\n"); error = DIO_ERROR_NSDQUERY; goto cleanup; } if (nsdqr.SupportedCommands != NULL) { UWORD cmd; int i = 0; while ((cmd = nsdqr.SupportedCommands[i++]) != CMD_INVALID) { if (cmd == CMD_READ) dio->cmd_support |= CMDSF_TD32; else if (cmd == ETD_READ) dio->cmd_support |= CMDSF_ETD32; else if (cmd == TD_READ64) dio->cmd_support |= CMDSF_TD64; else if (cmd == NSCMD_TD_READ64) dio->cmd_support |= CMDSF_NSD_TD64; else if (cmd == NSCMD_ETD_READ64) dio->cmd_support |= CMDSF_NSD_ETD64; else if (cmd == CMD_UPDATE) dio->cmd_support |= CMDSF_CMD_UPDATE; else if (cmd == ETD_UPDATE) dio->cmd_support |= CMDSF_ETD_UPDATE; } } } else if (iotd->iotd_Req.io_Error == IOERR_NOCMD) { DEBUGF("Not an NSD device\n"); dio->cmd_support = CMDSF_TD32|CMDSF_CMD_UPDATE; DEBUGF("Checking for TD64 support\n"); iotd->iotd_Req.io_Command = TD_READ64; iotd->iotd_Req.io_Data = NULL; iotd->iotd_Req.io_Actual = 0; iotd->iotd_Req.io_Offset = 0; iotd->iotd_Req.io_Length = 0; if (DoIO((struct IORequest *)iotd) != IOERR_NOCMD) dio->cmd_support |= CMDSF_TD64; } else { DEBUGF("NSD query command failed (error: %d)\n", (int)iotd->iotd_Req.io_Error); error = DIO_ERROR_NSDQUERY; goto cleanup; } if ((dio->cmd_support & (CMDSF_TD32|CMDSF_ETD32|CMDSF_TD64|CMDSF_NSD_TD64|CMDSF_NSD_ETD64)) == 0) { DEBUGF("No I/O commands supported\n"); error = DIO_ERROR_NSDQUERY; goto cleanup; } if (dio->cmd_support & CMDSF_ETD_UPDATE) dio->update_cmd = ETD_UPDATE; else if (dio->cmd_support & CMDSF_CMD_UPDATE) dio->update_cmd = CMD_UPDATE; else dio->update_cmd = CMD_INVALID; dio->mempool = CreatePool(MEMF_PUBLIC, 4096, 1024); if (dio->mempool == NULL) { error = DIO_ERROR_NOMEM; goto cleanup; } DIO_Update(dio); DEBUGF("DIO_Setup: %#p\n", dio); return dio; cleanup: if (dio != NULL) DIO_Cleanup(dio); error_storage = (int *)GetTagData(DIOS_Error, (Tag)NULL, tags); if (error_storage != NULL) *error_storage = error; DEBUGF("DIO_Setup failed (error: %d)\n", error); return NULL; }
int access ( /* SYNOPSIS */ const char *path, int mode) /* FUNCTION Check access permissions of a file or pathname INPUTS path - the path of the file being checked mode - the bitwise inclusive OR of the access permissions to be checked: W_OK - for write permission R_OK - for readpermissions X_OK - for execute permission F_OK - Just to see whether the file exists RESULT If path cannot be found or if any of the desired access modes would not be granted, then a -1 value is returned; otherwise a 0 value is returned. NOTES EXAMPLE BUGS SEE ALSO open(), ftruncate() INTERNALS ******************************************************************************/ { BPTR lock = NULL; struct FileInfoBlock *fib = NULL; int result = -1; char vol[32]; struct DosList *dl = NULL; if (!path) /* safety check */ { errno = EFAULT; return -1; } if (!strlen(path)) /* empty path */ { errno = ENOENT; return -1; } /* Check if the volume exists. Calling Lock on non-existing volume will bring up System Requester */ if (SplitName(__path_u2a(path), ':', vol, 0, sizeof(vol)-1) != -1) { if(strcmp(vol, "PROGDIR") != 0) { dl = LockDosList(LDF_ALL | LDF_READ); dl = FindDosEntry(dl, vol, LDF_ALL); UnLockDosList(LDF_ALL | LDF_READ); /* Volume / Assign / Device not found */ if (dl == NULL) { errno = ENOENT; return -1; } } } /* Create a lock and examine a lock */ lock = Lock(__path_u2a(path), SHARED_LOCK); if (lock == NULL) { errno = IoErr2errno(IoErr()); return -1; } fib = AllocDosObject(DOS_FIB, NULL); if (!fib) { errno = IoErr2errno(IoErr()); UnLock(lock); return -1; } if (Examine(lock, fib)) { /* Notice : protection flags are 'low-active' (0 means access is granted) */ result = 0; if ((mode & R_OK) && (result == 0) && (fib->fib_Protection & (1 << FIBB_READ))) { errno = EACCES; result = -1; } if ((mode & W_OK) && (result == 0) && (fib->fib_Protection & (1 << FIBB_WRITE))) { errno = EACCES; result = -1; } if ((mode & X_OK) && (result == 0) && (fib->fib_Protection & (1 << FIBB_EXECUTE))) { errno = EACCES; result = -1; } } else { errno = EBADF; result = -1; } FreeDosObject(DOS_FIB, fib); fib = NULL; UnLock(lock); return result; }