Ejemplo n.º 1
0
void LaosFileSystem::makeshortname(char* shortname, char* name) {
    char *tmpname = new char[MAXFILESIZE];
    strcpy(tmpname, name);
    removespaces(tmpname);
    shorten(tmpname, SHORTFILESIZE);
    char *basename = strtok(tmpname, ".");
    char *ext_name = strtok(NULL, ".");
    strtolower(basename);
    strtolower(ext_name);
    int cnt = 1;
    char fullname[MAXFILESIZE+SHORTFILESIZE+2];
    FILE *fp = NULL;
    do {
        if (fp != NULL) fclose(fp);
        while ((cnt/10+strlen(basename)+2) > 8)
            basename[strlen(basename)-1] = 0;
        if (strlen(ext_name) > 0) {
            sprintf(shortname, "%s~%d.%s", basename, cnt++, ext_name);
        } else {
            sprintf(shortname, "%s~%d", basename, cnt++);
        }
        sprintf(fullname, "%s%s", pathname, shortname);
        fp = fopen(fullname, "rb");
    } while (fp!=NULL);
    
    FILE *tfp = fopen(tablename, "ab");
    dirwrite(name, shortname, tfp);
    fclose(tfp);

    delete(tmpname);
}
Ejemplo n.º 2
0
        bool ScreenCapture::process_batch_command (const std::string& cmd, const std::string& args)
        {
          // BATCH_COMMAND capture.folder path # Set the output folder for the screen capture tool
          if (cmd == "capture.folder") {
            directory->setPath (args.c_str());
            QString path (shorten(directory->path().toUtf8().constData(), 20, 0).c_str());
            folder_button->setText(path);
            on_output_update ();
            return true;
          }

          // BATCH_COMMAND capture.prefix path # Set the output file prefix for the screen capture tool
          if (cmd == "capture.prefix") {
            prefix_textbox->setText (args.c_str());
            on_output_update ();
            return true;
          }

          // BATCH_COMMAND capture.grab # Start the screen capture process
          if (cmd == "capture.grab") {
            on_screen_capture();
            return true;
          }

          return false;
        }
Ejemplo n.º 3
0
std::string environment_get_variable(std::string name) {
  WCHAR buffer[1024];
  tstring tstr_name = widen(name);
  GetEnvironmentVariableW(tstr_name.c_str(), (LPWSTR)&buffer, 1024);

  return shorten(buffer);
}
Ejemplo n.º 4
0
PRIVATE int parseFeed(rss_feeds *feeds, const char* feedstr) {
  char *line = NULL, *option = NULL, *param = NULL;
  char *saveptr;
  char *str = NULL;
  rss_feed* feed = NULL;
  int result = SUCCESS; /* be optimistic */

  str = shorten(feedstr);

  line = strtok_r(str, AM_DELIMITER, &saveptr);
  while (line) {
    if(!feed) {
      feed = feed_new();
      assert(feed && "feed_new() failed!");
    }
    if(parseSubOption(line, &option, &param) == 0) {
      if(!strncmp(option, "url", 3)) {
        feed->url = shorten(param);
      } else if(!strncmp(option, "cookies", 6)) {
        feed->cookies = shorten(param);
      } else {
        dbg_printf(P_ERROR, "Unknown suboption '%s'!", option);
      }
      am_free(option);
      am_free(param);
    } else {
      dbg_printf(P_ERROR, "Invalid suboption string: '%s'!", line);
    }
    line = strtok_r(NULL, AM_DELIMITER, &saveptr);
  }


  if(feed && feed->url) {
    /* Maybe the cookies are encoded within the URL */
    if(feed->cookies == NULL) {
      parseCookiesFromURL(feed);
    }
    feed->id = listCount(*feeds);
    feed_add(feed, feeds);
  } else {
    dbg_printf(P_ERROR, "Invalid feed: '%s'", str);
    result = FAILURE;
  }

  am_free(str);
  return result;
}
Ejemplo n.º 5
0
 bool ScreenCapture::select_output_folder_slot ()
 {
   directory->setPath(QFileDialog::getExistingDirectory (this, tr("Directory"), directory->path()));
   QString path (shorten(directory->path().toUtf8().constData(), 20, 0).c_str());
   folder_button->setText(path);
   on_output_update ();
   return true;
 }
