VMVariable::VMVariable(CFile *file) { char string[256]; // Read the variable name file->ReadStringZ(string); m_Name = strnew(string); // Read the address of the variable file->Read(&m_Address, sizeof(int)); // Read the variable type ID file->Read(&m_TypeID, sizeof(int)); // Get the type name if it's custom if (m_TypeID == VARIABLE_TYPEID_CUSTOM) { file->ReadStringZ(string); m_TypeName = strnew(string); } else { m_TypeName = NULL; } // If the variable is an array m_Array = file->ReadByte(); // Number of elements in the array if (m_Array) file->Read(&m_NbElements, sizeof(int)); else m_NbElements = 0; }
AppIfl::AppIfl(const char * fullPath) { mIflFile = strnew(fullPath); // load in duration and names std::ifstream is; is.open(fullPath); char buffer[256]; char name[256]; S32 duration; while (is.good() && !is.eof()) { is.getline(buffer,sizeof(buffer)); S32 num = sscanf(buffer,"%s %i",name,&duration); if (num==1) { mNames.push_back(strnew(name)); mDurations.push_back(AppTime(1.0f/30.0f,0)); } else if (num==2) { mNames.push_back(strnew(name)); mDurations.push_back(AppTime(F32(duration)/30.0f,0)); } } }
static void rduser(USER *user) { FILE *in; char *buf, *name, *qth; user->name = strdup("?_name"); user->qth = strdup("?_qth"); in = nfopeni(RtUsr, "r"); if (in) { buf = mallocw(LINE128); while(fgets(buf, LINE128, in)) { rip(buf); name = strlop(buf, ' '); if (!matchi(buf, user->call)) continue; if (!name) break; qth = strlop(name, ' '); strnew(&user->name, name); if (!qth) break; strnew(&user->qth, qth); break; } free(buf); nfclose(&in); } }
int main (){ FILE *input; input = fopen("text.txt", "r"); char *str = strnew(); sentence_t *currSentence = sentence_create(); text_t *text = text_create(); while (1) { char c = fgetc(input); if (c == EOF || isspace(c) || c == ',' || c == '.' || c == '!' || c == '?' || c == ';') { if (strlen(str) != 0) { word_t *word = word_new(str); sentence_add(currSentence, word); free (str); word_free (word); str = strnew(); } } if (c == EOF || c == '.' || c == '!' || c == '?') { text_add (text, currSentence); sentence_free(currSentence); currSentence = sentence_create(); } if (c == EOF) break; if (isalpha(c)) { c = tolower(c); char *w = stradd(str, c); free (str); str = w; } } fclose (input); FILE *output; output = fopen("result.txt", "w"); input = fopen ("stopwords.txt", "r"); int stopCount, i; fscanf (input, "%d", &stopCount); for (i = 0; i < stopCount; i++) { char s[15]; fscanf (input, "%s", s); fprintf (output, "%s: %d\n", s, text_find (text, s)); } fclose (input); fclose (output); free (str); sentence_free(currSentence); text_free(text); return 0; }
SessionId::SessionId (unsigned int sid, unsigned int osid, int pid, const char* username, const char* hostname, int hostid, DrawLink* link) { _sid = sid; _osid = osid; _pid = pid; _username = strnew(username); _hostname = strnew(hostname); _hostid = hostid; _drawlink = link; }
/* ANT_DIRECTORY_ITERATOR_RECURSIVE::NEXT() ---------------------------------------- */ ANT_directory_iterator_object *ANT_directory_iterator_recursive::next(ANT_directory_iterator_object *object) { char *got; #ifdef _MSC_VER size_t path_length; if ((got = next_match_wildcard()) == NULL) return NULL; path_length = strlen(file_list->path) - 4; sprintf(object->filename, "%*.*s/%s", (int)path_length, (int)path_length, file_list->path, got); #else if ((got = next_match_wildcard()) == NULL) return NULL; object->filename = strnew(got); #endif if (get_file) object->file = ANT_disk::read_entire_file(object->filename, &object->length); else { object->file = NULL; object->length = 0; } return object; }
Log::Log (const char *iLogFileName) { LogFileName = strnew (iLogFileName); LoggingFlags = 0; LogFile = NULL; NewLine = true; }
ULabel::ULabel (const char* s, Graphic* gr) : Graphic(gr) { _font = nil; if (gr != nil) { ULabel::SetFont(gr->GetFont()); } _string = strnew(s); }
/* ANT_CHANNEL_SOCKET::ANT_CHANNEL_SOCKET() ---------------------------------------- */ ANT_channel_socket::ANT_channel_socket(unsigned short port, char *address) : ANT_channel() { connected = FALSE; socket = new ANT_socket; this->port = port; this->address = address == NULL ? NULL : strnew(address); }
void RegisterParameter( UnityAudioEffectDefinition& definition, const char* name, const char* unit, float minval, float maxval, float defaultval, float displayscale, float displayexponent, int enumvalue, const char* description ) { assert(defaultval >= minval); assert(defaultval <= maxval); strcpy_s(definition.paramdefs[enumvalue].name, name); strcpy_s(definition.paramdefs[enumvalue].unit, unit); definition.paramdefs[enumvalue].description = (description != NULL) ? strnew(description) : (name != NULL) ? strnew(name) : NULL; definition.paramdefs[enumvalue].defaultval = defaultval; definition.paramdefs[enumvalue].displayscale = displayscale; definition.paramdefs[enumvalue].displayexponent = displayexponent; definition.paramdefs[enumvalue].min = minval; definition.paramdefs[enumvalue].max = maxval; if (enumvalue >= (int)definition.numparameters) definition.numparameters = enumvalue + 1; }
bool csArchive::DeleteFile (const char *name) { if (!FileExists (name)) return false; del.InsertSorted (strnew (name)); return true; }
void SimTreeView::registerClass( const char *classname, int normalBmpIndex, int selectedBmpIndex ) { ClassReg *cr = new ClassReg; cr->normalBmpIndex = normalBmpIndex; cr->selectedBmpIndex = selectedBmpIndex; cr->classname = strnew( classname ); classRegistry.push_front( cr ); }
void RotateDialog::GetValue (float& angle) { char* movement = nil; movement = strnew(_medit->Text()); if (sscanf(movement,"%f",&angle) != 1) { angle = 0.0; } delete movement; }
void ScaleDialog::GetValues (float& x, float& y) { char* movement = nil; movement = strnew(_medit->Text()); if (sscanf(movement,"%f %f",&x, &y) != 2) { x = y = 1.0; } delete movement; }
static int sruncmd(cmdint_t *ci, const char *cmdline) { char *cmdnew; int ret; cmdnew = strnew(cmdline); ret = runcmd(ci, cmdnew); free(cmdnew); return ret; }
void BitmapGraphic::Init (char* fg_name) { _fg_map = nil; _fg_name = nil; if (fg_name != nil && *fg_name != '\0') { _fg_map = Bitmap::open(fg_name); _fg_map->Reference(); _fg_name = strnew(fg_name); } }
ClassInfo::ClassInfo (const char* name, const char* path, int lineno) { const int defaultSize = 8; _name = strnew(name); _path = nil; _lineno = lineno; Path(path); _childbufsize = _parentbufsize = defaultSize; _childbuf = new ClassInfo*[_childbufsize]; _parentbuf = new ClassInfo*[_parentbufsize]; _childcount = _parentcount = 0; }
static void cs_write_log_int(char *txt) { if(exit_oscam == 1) { cs_write_log(txt, 1); } else { struct s_log * log = cs_malloc(&log, sizeof(struct s_log), 0); log->txt = strnew(txt); log->header_len = 0; log->direct_log = 1; ll_append(log_list, log); } }
csArchive::csArchive (const char *filename) { comment = NULL; comment_length = 0; csArchive::filename = strnew (filename); file = fopen (filename, "rb"); if (!file) /* Create new archive file */ file = fopen (filename, "wb"); else ReadDirectory (); }
string_t *strappend(string_t *str, const char *s) { if (!str) str = strnew(); if (str->alloc - strlen(str->str) - 1 < strlen(s)) { str->alloc += strlen(s); str->alloc *= 2; str->str = (char *) xrealloc(str->str, str->alloc); } strlcat(str->str, s, str->alloc); return str; }
void SimTreeView::registerScript( const char *description, const char *consoleString ) { if ( !strcmpi(description,"separator") ) AppendMenu( hScriptsMenu, MF_SEPARATOR, NULL, NULL ); else { AppendMenu( hScriptsMenu, MF_STRING, scriptMenu_IDM, description ); script.push_back( strnew( consoleString ) ); scriptMenu_IDM++; } DrawMenuBar( hWnd ); }
void VMUnit::Load(const char *filename) { CFile *file; int x, nb_classes; char string[256]; VMClass *class_ptr; // Open the unit file if ((file = new CFile(filename, FILEOPEN_READ)) == NULL) return; // Get the code segment size file->SeekTo(-4, FILESEEK_END); file->Read(&m_CodeSize, sizeof(int)); file->SeekTo(0, FILESEEK_START); // Allocate the code segment if ((m_CodeSegment = new char[m_CodeSize]) == NULL) return; // Read in the code segment file->Read(m_CodeSegment, m_CodeSize); // Get the number of classes file->Read(&nb_classes, sizeof(int)); for (x = 0; x < nb_classes; x++) { // Get the class information if ((class_ptr = new VMClass(file)) == NULL) return; class_ptr->SetUnit(this); // Add it to the lists m_ClassList.AddLast(class_ptr); m_ClassHash.Add(class_ptr->GetName(), class_ptr); } // Close the unit file delete file; // Classes are loaded, build the import tables for (class_ptr = m_ClassList.GetFirst(); class_ptr; class_ptr = class_ptr->next) class_ptr->BuildImportTable(); // Create the unit name strcpy(string, filename); *strchr(string, '.') = 0; _strlwr(string); m_Name = strnew(string); }
void FGIRCActiveTextFormat::onRender(GFXSurface *sfc, Point2I offset, const Box2I &) { GFXFont *font; if (mOrgTextPtr) { if (stateOver && szAction[0] != '\0') { sfc->drawRect2d(&RectI(offset.x, offset.y + 1, offset.x + extent.x - 10, offset.y + extent.y - 1), 255); } offset.x += 4; offset.y -= 2; // Use a local buffer char *localBuffer = strnew(mOrgTextPtr); Vector<msgFormat>::iterator i; for (i = msgLines.begin(); i != msgLines.end(); i++) { font = fontArray[i->fontType].font; AssertFatal(font, "what happened to the font?"); // Find out where to draw the text; Point2I textOffset = offset + i->offset; // Draw the text char *textPtr = localBuffer + i->startChar; if (i->length > 0) { char temp = textPtr[i->length]; textPtr[i->length] = '\0'; sfc->drawText_p(font, &textOffset, textPtr); textPtr[i->length] = temp; } } // Delete the local buffer delete [] localBuffer; // Now draw all the bitmaps for (int j = 0; j < mBitmapCount; j++) { Point2I bmpOffset = offset + mBitmaps[j].offset; sfc->drawBitmap2d(mBitmaps[j].bmp, &bmpOffset); } } }
void strdropi(char const *s) { char *str = strnew(strlen(s)); char *p = str; for (; *s != '\0'; s++) *p++ = (isupper(*s)) ? tolower(*s) : *s; *p = '\0'; strdrop(str); strfree(str); }
void HelpCtrl::setHelpText(const char *lpszText, float /* rElapsedTime */, bool /*mouseClicked*/) { if (lpszHelpText) { delete [] (char*)lpszHelpText; lpszHelpText = NULL; } if (lpszText) { lpszHelpText = strnew(lpszText); mHelpTag = 0; } }
char const * strgeti(char const *s) { char *str = strnew(strlen(s)); char *p = str; const char *ret; for (; *s != '\0'; s++) *p++ = (isupper(*s)) ? tolower(*s) : *s; *p = '\0'; ret = strget(str); strfree(str); return ret; }
static void write_to_log_int(char *txt, int8_t header_len) { #if !defined(WEBIF) && !defined(MODULE_MONITOR) if (cfg.disablelog) return; #endif struct s_log *log = cs_malloc(&log, sizeof(struct s_log), 0); log->txt = strnew(txt); log->header_len = header_len; log->direct_log = 0; struct s_client *cl = cur_client(); log->cl_usr = ""; if (!cl){ log->cl_text = "undef"; log->cl_typ = ' '; } else { switch(cl->typ) { case 'c': case 'm': if(cl->account) { log->cl_text = cl->account->usr; log->cl_usr = cl->account->usr; } else log->cl_text = ""; break; case 'p': case 'r': log->cl_text = cl->reader ? cl->reader->label : ""; break; default: log->cl_text = "server"; break; } log->cl_typ = cl->typ; } if(exit_oscam == 1 || cfg.disablelog){ //Exit or log disabled. if disabled, just display on webif/monitor char buf[LOG_BUF_SIZE]; cs_strncpy(buf, log->txt, LOG_BUF_SIZE); write_to_log(buf, log, 1); free(log->txt); free(log); } else ll_append(log_list, log); }
void MoveDialog::GetValues (float& x, float& y) { char* movement = nil; movement = strnew(_medit->Text()); if (sscanf(movement,"%f %f",&x, &y) != 2) { x = y = 0.0; } else { int unit; _units->GetValue(unit); switch (unit) { case 'i': x *= inches; y *= inches; break; case 'o': x *= points; y *= points; break; case 'c': x *= cm; y *= cm; break; } } delete movement; }
bool init_pipes (AVS_PIPES *avsp, int num, FILE *pfile) { int i; for (i = 0; i < num; i++) { char sname[MAX_PATH]; if (fscanf(pfile, "%s\n", sname) != 1) DEBUG_PRINTF_RED("fscanf error\n"); else if (!(avsp[i].pipename = strnew(sname))) DEBUG_PRINTF_RED("strnew error\n"); else if (remove(avsp[i].pipename)) DEBUG_PRINTF_RED("error remove file\n"); else if (mkfifo(avsp[i].pipename, 0600)) DEBUG_PRINTF_RED("mkfifo error create fifo file %s, errno %d\n", avsp[i].pipename, errno); else continue; deinit_pipes(avsp, i); return false; } return true; }
static void write_to_log_int(char *txt, int8_t header_len) { struct s_log *log = cs_malloc(&log, sizeof(struct s_log), 0); log->txt = strnew(txt); log->header_len = header_len; log->direct_log = 0; struct s_client *cl = cur_client(); log->cl_usr = ""; if (!cl){ log->cl_text = "undef"; log->cl_typ = ' '; } else { switch(cl->typ) { case 'c': case 'm': if(cl->account) { log->cl_text = cl->account->usr; log->cl_usr = cl->account->usr; } else log->cl_text = ""; break; case 'p': case 'r': log->cl_text = cl->reader ? cl->reader->label : ""; break; default: log->cl_text = "server"; break; } log->cl_typ = cl->typ; } if(exit_oscam == 1){ char buf[LOG_BUF_SIZE]; cs_strncpy(buf, log->txt, LOG_BUF_SIZE); write_to_log(buf, log, 1); free(log->txt); free(log); } else ll_append(log_list, log); }