コード例 #1
0
ファイル: main.c プロジェクト: totzyuta/ListManager
//%E edit 
void cmd_edit()
{
  int i,id,edt=0;
  char m[MAX_LINE_LEN],after[MAX_LINE_LEN];
  char *ptr[5],*aft;
  struct profile *p;

  printf("What is ID of the data you want to edit?\n id:");
  fgets(m,MAX_LINE_LEN + 1,stdin);
  id = atoi(m);

  for(i = 0; i < profile_data_nitems; i++){
    p = &profile_data_store[i];
   
    if(id == p->id){
      printf("Before\n%d,%s,%04d-%02d-%02d,%s,%s\n",p->id, p->name, (p->birth).y, p->birth.m, (p->birth).d, (p->home), p->comment);
      printf("After\n");
      fgets(after,MAX_LINE_LEN+1,stdin);

      if(new_profile(&profile_data_store[i],after,edt)!=NULL){
	      profile_data_nitems--;
      }
    }
  }
}
コード例 #2
0
ファイル: net_pro.c プロジェクト: kota395/np
void parse_line(char *line)
{
  if (line[0] == '%') {
    exec_command(line[1], &line[3]);
  }
  else if (new_profile(&profile_data_store[profile_data_nitems], line) != NULL)
    profile_data_nitems++;
}
コード例 #3
0
ファイル: main.c プロジェクト: totzyuta/ListManager
int parse_line(char *line)
{
  int cmd,std=1;
  char *param;
  
  if(*line == '%'){
    cmd = line[1];
    param = &line[3];
    exec_command(cmd,param);
  }else if(*line == '\0'){
    fprintf(stderr,"error: no input\n\n:");
    return 0;
  }else if(profile_data_nitems == MAX_PROFILES){
    fprintf(stderr,"error: over the limit of datas\n\n:");
  }else {
    new_profile(&profile_data_store[profile_data_nitems],line,std);
  }
  return 0;
}
コード例 #4
0
void title_handle_key_evt (struct android_app* app, AInputEvent* event) {
	Context* context = (Context*) app->userData;
	int32_t key_code, i;
	
	if (AKeyEvent_getAction(event) != AKEY_EVENT_ACTION_UP) {
		return;
	}
	
	key_code = AKeyEvent_getKeyCode(event);
	
	switch (context->title->state) {
		case TITLE_STATE_LOAD_PROFILE:
			if (key_code == AKEY_CODE_BACK) {
				title_transition(context, TITLE_STATE_MAIN);
			}
			break;
		
		case TITLE_STATE_NEW_PROFILE:
			if (key_code == AKEY_CODE_BACK) {
				title_transition(context, TITLE_STATE_MAIN);
			} else if (
				key_code >= AKEY_CODE_A
				&& key_code <= AKEY_CODE_Z
				&& (
					context->title->profile_name == NULL
					|| strlen(context->title->profile_name) <= PROFILE_MAX_LEN
				)
			) {
				char c = key_code - AKEY_CODE_A + 'A';
				if (context->title->profile_name == NULL) {
					context->title->profile_name =
						(char*)
						malloc((PROFILE_MAX_LEN + 1) * sizeof(char));
					context->title->profile_line =
						(Line*)
						malloc(sizeof(Line));
					context->title->profile_line->v_bufs =
						(vertex_buffer**)
						malloc(PROFILE_MAX_LEN * sizeof(vertex_buffer*));
					context->title->profile_line->x = 0;
					context->title->profile_line->y =
						SCREEN_TOP + GLYPH_SIZE + LINE_GAP;
					context->title->profile_line->len = 0;
					context->title->profile_name[0] = c;
					context->title->profile_name[1] = '\0';
				} else {
					context->title->profile_name[
						context->title->profile_line->len
					] = c;
					context->title->profile_name[
						context->title->profile_line->len+1
					] = '\0';
				}
				
				write_char(context->glyphs, context->title->profile_line, c);
			} else if (key_code == AKEY_CODE_DEL) {
				if (context->title->profile_name == NULL) {
					return;
				}
				
				if (context->title->lines[1] != NULL) {
					del_line(context->glyphs, context->title->lines[1]);
				}
				
				if (strlen(context->title->profile_name) == 1) {
					free(context->title->profile_name);
					context->title->profile_name = NULL;
					del_line(context->glyphs, context->title->profile_line);
				} else {
					del_char(context->glyphs, context->title->profile_line);
					context->title->profile_name[
						context->title->profile_line->len
					] = '\0';
				}
			} else if (key_code == AKEY_CODE_ENTER) {
				int valid = 1;
				int idx = 0;
				
				for (i = 0; i < MAX_PROFILES; i++) {
					if (context->profiles[i] == NULL) {
						break;
					}
					
					if (
						strcasecmp(
							context->profiles[i]->name
							, context->title->profile_name
						) == 0
					) {
						valid = 0;
					}
					
					idx++;
				}
				
				if (!valid) {
					context->title->lines[1] = write_line(
						context->glyphs
						, 0
						, SCREEN_TOP + (GLYPH_SIZE + LINE_GAP) * 3
						, "Name in use"
					);
				} else {
					context->profiles[i] = new_profile(
						context->app
						, context->title->profile_name
						, 0
						, 0
					);
					
					context->profile = context->profiles[idx];
					title_transition(context, TITLE_STATE_MAIN);
				}
			}
			break;
	}
}