Ejemplo n.º 6
0
void checkWall(float *eye, QuadBuffer *q, int i, int *pos, int *index, int *processed) {
  float x[2], y[2];
  float a[2], b[2];
  int j;

  processed[i] = 1;
  if(shorten(x, y, q->quads + i, 0.01))
    for(j = 0; j < q->current; j++)
      if(processed[j] == 0) {
	shorten(a, b, q->quads + j, 0.01);

	if(occlusiontest(x, y, eye, a, b))
	  checkWall(eye, q, j, pos, index, processed);
      }
  index[*pos] = i;
  (*pos)++; 
}
Ejemplo n.º 7
0
static void replayview_drawitem(void *n, int item, int cnt) {
	MenuEntry *e = (MenuEntry*)n;
	Replay *rpy = (Replay*)e->arg;
	float sizes[] = {1.2, 1.45, 0.8, 0.8, 0.65};
	
	int columns = 5, i, j;
	for(i = 0; i < columns; ++i) {
		char tmp[128];
		int csize = sizes[i] * (SCREEN_W - 210)/columns;
		int o = 0;
		
		for(j = 0; j < i; ++j)
			o += sizes[j] * (SCREEN_W - 210)/columns;
		
		Alignment a = AL_Center;
		
		// hell yeah, another loop-switch sequence
		switch(i) {
			case 0:
				a = AL_Left;
				time_t t = rpy->stages[0].seed;
				struct tm* timeinfo = localtime(&t);
				strftime(tmp, 128, "%Y-%m-%d %H:%M", timeinfo);
				break;
			
			case 1:
				a = AL_Center;
				strncpy(tmp, rpy->playername, 128);
				break;
			
			case 2:
				plrmode_repr(tmp, 128, rpy->stages[0].plr_char, rpy->stages[0].plr_shot);
				tmp[0] = tmp[0] - 'a' + 'A';
				break;
			
			case 3:
				snprintf(tmp, 128, difficulty_name(rpy->stages[0].diff));
				break;
			
			case 4:
				a = AL_Right;
				if(rpy->stgcount == 1)
					snprintf(tmp, 128, "Stage %i", rpy->stages[0].stage);
				else
					snprintf(tmp, 128, "%i stages", rpy->stgcount);
				break;
		}
		
		shorten(tmp, csize);
		switch(a) {
			case AL_Center:	o += csize * 0.5 - stringwidth(tmp, _fonts.standard) * 0.5;		break;
			case AL_Right:	o += csize - stringwidth(tmp, _fonts.standard);					break;
			default:																		break;
		}
		
		draw_text(AL_Left, o + 10, 20*item, tmp, _fonts.standard);
	}
}
Ejemplo n.º 8
0
void initialize_directory_globals() {
  // Set the working_directory
  WCHAR buffer[MAX_PATH + 1];
  GetCurrentDirectoryW(MAX_PATH + 1, buffer);
  enigma_user::working_directory = add_slash(shorten(buffer));

  // Set the program_directory
  buffer[0] = 0;
  GetModuleFileNameW(NULL, buffer, MAX_PATH + 1);
  enigma_user::program_directory = shorten(buffer);
  enigma_user::program_directory =
    enigma_user::program_directory.substr(0, enigma_user::program_directory.find_last_of("\\/"));

  // Set the temp_directory
  buffer[0] = 0;
  GetTempPathW(MAX_PATH + 1, buffer);
  enigma_user::temp_directory = add_slash(shorten(buffer));
}
Ejemplo n.º 9
0
PRIVATE int parseFilter(am_filters *patlist, const char* match) {
  char *line = NULL, *option = NULL, *param = NULL;
  char *saveptr;
  char *str = NULL;
  am_filter filter = NULL;
  int result = SUCCESS; /* be optimistic */

  str = shorten(match);

  line = strtok_r(str, AM_DELIMITER, &saveptr);
  while (line) {
    if(!filter) {
      filter = filter_new();
      assert(filter && "filter_new() failed!");
    }
    if(parseSubOption(line, &option, &param) == 0) {
      if(!strncmp(option, "pattern", 7)) {
        filter->pattern = shorten(param);
      } else if(!strncmp(option, "useragent", 9)) {
        filter->agent = shorten(param);
      } else {
        dbg_printf(P_ERROR, "Unknown suboption '%s'!", option);
      }
      am_free(option);
      am_free(param);
    } else {
      dbg_printf(P_ERROR, "Invalid suboption string: '%s'!", line);
    }
    line = strtok_r(NULL, AM_DELIMITER, &saveptr);
  }

  if(filter && filter->pattern) {
    filter_add(filter, patlist);
  } else {
    dbg_printf(P_ERROR, "Invalid filter: '%s'", str);
    result = FAILURE;
  }

  am_free(str);
  return result;
}
Ejemplo n.º 10
0
short curtail(Char *s, Char c)
{
  short Result = 0;
  short l;

  l = strlen(s);
  if (s[l-1] == c) {
    shorten(s, l - 1);
    return l;
  }
  return Result;
}
Ejemplo n.º 11
0
std::unordered_map<std::string, std::string>
CarbonRouterInstanceBase::getStartupOpts() const {
  constexpr size_t kMaxOptionValueLength = 256;

  auto result = opts_.toDict();
  result.insert(additionalStartupOpts_.begin(), additionalStartupOpts_.end());
  result.emplace("version", MCROUTER_PACKAGE_STRING);
  for (auto& it : result) {
    it.second = shorten(it.second, kMaxOptionValueLength);
  }
  return result;
}
Ejemplo n.º 12
0
bool set_working_directory(string dname) {
  tstring tstr_dname = widen(dname);
  replace(tstr_dname.begin(), tstr_dname.end(), '/', '\\');
  if (SetCurrentDirectoryW(tstr_dname.c_str()) != 0) {
    WCHAR wstr_buffer[MAX_PATH + 1];
    if (GetCurrentDirectoryW(MAX_PATH + 1, wstr_buffer) != 0) {
      working_directory = add_slash(shorten(wstr_buffer));
      return true;
    }
  }

  return false;
}
Ejemplo n.º 13
0
static void form(Request *request, Response *response) {
	char *nStr = QUICK_FORM_TEXT(request, response, "longurl");
	char shortUrl[6];

	if (nStr != NULL) {
		shorten(nStr, shortUrl);
		resPrintf(response, "Here's the short url of %s: ", nStr);
		resPrintf(response,
				STAG(input, type="text" disabled="disabled" value="%s"),
				shortUrl);

	}
}
Ejemplo n.º 14
0
char *grbrush_make_label(GrBrush *brush, const char *str, uint maxw)
{
    size_t nmatch=10;
    regmatch_t pmatch[10];
    SR *rule;
    int ret;
    char *retstr;
    bool fits=FALSE;

    if(grbrush_get_text_width(brush, str, strlen(str))<=maxw)
        fits=TRUE;

        /*return scopy(str);*/

    for(rule=shortenrules; rule!=NULL; rule=rule->next){
        if(fits && !rule->always)
            continue;
        ret=regexec(&(rule->re), str, nmatch, pmatch, 0);
        if(ret!=0)
            continue;
        retstr=shorten(brush, str, maxw, rule->rule, nmatch, pmatch);
        goto rettest;
    }

    if(fits){
        retstr=scopy(str);
    }else{
        pmatch[0].rm_so=0;
        pmatch[0].rm_eo=strlen(str)-1;
        retstr=shorten(brush, str, maxw, "$1$<...", 1, pmatch);
    }

rettest:
    if(retstr!=NULL)
        return retstr;
    return scopy("");
}
Ejemplo n.º 15
0
PRIVATE int addPatterns_old(am_filters *patlist, const char* strlist) {
  char *p = NULL;
  char *str = NULL;
  assert(patlist != NULL);
  str = shorten(strlist);
  p = strtok(str, AM_DELIMITER);
  while (p) {
    am_filter pat = filter_new();
    assert(pat != NULL);
    pat->pattern = strdup(p);
    filter_add(pat, patlist);
    p = strtok(NULL, AM_DELIMITER);
  }
  am_free(str);
  return SUCCESS;
}
Ejemplo n.º 16
0
Archivo: setup.c Proyecto: stqism/DEMOS
setsym()
{
        INT             relflg;
        INT             symval, symflg;
        SYMSLAVE        *symptr;
        SYMPTR          symp;
        TXTHDR          txthdr;

        fsym=getfile(symfil,1);
        txtmap.ufd=fsym;
        IF read(fsym, txthdr, TXTHDRSIZ)==TXTHDRSIZ
        THEN    magic=txthdr[0];
                IF magic!=0411 ANDF magic!=0410 ANDF magic!=0407 ANDF magic!=0405
                THEN    magic=0;
                ELSE    symnum=txthdr[4]/SYMTABSIZ;
                        txtsiz=txthdr[1];
                        datsiz=txthdr[2];
                        symbas=txtsiz+datsiz;
                        txtmap.b1=0;
                        txtmap.e1=(magic==0407?symbas:txtsiz);
                        txtmap.f1 = TXTHDRSIZ;
                        txtmap.b2=datbas=(magic==0410?round(txtsiz,TXTRNDSIZ):0);
                        txtmap.e2=txtmap.b2+(magic==0407?symbas:datsiz);
                        txtmap.f2 = TXTHDRSIZ+(magic==0407?0:txtmap.e1);
                        entrypt=txthdr[5];
                        relflg=txthdr[7];
                        IF relflg!=1 THEN symbas =<< 1; FI
                        symbas += TXTHDRSIZ;

                        /* set up symvec */
                        symvec=sbrk(shorten((1+symnum))*sizeof (SYMSLAVE));
                        IF (symptr=symvec)==-1
                        THEN    printf("%s\n",BADNAM);
                                symptr=symvec=sbrk(sizeof (SYMSLAVE));
                        ELSE    symset();
                                WHILE (symp=symget()) ANDF errflg==0
                                DO  symval=symp->symv; symflg=symp->symf;
                                    symptr->valslave=symval;
                                    symptr->typslave=SYMTYPE(symflg);
                                    symptr++;
                                OD
                        FI
                        symptr->typslave=ESYM;
                FI
        FI
        IF magic==0 THEN txtmap.e1=maxfile; FI
}
Ejemplo n.º 17
0
PRIVATE int getFeeds(NODE **head, const char* strlist) {
  char *p = NULL;
  char *str;
  str = shorten(strlist);
  assert(head != NULL);
  p = strtok(str, AM_DELIMITER);
  while (p) {
    rss_feed* feed = feed_new();
    assert(feed && "feed_new() failed!");
    feed->url = strdup(p);
    feed->id  = listCount(*head);
    /* Maybe the cookies are encoded within the URL */
    parseCookiesFromURL(feed);
    feed_add(feed, head);
    p = strtok(NULL, AM_DELIMITER);
  }
  am_free(str);
  return 0;
}
Ejemplo n.º 18
0
void LevelEditor::keyPressed(QKeyEvent *event)
{
    if (isMoving)
        return;

    currentError.clear();
    int key = event->key();

    switch (key)
    {
    case Qt::Key_Escape:
        buttonBackTriggered();
        break;

    case Qt::Key_Backspace:
        if (currentView == SET_NAME_VIEW)
        {
            emit playEffect(EFFECT_JUMP);
            currentName = currentName.left(currentName.length() - 1);

            formSetLevelName->~CubeStringList();
            formSetLevelName = new CubeStringList(currentName, 14.0f, 6.0f, alphabet, 2.0f, FORM_SET_LEVEL_NAME);
        }
        else
        {
            buttonBackTriggered();
        }

        break;

    case Qt::Key_Enter:
    case Qt::Key_Return:
        buttonNextTriggered();
        break;

    case Qt::Key_Up:
        if (currentView == SET_PARAM_VIEW)
        {
            lengthen();
        }
        else if (currentView == EDITING_LEVEL_VIEW)
        {
            moveIn();
            checkMousePosition(lastMouseX, lastMouseY);
        }

        break;

    case Qt::Key_Down:
        if (currentView == SET_PARAM_VIEW)
        {
            shorten();
        }
        else if (currentView == EDITING_LEVEL_VIEW)
        {
            moveOut();
            checkMousePosition(lastMouseX, lastMouseY);
        }

        break;

    case Qt::Key_Left:

        if (currentView == SET_PARAM_VIEW)
            reduce();
        else if (currentView == SET_GRAVITY_VIEW)
            gravityMinus();
        break;

    case Qt::Key_Right:


        if (currentView == SET_PARAM_VIEW)
            enlarge();
        else if (currentView == SET_GRAVITY_VIEW)
            gravityPlus();
        break;

    default:
        if ((key >= Qt::Key_A && key <= Qt::Key_Z) || (key >= Qt::Key_0 && key <= Qt::Key_9) || key == Qt::Key_Space)
            letterTyped(key);
        break;
    }
}
Ejemplo n.º 19
0
Local void analyzeParagraph(struct LOC_paragraphSetup *LINK)
{
  paragraph_index i, FORLIM;

  *LINK->voice = 0;
  bottom = 0;
  top = nvoices + 1;
  clearLabels();
  clearTags();
  clearUptext();
  FORLIM = para_len;
  for (i = 1; i <= FORLIM; i++)
  {   /* ----- Paragraph analysis main loop ----- */
    if (*P[i-1] != '\0' && P[i-1][0] != comment) {
      NextWord(LINK->w, P[i-1], blank, colon);
      line_no = orig_line_no[i-1];
      LINK->l = strlen(LINK->w);
      LINK->is_labelled = (LINK->w[LINK->l-1] == colon &&
			   LINK->w[LINK->l-2] != barsym);
      if (LINK->is_labelled) {
	strcpy(LINK->P_keep, P[i-1]);
	predelete(P[i-1], LINK->l);
	shorten(LINK->w, LINK->l - 1);
	LINK->k = findVoice(LINK->w);   /* First look for a voice label */
	if (LINK->k > 0) {
	  *LINK->voice = LINK->k;
	  setMusicLineNo(*LINK->voice, i);
	} else if (LINK->w[0] == 'L')
	  maybeLyrics(*LINK->voice, i, LINK->w);
	else if (LINK->w[0] == 'C')
	  maybeChords(i, LINK);
	else if (LINK->w[0] == 'U')
	  maybeUptext(i, LINK);
	else {
	  if (startsWithIgnoreCase(LINK->w, "SPACE")) {
	    setSpace(P[i-1]);
	    must_respace = true;
	  } else {
	    if (startsWithIgnoreCase(LINK->w, "VOICES")) {
	      selectVoices(P[i-1]);
	      must_restyle = true;
	    } else {
	      strcpy(P[i-1], LINK->P_keep);
	      LINK->is_labelled = false;
	      if (!isNoteOrRest(LINK->w)) {
		error("Unknown line label", print);
		/** ------------ Maybe Space command ------------ */
		/** ------------ Maybe Voices command ------------ */
		/** Could be sticky attribute **/
	      }
	    }
	  }
	}
      }
      if (!LINK->is_labelled) {
	(*LINK->voice)++;
	setMusicLineNo(*LINK->voice, i);
      }
      if (*LINK->voice > bottom)
	bottom = *LINK->voice;
      if (*LINK->voice > 0 && *LINK->voice < top)
	top = *LINK->voice;
    }
  }
}
Ejemplo n.º 20
0
void LevelEditor::itemClicked(QMouseEvent *event, QList<GLuint> listNames)
{
    if (isMoving)
        return;

    Vector3f *pos = NULL;

    if (!listNames.isEmpty())
    {
        switch (listNames.at(0))
        {
        case BUTTON_VOLUME:
            if ((GLint(angleRotVolumeCube) % 90) == 0)
            {
                audioEnabled = !audioEnabled;
                emit enableAudio(audioEnabled);
                currentActions->appendSecondaryAction(ROTATE_VOLUMECUBE);
            }
            break;

        case BUTTON_SHORTEN:
            shorten();
            break;

        case BUTTON_LENGTHEN:
            lengthen();
            break;

        case BUTTON_REDUCE:
            reduce();
            break;

        case BUTTON_ENLARGE:
            enlarge();
            break;

        case BUTTON_GRAVITY_MINUS:
            gravityMinus();
            break;

        case BUTTON_GRAVITY_PLUS:
            gravityPlus();
            break;

        case BUTTON_BACK:
            buttonBackTriggered();
            break;

        case BUTTON_NEXT:
            buttonNextTriggered();
            break;

        case OBSTACLE_0:
            lastCentre = toolbarObstacleCentres.at(0);
            pos = getModelViewPos(new Vector3f(event->x(), event->y(), 0.0f), true);
            currentDelta = Vector3f();
            deltaFromCentre = *pos - lastCentre;
            movingObject = 0;
            break;

        case OBSTACLE_1:
            lastCentre = toolbarObstacleCentres.at(1);
            pos = getModelViewPos(new Vector3f(event->x(), event->y(), 0.0f), true);
            currentDelta = Vector3f();
            deltaFromCentre = *pos - lastCentre;
            movingObject = 1;
            break;

        case OBSTACLE_2:
            lastCentre = toolbarObstacleCentres.at(2);
            pos = getModelViewPos(new Vector3f(event->x(), event->y(), 0.0f), true);
            currentDelta = Vector3f();
            deltaFromCentre = *pos - lastCentre;
            movingObject = 2;
            break;

        case OBSTACLE_3:
            lastCentre = toolbarObstacleCentres.at(3);
            pos = getModelViewPos(new Vector3f(event->x(), event->y(), 0.0f), true);
            currentDelta = Vector3f();
            deltaFromCentre = *pos - lastCentre;
            movingObject = 3;
            break;

        case BUTTON_SAVE:
            saveLevel();
            break;

        case BUTTON_CANCEL:
            level->clearTempObstaclesList();
            emit playEffect(EFFECT_JUMP);
            break;

        case BUTTON_CLEAR:
            level->clearObstaclesList();
            emit playEffect(EFFECT_JUMP);
            break;

        case BUTTON_EXIT:
            quitEditor();
            break;

        case OBSTACLES:
            level->deleteObstacle(listNames.at(1));
            break;
        }
    }
}
Ejemplo n.º 21
0
template <class T, class U> void
rel_hashmap_rep<T,U>::merge () {
  ASSERT (!is_nil (next), "relative hashmap cannot be merged");
  next->change (item);
  shorten ();
}
Ejemplo n.º 22
0
 inline void erase(int ent_no) {
   shorten(ent_no, 0); 
 }
Ejemplo n.º 23
0
bool equal(){
    shorten(s1);
    shorten(s2);
    if(strcmp(s1,s2)==0)return true;
    return false;
}