int WavefrontDisplayDevice::open_file(const char *filename) { if (isOpened) { close_file(); } if ((outfile = fopen(filename, "w")) == NULL) { msgErr << "Could not open file " << filename << " in current directory for writing!" << sendmsg; return FALSE; } my_filename = stringdup(filename); #ifdef VMDGENMTLFILE mtlfilename = stringdup(filename); if (replacefileextension(mtlfilename, ".obj", ".mtl")) { msgErr << "Could not generate material filename" << sendmsg; return FALSE; } if ((mtlfile = fopen(mtlfilename, "w")) == NULL) { msgErr << "Could not open file " << mtlfilename << " in current directory for writing!" << sendmsg; return FALSE; } #endif isOpened = TRUE; reset_state(); oldColorIndex = -1; oldMaterialIndex = -1; oldMaterialState = -1; return TRUE; }
WhereClause::WhereClause(const char* p, const char* v, WhereClauseOperator o, bool s) { type = WHERE_CLAUSE; property = NULL; if (p) property = stringdup(p); value = NULL; if (v) value = stringdup(v); op = o; caseSensitive = s; }
CmdMaterialAdd::CmdMaterialAdd(const char *s, const char *copyfrom) : Command(MATERIAL_ADD) { name = copy = NULL; if (s) name = stringdup(s); if (copyfrom) copy = stringdup(copyfrom); }
USE_NAMESPACE SyncSourceEvent::SyncSourceEvent(const char* uri, const char* sourcename, int mode, int data, int type, unsigned long date) : BaseEvent(type, date) { sourceURI = stringdup(uri); syncMode = mode; name = stringdup(sourcename); this->data = data; }
struct syntaxnode *allocnode(enum syntaxtype type, int subtype, struct token *token) { struct syntaxnode *node; node = (struct syntaxnode *)xmalloc(sizeof(*node)); memset(node, 0x0, sizeof(*node)); node->type = type; node->datatype = dtvoid; node->lineno = token->lineno; if (type == syntaxstmt) { node->subtype.stmt = subtype; switch (subtype) { case stmtif: case stmtrepeat: node->attr.tktype = token->type; break; case stmtassign: case stmtread: node->attr.name = stringdup(token->buf); break; case stmtwrite: /* write needs nothing */ break; default: /* should this happen? */ node->subtype.stmt = stmtunknown; break; } } else if (type == syntaxexp) { node->subtype.exp = subtype; switch (subtype) { case expop: node->attr.tktype = token->type; break; case expconst: node->attr.val = atoi(token->buf); break; case expid: node->attr.name = stringdup(token->buf); break; default: /* should this happen? */ node->subtype.exp = expunknown; break; } } else { /* stmtunknown == expunknown */ node->subtype.stmt = stmtunknown; printf("unknown node\n"); } return node; }
Molecule::Molecule(const char *src, VMDApp *vmdapp, Displayable *d) : DrawMolecule(vmdapp, d), coorIOFiles(8) { char *strPath = NULL, *strName = NULL; breakup_filename(src, &strPath, &strName); if (!strName) strName = stringdup("unknown"); // set the molecule name moleculename = stringdup(strName); delete [] strPath; delete [] strName; }
USE_NAMESPACE /* * Constructor. * * @param parent - a ManagementNode is usually under the context of a * parent node. * @param name - the node name * */ ManagementNode::ManagementNode(const char* parent, const char* name) { context = stringdup(parent); this->name = stringdup(name); }
/** * Sets the reference value. If value is null, the empty string is adopted. * * @param value the reference value - NULL */ void SourceRef::setValue(const char* value) { if (this->value) { delete [] this->value; this->value = NULL; } this->value = stringdup(value); }
int ManagementNode::setFullName(const char *fullname) { char* p; int len; p = strrchr((char*)fullname, '/'); if ( !p ) return -1; len = p-fullname; context = stringdup(fullname, len); p++; len=strlen(fullname)-len; name = stringdup(p, len); return 0; }
void SyncSourceConfig::setEncoding(const char* s) { safeDelete(&encodings); if (s) { encodings = stringdup(s); } }
/** * Creates a new CmdID object with the given String cmdID * * @param cmdID the cmdID of CmdID - NOT NULL * */ CmdID::CmdID(const char* cmdID) { this->cmdID = NULL; if ((cmdID == NULL) || (strlen(cmdID) == 0)) { // tbd } this->cmdID = stringdup(cmdID); }
/** * Sets type * * @param type the new type value */ void SourceFilter::setType(const char*type) { delete [] this->type; if (type) { this->type = stringdup(type); } else { this->type = NULL; } }
/* * Sets displayName * * @param displayName the new value * */ void PropParam::setDisplayName(const char*displayName) { if (this->displayName) { delete [] this->displayName; this->displayName = NULL; } if (displayName) { this->displayName = stringdup(displayName); } }
/* * Sets value * * @param value the new value * */ void WhereClause::setValue(const char*value) { if (this->value) { delete this->value; this->value = NULL; } if (value) { this->value = stringdup(value); } }
/* * Sets paramName * * @param paramName the new value * */ void PropParam::setParamName(const char*paramName) { if (this->paramName) { delete [] this->paramName; this->paramName = NULL; } if (paramName) { this->paramName = stringdup(paramName); } }
/* * Sets dataType * * @param dataType the new value * */ void PropParam::setDataType(const char*dataType) { if (this->dataType) { delete [] this->dataType; this->dataType = NULL; } if (dataType) { this->dataType = stringdup(dataType); } }
void Source::set(const char* locURI, const char* locName) { setLocURI(locURI); if (this->locName) { delete [] this->locName; this->locName = NULL; } this->locName = stringdup(locName); }
/** @brief Set values for the object @param sync_type Sync type (values: 6-10) @param content_type MIME type @param len Server URI lenght @param buf Server URI characters @return */ int SyncAlert::set(int sync_type, int content_type, const char *uri) { if (sync_type < 6 || sync_type > 10) return -1; syncType = sync_type+200; contentType = content_type; serverURI=stringdup(uri); return 0; }
/** * Sets the source URI * * @param locURI the source URI - NOT NULL * */ void Source::setLocURI(const char* locURI) { if (locURI == NULL) { // TBD } if (this->locURI) { delete [] this->locURI; this->locURI = NULL; } this->locURI = stringdup(locURI); }
/* * Sets property * * @param property the new value * */ void WhereClause::setProperty(const char*property) { if (this->property) { delete this->property; this->property = NULL; } if (property) { this->property = stringdup(property); } }
/** * Sets the cmd element * * @param cmd the new cmd element - NOT NULL * */ void Status::setCmd(const char* cmd) { if (cmd == NULL) { // TBD } else { if (this->cmd) { delete [] this->cmd; this->cmd = NULL; } this->cmd = stringdup(cmd); } }
/** * The result must be deleted by caller */ const char* MailMessage::getHeaders() { if( headers.size() ) { StringBuffer buff; buff.join(headers, "\n"); char* strHeaders = stringdup(buff.c_str(), buff.length() -1); return strHeaders; } else return 0; }
VMDFltkMenu::VMDFltkMenu(const char *menuname,const char *title,VMDApp *vmdapp) : VMDMenu(menuname, vmdapp), Fl_Window(0,0,NULL) { _title=stringdup(title); Fl_Window::label(_title); #if defined(VMDMENU_WINDOW) Fl_Window::color(VMDMENU_WINDOW); #endif callback(window_cb); }
char* strtoupper(const char *s) { char* u = NULL; char* p = NULL; for(u = p = stringdup(s); *p; ++p) { *p=toupper(*p); } return u; }
char* strtolower(const char *s) { char* l = NULL; char* p = NULL; for(l = p = stringdup(s); *p; ++p) { *p=tolower(*p); } return l; }
/* * Returns the value of the given property * the value is returned as a new char array and must be fred by the user * * @param property - the property name */ char* DeviceManagementNode::readPropertyValue(const char* property) { int i = 0; while (true) { line *curr = (line *)lines->get(i); if (!curr) { break; } const char *value = curr->getLine(); while (*value && isspace(*value)) { value++; } if (!strnicmp(value, property, strlen(property))) { value = strchr(value, '='); if (value) { value++; while (*value && isspace(*value)) { value++; } char *res = stringdup(value); // FOUND :) // remove trailing white space: usually it is // added accidentally by users char *tmp = res + strlen(res) - 1; while (tmp > res) { if (!isspace(*tmp)) { break; } tmp--; } tmp[1] = 0; return res; } } i++; } // Not found, return an empty string return stringdup(""); }
/* * Returns the SyncHeader/RespURI element of the given message. If the element is not * found it returns NULL. The returned respURI is allocated with the new operator * and must be discarded with delete by the caller. * * @param SyncHdr - the SyncHdr object - NOT NULL */ const char* SyncMLProcessor::getRespURI(SyncHdr* syncHdr) { char* respURI = NULL; if (syncHdr == NULL) { goto finally; } respURI = stringdup(syncHdr->getRespURI()); finally: return respURI; }
char* FolderData::format() { StringBuffer out; out.reserve(150); out = "<Folder>\n"; if (name.length() > 0) out += XMLProcessor::makeElement(FOLDER_NAME, name); if (created.length() > 0) out += XMLProcessor::makeElement(FOLDER_CREATED, created); if (modified.length() > 0) out += XMLProcessor::makeElement(FOLDER_MODIFIED, modified); if (accessed.length() > 0) out += XMLProcessor::makeElement(FOLDER_ACCESSED, accessed); StringBuffer attributes; if (isHiddenPresent) attributes += XMLProcessor::makeElement(FOLDER_HIDDEN, hidden); if (isSystemPresent) attributes += XMLProcessor::makeElement(FOLDER_SYSTEM, system); if (isArchivedPresent) attributes += XMLProcessor::makeElement(FOLDER_ARCHIVED, archived); if (isDeletedPresent) attributes += XMLProcessor::makeElement(FOLDER_DELETE, deleted); if (isWritablePresent) attributes += XMLProcessor::makeElement(FOLDER_WRITABLE, writable); if (isReadablePresent) attributes += XMLProcessor::makeElement(FOLDER_READABLE, readable); if (isExecutablePresent) attributes += XMLProcessor::makeElement(FOLDER_EXECUTABLE, executable); if (!attributes.empty()) out += XMLProcessor::makeElement(FOLDER_ATTRIBUTES, attributes); if (role.length() > 0) out += XMLProcessor::makeElement(FOLDER_ROLE, role); if (!(extended.isEmpty())){ for(int i=0; i < extended.size(); i++){ const char* temp = ((FolderExt*)extended.get(i))->format(); out += temp; delete [] temp; } } out += "</Folder>\n"; return stringdup(out.c_str()); }
int MoleculeGraphics::add_text(const float *x, const char *text, float size, float thickness) { ShapeClass s(TEXT, 6, next_id); float *data = s.data; vec_copy(data+0, x); data[3] = size; data[4] = thickness; data[5] = (float)shapetext.num(); // index where the text will be stored shapetext.append(stringdup(text)); if (next_index < num_elements()) shapes[next_index] = s; else shapes.append(s); return added(); }
char* MD5CredentialData(const char* userName, const char* password, const char* nonce) { int len = 0, lenNonce = 0, totLen = 0; char cnonce [64]; char digest [16]; char base64 [64]; char base64Nonce [64]; char token [512]; char* md5Digest = NULL; char ch [3]; memset(digest, 0, 16); memset(base64, 0, 64); memset(base64Nonce, 0, 64); memset(cnonce, 0, 64); memset(token, 0, 512); sprintf(ch, ":"); sprintf(token, "%s:%s", userName, password); len = strlen(token); // H(username:password) calculateMD5((void*)token, len, digest); // B64(H(username:password)) len = b64_encode((char*)base64, digest, 16); // decode nonce from stored base64 to bin strcpy(cnonce, nonce); lenNonce = b64_decode(cnonce, cnonce); memcpy(base64Nonce, base64, len); memcpy(&base64Nonce[len], ch, 1); memcpy(&base64Nonce[len+1], cnonce, lenNonce); totLen = len + 1 + lenNonce; memset(digest, 0, 16); calculateMD5(base64Nonce, totLen, digest); b64_encode(base64, digest, 16); // return new value md5Digest = stringdup(base64); return md5Digest; }