Example #1
0
NUSHORT srvc_register_service(NPCHAR name) {
#ifdef DEBUG_LVL_ONE
  vid_print("[ SRVC ] srvc_register_service: ",0x0A);
  vid_print(name,0x0A);
  vid_print("\r\n",0x07);
#endif
  struct SRVCEntry entry;
  entry.name = (NPCHAR)mem_alloc(nstrlen(name)+1);
#ifdef DEBUG_LVL_ONE
  vid_print("[ SRVC ] Name of service: ",0x0A);
  vid_print(name,0x0A); char buffer[256];
  vid_print(" ptr = ",0x0A); nultoa((NULONG)(NPVALUE)entry.name,16,buffer); vid_print(buffer,0xf);
  vid_print("\r\n",0x0A);
#endif
  NUSHORT i;
  NUINT len = nstrlen(name)+1;
  for(i=0;i<len;i++) {
    entry.name[i] = name[i];
  }
  entry.sid = srvc_sid;
  srvc_sid++;
  srvc_entries[srvc_index] = entry;
#ifdef DEBUG_LVL_ONE
  vid_print("[ SRVC ] Registered as: ",0x0A);
  vid_print(nitoa((int)srvc_entries[srvc_index].sid,10),0x0A);
  vid_print("\r\n",0x07);
#endif
  srvc_index++;
  return entry.sid;
}
Example #2
0
NUSHORT srvc_get_id(NPCHAR name) { 
  NUSHORT i;
  for(i=0;i<SRVC_SIZE;i++) {
    
    if(nstrlen(srvc_entries[i].name) != nstrlen(name)) continue;
    if(nstrcmp(srvc_entries[i].name,name) != 1) continue;
#ifdef DEBUG_LVL_TWO
    vid_print("[ SRVC ] Found as: ",0x0A);
    vid_print(nitoa((int)srvc_entries[i].sid,10),0x0A);
    vid_print("\r\n",0x07);
    vid_print(srvc_entries[i].name,0x08);
    vid_print(" /SRVC\r\n",0x08);
#endif
    return srvc_entries[i].sid;
  }
#ifdef DEBUG_LVL_TWO
  vid_print("[ SRVC ] srvc_get_id could not find this service :(\r\n",0x04);
  vid_print(name,0x4);
#endif
  //kstop();
  return 0;
}
Example #3
0
char* mkpath_string(struct lnfstore_conf *conf, const char* suffix)
{
	char* path_strings[5] = {
		(char*)conf->storage_path, 
		(char*)suffix,
		conf->t_vars->dir, (char*)conf->prefix, conf->t_vars->suffix
	};
	
	char* path = malloc(sizeof(char)*(nstrlen(path_strings, 5)+1));
	if(path == NULL){
		return NULL;
	}

	path[0] = 0; //*< Clear path string

	for(int i = 0; i < 5; i++){ 
		if(path_strings[i] == NULL)
			continue;
		strcat(path, path_strings[i]);
	}
	return path;
}
int32_t main() {
int32_t x;
x = 1;
int32_t y;
int32_t temp_0 = 2 * x;
int32_t temp_1 = temp_0 + 1;
y = temp_1;
int32_t z;
char* label;
char* temp_2 = initLabel();
char *temp_3 = (char *)malloc(5 + strlen(temp_2));
*((int*) temp_3) = strlen(temp_2);
temp_3 += 4;
strcpy(temp_3, temp_2);
label = temp_3;
int32_t* p;
printf ("%d\n", globalInt);
int32_t temp_4 = x * y;
int32_t temp_5 = y + temp_4;
int32_t* temp_6 = &globalInt;
p = temp_6;
int32_t temp_7 = fact(y, p);
printf ("%d\n", temp_7);
int32_t temp_8 = temp_5 + temp_7;
z = temp_8;
char *temp_9 = (char *)malloc(5 + strlen(" = "));
*((int*) temp_9) = strlen(" = ");
temp_9 += 4;
strcpy(temp_9, " = ");
char* temp_10 = string_add(label, temp_9);
char *temp_11 = (char *)malloc(5 + strlen(temp_10));
*((int*) temp_11) = strlen(temp_10);
temp_11 += 4;
strcpy(temp_11, temp_10);
label = temp_11;
char *temp_12 = (char *)malloc(5 + strlen("%s %d\n"));
*((int*) temp_12) = strlen("%s %d\n");
temp_12 += 4;
strcpy(temp_12, "%s %d\n");
char *temp_13 = (char *)malloc(5 + strlen(label));
*((int*) temp_13) = strlen(label);
temp_13 += 4;
strcpy(temp_13, label);
int32_t temp_14 = printf(temp_12, temp_13, z);
char *temp_15 = (char *)malloc(5 + strlen("The label '%s' has length %d\n"));
*((int*) temp_15) = strlen("The label '%s' has length %d\n");
temp_15 += 4;
strcpy(temp_15, "The label '%s' has length %d\n");
int32_t temp_16 = nstrlen(label);
char *temp_17 = (char *)malloc(5 + strlen(label));
*((int*) temp_17) = strlen(label);
temp_17 += 4;
strcpy(temp_17, label);
int32_t temp_18 = printf(temp_15, temp_17, temp_16);
char *temp_19 = (char *)malloc(5 + strlen("globalInt = %d\n"));
*((int*) temp_19) = strlen("globalInt = %d\n");
temp_19 += 4;
strcpy(temp_19, "globalInt = %d\n");
int32_t temp_20 = printf(temp_19, *p);
return 0;
}