Example #1
0
int __cdecl main(int argc, char *argv[])
{
	int ID;
	char *image;
	
	printf("GhostTool version %s\n", GHOST_VERSION);

	if (argc < 3) {
		print_help();
		return 0;
	}

	ID = (int)argv[2][0] - 0x30;
	if (ID < 0 || ID > 9) {
		printf("Error: ID must be between 0 and 9\n");
		return -1;
	}

	if (!strcmp(argv[1], "mount")) {
		/* we are going to mount an image */
		mount_image(ID);
	}
	else if (!strcmp(argv[1], "umount")) {
		/* we have to umount an image */
		umount_image(ID);
	}
	else {
		print_help();
	}

	return 0;
}
Example #2
0
struct frm_mod_t *frm_mod_create_logic(char *mod_name)
{
	struct frm_mod_t *mod;

	mod = frm_mod_create();
	mod->type = frm_token_mod_logic;

	if (!strcmp(mod_name, "AND"))
	{
		mod->value.logic = logic_and;
	}
	else if (!strcmp(mod_name, "OR"))
	{
		mod->value.logic = logic_or;
	}
	else if (!strcmp(mod_name, "XOR"))
	{
		mod->value.logic = logic_xor;
	}
	else
	{
		printf("wrong mod_name inside frm_mod_create_logic !\n");
	}

	return mod;
}
Example #3
0
main()
{
    ShowAllCmd(head);

    while(exit_signal == 0)
    {
        /* Get a command */
        char cmdin[CMD_MAX_LEN];
        printf("Please input a cmd ---> ");
        scanf("%s", cmdin);
        
        /* distinguish the command */
        if(!strcmp("help", cmdin))
        {
            ShowAllCmd(head);
        }
        else if(!strcmp("exit", cmdin))
        { 
            Exit();
        }
        else if(!strcmp("writer", cmdin))
        {
            WriterCmd();
        }
        else if(!strcmp("version", cmdin))
        {
            VersionCmd();
        }
        else
        {
            WrongCmd();
        }
    }
}
Example #4
0
static bool IsSmpteSt2067_2(const char* Ns)
{
    return Ns &&
           (!strcmp(Ns, "http://www.smpte-ra.org/schemas/2067-2/2013") ||
            !strcmp(Ns, "http://www.smpte-ra.org/schemas/2067-2/XXXX")); //Some muxers use XXXX instead of year

}
Example #5
0
/* modifier specifically for IMAD instruction */
struct frm_mod_t *frm_mod_create_IMAD_mod(char *mod_name)
{
	struct frm_mod_t *mod;
	/* use count to tell create IMAD_mod1 or IMAD_mod2 */
	static int count = 0;

	mod = frm_mod_create();
	if (count == 0)
	{
		mod->type = frm_token_IMAD_mod1;
		count ++;
	}
	else
	{
		mod->type = frm_token_IMAD_mod2;
		count --;
	}

	if (!strcmp(mod_name, "U32"))
	{
		mod->value.IMAD_mod = 0;
	}
	else if (!strcmp(mod_name, "S32"))
	{
		mod->value.IMAD_mod = 1;
	}
	else
	{
		printf("wrong IMAD_mod !\n");
	}

	return mod;
}
Example #6
0
static gboolean
test_role (void)
{
    AtkRole role1, role2;
    G_CONST_RETURN gchar *name;

    name = atk_role_get_name (ATK_ROLE_PAGE_TAB);
    g_return_val_if_fail (name, FALSE);
    if (strcmp (name, "page-tab") != 0)
    {
        g_print ("Unexpected name for ATK_ROLE_PAGE_TAB %s\n", name);
        return FALSE;
    }

    name = atk_role_get_name (ATK_ROLE_LAYERED_PANE);
    g_return_val_if_fail (name, FALSE);
    if (strcmp (name, "layered-pane") != 0)
    {
        g_print ("Unexpected name for ATK_ROLE_LAYERED_PANE %s\n", name);
        return FALSE;
    }

    role1 = atk_role_for_name ("list-item");
    if (role1 != ATK_ROLE_LIST_ITEM)
    {
        g_print ("Unexpected role for list-item\n");
        return FALSE;
    }

    role1 = atk_role_register ("test-role");
    name = atk_role_get_name (role1);
    g_return_val_if_fail (name, FALSE);
    if (strcmp (name, "test-role") != 0)
    {
        g_print ("Unexpected name for test-role %s\n", name);
        return FALSE;
    }
    role2 = atk_role_for_name ("test-role");
    if (role1 != role2)
    {
        g_print ("Unexpected role for test-role\n");
        return FALSE;
    }
    role2 = atk_role_for_name ("TEST_ROLE");
    if (role2 != 0)
    {
        g_print ("Unexpected role for TEST_ROLE\n");
        return FALSE;
    }
    /*
     * Check that a non-existent role returns NULL
     */
    name = atk_role_get_name (ATK_ROLE_LAST_DEFINED + 2);
    if (name)
    {
        g_print ("Unexpected name for undefined role %s\n", name);
        return FALSE;
    }
    return TRUE;
}
Example #7
0
int ls_func(pfactory pf,pnode pget)
{
	DIR *pdir;
	//printf("%s\n",pf->pth_pwd);
	pdir = opendir(pf->pth_pwd);
	printf("%s\n",pf->pth_pwd);
	if(pdir == NULL)
	{
		perror("opendir");
		return;
	}
	struct dirent *dirinfo;
	char buf[128] = {0};
	struct stat fsta;
	int ret;
	char ftype;
	data d;
	while((dirinfo = readdir(pdir))!= NULL)
	{
		sprintf(buf,"%s/%s",pf->pth_pwd,dirinfo->d_name);
		ret = stat(buf,&fsta);
		bzero(buf,sizeof(buf));
		if(!strcmp(dirinfo->d_name,".") || !strcmp(dirinfo->d_name,".."))
		{
		}else{
			sprintf(buf,"%-5s %-10s		%-10ld\n",dirinfo->d_type>4?"-":"d",dirinfo->d_name,fsta.st_size);
			send(pget->new_fd,buf,sizeof(buf),0);
//			printf("%s",buf);
			sleep(1);
		}
	}
	closedir(pdir);
	return 0;
}
void baocunxingming(char a[],struct phb c[])/*此函数用于键入并保存玩家的姓名 */
{
	FILE *fp;                               /*定义一个文件的指针*/ 
	int b=1,i;
	zs=0;ys=0;
	printf("请输入你的人物名:");
	scanf("%s",a);                          /*此处键入玩家的信息 */
	if((fp=fopen("ph.dat","r"))==NULL)      /*fopen函数用于打开文件,返回文件的指针 */
	{
		for(i=1;i<6;i++)
			if(strcmp(a,c[i].nm)==0)        /*{strcmp函数用于比较两个字符串的大小,判断两次输入的姓名是否一致*/
				b=0;
	}
	else
	{
		for(i=1;i<6;i++)
		{ 
		                                    /*fread函数从文件流中读入数据 */
			fread(&c[i],sizeof(struct phb),1,fp);/*sizeof为C语言中判断数据类型或者表达式长度符的操作符 */
			if(strcmp(a,c[i].nm)==0)
				b=0;
		}
		fclose(fp);                              /*关闭一个文件流 */
	}
	if(b==0)                                     /*玩家姓名一致。提示错误 */
	{
		printf("你输入的名字已存在,请重新输入\n");
		baocunxingming(a,c);
	}
	if(b==1)
		printf("\f");
}
Example #9
0
//Entry point of the P2- microshell implementation
int main(int argc, char *argv[])
{
  Pipe p;
  ctrlCFlag = 1;
  signalHandling();
  ushrcProcessing();
  char *hostName = (char *)malloc(1000);
  gethostname(hostName,1024);    
  while(1){
    fflush(stdin);
    if(isatty(fileno(stdin)) && ctrlCFlag == 1){
       printf("%s%%", hostName);
       fflush(stdout);
    }
    ctrlCFlag = 1;
    p = parse();
    if(p == NULL)
    {
	continue;
    }
    if(p!=NULL && strcmp(p->head->args[0], "end"))
    {
    	prPipe(p);
    }
    else if(isatty(fileno(stdin)) && !strcmp(p->head->args[0], "end"))
    {
	exit(0);
    }	
    else if(!isatty(fileno(stdin)) && !strcmp(p->head->args[0], "end")){
	break;
    }
    freePipe(p);
  }
}
Example #10
0
int pl_file_open_directory(const char *path,
                           const char *subdir,
                           char *result,
                           int  result_len)
{
  /* This routine should be made more robust */
  /* to accept subdirs like ../../ etc... */
  int path_len = strlen(path);
  int copy_len;

  /* Ascend one level */
  if (strcmp(subdir, "..") == 0)
  {
    pl_file_get_parent_directory(path,
                                 result,
                                 result_len);
    return 1;
  }
  else
  {
    copy_len = MIN(result_len - 1, strlen(subdir) + path_len + 2);
    snprintf(result, copy_len, "%s%s/", path, subdir);
    result[copy_len] = '\0';
    return 1;
  }

  /* If we're here, then we couldn't figure out final path */
  /* Just copy the original path */
  copy_len = MIN(result_len - 1, path_len);
  strncpy(result, path, copy_len);
  result[copy_len] = '\0';

  return (strcmp(subdir, ".") == 0);
}
Example #11
0
static gboolean
ppp_dialog_check_fields (GstConnectionDialog *dialog)
{
  gchar *connection_type;
  gboolean valid = TRUE;

  if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->connection_configured)))
    return TRUE;

  connection_type = connection_combo_get_value (GTK_COMBO_BOX (dialog->ppp_type_combo));

  if (!connection_type)
    return FALSE;

  if (strcmp (connection_type, "modem") == 0)
    valid = (get_entry_text (dialog->login) &&
	     get_entry_text (dialog->phone_number) &&
	     get_entry_text (gtk_bin_get_child (GTK_BIN (dialog->serial_port))));
  else if (strcmp (connection_type, "isdn") == 0)
    valid = (get_entry_text (dialog->login) &&
	     get_entry_text (dialog->phone_number));
  else if (strcmp (connection_type, "pppoe") == 0)
    valid = (get_entry_text (dialog->login) &&
	     gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->pppoe_interface_combo)) != -1);
  else if (strcmp (connection_type, "gprs") == 0)
    valid = (get_entry_text (dialog->apn) &&
	     get_entry_text (gtk_bin_get_child (GTK_BIN (dialog->serial_port))));

  g_free (connection_type);

  return valid;
}
Example #12
0
TableEntry *retrieveEntry(Table *table, TableEntry *entry) {

	int probe = Hash(table, *entry);
	for (int index = 0; index <= table->hashSize / 2; index++) {
		if (!table->entry[probe].key) {
			// empty position found
			return NULL;
		}
		else if (!strcmp(entry->key, table->entry[probe].key)) {
			return &table->entry[probe];
		}
		else {
			TableEntry *current = table->entry[probe].n;
			while (current != NULL) {
				if (strcmp(entry->key, current->key)==0) {
					return current;
				}
				current = current->n;
			}
		}
#ifdef	QUADRATIC_PROBING
		increment += 2;
#endif	QUADRATIC_PROBING
	}
	return NULL;
}
Example #13
0
int main() {
    print_header();
#ifdef DEBIAN_BINARY
    getconf = getenvdeb;
#else
    getconf = getenv;
#endif
    char* envval;
    if (envval = getconf("PROTOCOL")) {
        if (strcmp(envval, "raw") == 0) {
            return tunmain_raw();
        } else if (strcmp(envval, "nacl0") == 0) {
            return tunmain_nacl0();
        } else if (strcmp(envval, "nacltai") == 0) {
            return tunmain_nacltai();
        } else {
            fprintf(stderr, "Unknown protocol specified: %s\n", envval);
            return -1;
        }
    } else if (getconf("PRIVATE_KEY")) {
        return tunmain_nacl0();
    } else {
        return tunmain_raw();
    }
}
Example #14
0
/* find a volume that matches the parameters */
static struct volume *find_matching_volume( const char *udi, const char *device,
                                            const char *mount_point, enum device_type type )
{
    struct volume *volume;
    struct disk_device *disk_device;

    LIST_FOR_EACH_ENTRY( volume, &volumes_list, struct volume, entry )
    {
        int match = 0;

        /* when we have a udi we only match drives added manually */
        if (udi && volume->udi) continue;
        /* and when we don't have a udi we only match dynamic drives */
        if (!udi && !volume->udi) continue;

        disk_device = volume->device;
        if (disk_device->type != type) continue;
        if (device && disk_device->unix_device)
        {
            if (strcmp( device, disk_device->unix_device )) continue;
            match++;
        }
        if (mount_point && disk_device->unix_mount)
        {
            if (strcmp( mount_point, disk_device->unix_mount )) continue;
            match++;
        }
        if (!match) continue;
        TRACE( "found matching volume %s for device %s mount %s type %u\n",
               debugstr_guid(&volume->guid), debugstr_a(device), debugstr_a(mount_point), type );
        return grab_volume( volume );
    }
    return NULL;
}
Example #15
0
int		
main (int argc, char *argv[])
{	int		bDoAll = 0 ;
	int		nTests = 0 ;

	if (argc != 2)
	{	printf ("Usage : %s <test>\n", argv [0]) ;
		printf ("    Where <test> is one of the following:\n") ;
		printf ("           wav  - test WAV file peak chunk\n") ;
		printf ("           aiff - test AIFF file PEAK chunk\n") ;
		printf ("           all  - perform all tests\n") ;
		exit (1) ;
		} ;

	bDoAll=!strcmp (argv [1], "all");
		
	if (bDoAll || ! strcmp (argv [1], "wav"))
	{	test_float_peak ("wav", "peak_chunk.wav", SF_FORMAT_WAV) ;
		nTests++ ;
		} ;

	if (bDoAll || ! strcmp (argv [1], "aiff"))
	{	test_float_peak	("aiff", "peak_chunk.aiff", SF_FORMAT_AIFF) ;
		nTests++ ;
		} ;

	if (nTests == 0)
	{	printf ("Mono : ************************************\n") ;
		printf ("Mono : *  No '%s' test defined.\n", argv [1]) ;
		printf ("Mono : ************************************\n") ;
		return 1 ;
		} ;

	return 0;
} /* main */
void
glade_gtk_action_bar_set_property (GladeWidgetAdaptor * adaptor,
                                   GObject * object,
                                   const gchar * id,
                                   const GValue * value)
{
  if (!strcmp (id, "use-center-child"))
    {
      GtkWidget *child;

      if (g_value_get_boolean (value))
        {
          child = gtk_action_bar_get_center_widget (GTK_ACTION_BAR (object));
          if (!child)
            child = glade_placeholder_new ();
          g_object_set_data (G_OBJECT (child), "special-child-type", "center");
        }
      else
        child = NULL;
      gtk_action_bar_set_center_widget (GTK_ACTION_BAR (object), child);
    }

  else if (!strcmp (id, "size"))
    glade_gtk_action_bar_set_size (object, value);
  else
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value);
}
void test_board_san() {
    puts("test_board_san");
    board_t pos;
    char san[LEN_SAN];

    // Double pawn move.
    board_reset(&pos);
    board_san(&pos, move_make(SQ_H2, SQ_H4, kNone), san);
    assert(strcmp(san, "h4") == 0);

    // Promotion.
    assert(board_set_fen(&pos, "4k3/8/8/8/8/8/6p1/4K3 b - - 0 1"));
    board_san(&pos, move_make(SQ_G2, SQ_G1, kRook), san);
    assert(strcmp(san, "g1=R+") == 0);

    // Not ambiguous because of pin.
    assert(board_set_fen(&pos, "4k3/8/8/b7/8/2N3N1/8/4K3 w - - 0 1"));
    board_san(&pos, move_make(SQ_G3, SQ_E4, 0), san);
    puts(san);
    assert(strcmp(san, "Ne4") == 0);

    // Ambiguous.
    board_remove_piece_at(&pos, SQ_A5);
    board_san(&pos, move_make(SQ_G3, SQ_E4, 0), san);
    assert(strcmp(san, "Nge4") == 0);
}
Example #18
0
json_t* nonstring(char* arg)
{
    json_t* temp;
    char* endptr;
    if (!strcmp(arg, "null") || !strcmp(arg, "n"))
        {return json_null();}
    if (!strcmp(arg, "true") || !strcmp(arg, "t"))
        {return json_true();}
    if (!strcmp(arg, "false") || !strcmp(arg, "f"))
        {return json_false();}
    if (!strcmp(arg, "array") || !strcmp(arg, "[]"))
        {return json_array();}
    if (!strcmp(arg, "object") || !strcmp(arg, "{}"))
        {return json_object();}
    errno = 0;
    temp = json_integer(strtol(arg, &endptr, 10));
    if (!errno && *endptr=='\0')
        {return temp;}
    errno = 0;
    temp = json_real(strtod(arg, &endptr));
    if (!errno && *endptr=='\0')
        {return temp;}
    arg_err("parse error: illegal nonstring on arg %i, \"%s\"");
    return json_null();
}
Example #19
0
static gboolean
test_text_attr (void)
{
    AtkTextAttribute attr1, attr2;
    G_CONST_RETURN gchar *name;

    name = atk_text_attribute_get_name (ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP);
    g_return_val_if_fail (name, FALSE);
    if (strcmp (name, "pixels-inside-wrap") != 0)
    {
        g_print ("Unexpected name for ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP %s\n", name);
        return FALSE;
    }

    name = atk_text_attribute_get_name (ATK_TEXT_ATTR_BG_STIPPLE);
    g_return_val_if_fail (name, FALSE);
    if (strcmp (name, "bg-stipple") != 0)
    {
        g_print ("Unexpected name for ATK_TEXT_ATTR_BG_STIPPLE %s\n", name);
        return FALSE;
    }

    attr1 = atk_text_attribute_for_name ("left-margin");
    if (attr1 != ATK_TEXT_ATTR_LEFT_MARGIN)
    {
        g_print ("Unexpected attribute for left-margin\n");
        return FALSE;
    }

    attr1 = atk_text_attribute_register ("test-attribute");
    name = atk_text_attribute_get_name (attr1);
    g_return_val_if_fail (name, FALSE);
    if (strcmp (name, "test-attribute") != 0)
    {
        g_print ("Unexpected name for test-attribute %s\n", name);
        return FALSE;
    }
    attr2 = atk_text_attribute_for_name ("test-attribute");
    if (attr1 != attr2)
    {
        g_print ("Unexpected attribute for test-attribute\n");
        return FALSE;
    }
    attr2 = atk_text_attribute_for_name ("TEST_ATTR");
    if (attr2 != 0)
    {
        g_print ("Unexpected attribute for TEST_ATTR\n");
        return FALSE;
    }
    /*
     * Check that a non-existent attribute returns NULL
     */
    name = atk_text_attribute_get_name (ATK_TEXT_ATTR_LAST_DEFINED + 2);
    if (name)
    {
        g_print ("Unexpected name for undefined attribute %s\n", name);
        return FALSE;
    }
    return TRUE;
}
bool isSubscriptionPresent(const char *pThingName, ShadowActions_t action) {

	uint8_t i = 0;
	bool isAcceptedPresent = false;
	bool isRejectedPresent = false;
	char TemporaryTopicNameAccepted[MAX_SHADOW_TOPIC_LENGTH_BYTES];
	char TemporaryTopicNameRejected[MAX_SHADOW_TOPIC_LENGTH_BYTES];

	topicNameFromThingAndAction(TemporaryTopicNameAccepted, pThingName, action, SHADOW_ACCEPTED);
	topicNameFromThingAndAction(TemporaryTopicNameRejected, pThingName, action, SHADOW_REJECTED);

	for(i = 0; i < MAX_TOPICS_AT_ANY_GIVEN_TIME; i++) {
		if(!SubscriptionList[i].isFree) {
			if((strcmp(TemporaryTopicNameAccepted, SubscriptionList[i].Topic) == 0)) {
				isAcceptedPresent = true;
			} else if((strcmp(TemporaryTopicNameRejected, SubscriptionList[i].Topic) == 0)) {
				isRejectedPresent = true;
			}
		}
	}

	if(isRejectedPresent && isAcceptedPresent) {
		return true;
	}

	return false;
}
static int get_event_num(char *path, char *index)
{
	struct dirent *dent;
	char *event_num_ptr;
	DIR *inputdir = NULL;

	inputdir = opendir(path);
	if (!inputdir) {
		printf("Error when opening search dir\n");
		return -1;
	}

	while ((dent = readdir(inputdir)) != NULL) {
		if (strcmp(dent->d_name, ".") == 0 ||
		    strcmp(dent->d_name, "..") == 0)
			continue;
		if (memcmp(dent->d_name, event_name, strlen(event_name)) == 0) {
			event_num_ptr = dent->d_name + strlen(event_name);
			*index = *event_num_ptr;
			return 0;
		} else {
			continue;
		}
	}

	return -1;

}
ProcessParamsTable *next_process_param( 
        const char *name, 
        const char *type,
            const char *fmt, ... )
{
  ProcessParamsTable *pp;
  va_list ap;
  pp = calloc( 1, sizeof( *pp ) );

  if ( ! pp )
  {
    perror( "next_process_param" );
    exit( 1 );
  }
  strncpy( pp->program, PROGRAM_NAME, LIGOMETA_PROGRAM_MAX );
  if ( ! strcmp( name, "userTag" ) || ! strcmp( name, "user-tag" ) )
    snprintf( pp->param, LIGOMETA_PARAM_MAX, "-userTag" );
  else
    snprintf( pp->param, LIGOMETA_PARAM_MAX, "--%s", name );
  strncpy( pp->type, type, LIGOMETA_TYPE_MAX );
  va_start( ap, fmt );
  vsnprintf( pp->value, LIGOMETA_VALUE_MAX, fmt, ap );
  va_end( ap );

  return pp;
}
Example #23
0
static int do_compact(int argc, const char **argv)
{
   uint32_t duration;

   if (argc > 2)
   {
      if (strcmp(argv[2], "a") == 0)
      {
         mmal_vc_compact(MMAL_VC_COMPACT_AGGRESSIVE, &duration);
         printf("Triggered aggressive compaction on VC - duration %u us.\n", duration);
      }
      else if (strcmp(argv[2], "d") == 0)
      {
         mmal_vc_compact(MMAL_VC_COMPACT_DISCARD, &duration);
         printf("Triggered discard compaction on VC - duration %u us.\n", duration);
      }
      else if (strcmp(argv[2], "n") == 0)
      {
         mmal_vc_compact(MMAL_VC_COMPACT_NORMAL, &duration);
         printf("Triggered normal compaction on VC - duration %u us.\n", duration);
      }
      else
      {
         printf("Invalid memory compaction option %s\n.", argv[2]);
         exit(1);
      }
   }
   else
   {
      printf("Invalid memory compaction arguments.  Need to specify 'a', 'n' or 't'.\n");
      exit(1);
   }
   return 0;
}
Example #24
0
static PyObject *
dbmopen(PyObject *self, PyObject *args)
{
	char *name;
	char *flags = "r";
	int iflags;
	int mode = 0666;

        if ( !PyArg_ParseTuple(args, "s|si:open", &name, &flags, &mode) )
		return NULL;
	if ( strcmp(flags, "r") == 0 )
		iflags = O_RDONLY;
	else if ( strcmp(flags, "w") == 0 )
		iflags = O_RDWR;
	else if ( strcmp(flags, "rw") == 0 ) /* B/W compat */
		iflags = O_RDWR|O_CREAT; 
	else if ( strcmp(flags, "c") == 0 )
		iflags = O_RDWR|O_CREAT;
	else if ( strcmp(flags, "n") == 0 )
		iflags = O_RDWR|O_CREAT|O_TRUNC;
	else {
		PyErr_SetString(DbmError,
				"arg 2 to open should be 'r', 'w', 'c', or 'n'");
		return NULL;
	}
        return newdbmobject(name, iflags, mode);
}
Example #25
0
struct frm_mod_t *frm_mod_create_mod0_B_cop(char *mod_name)
{
	struct frm_mod_t *mod;

	mod = frm_mod_create();
	mod->type = frm_token_mod0_B_cop;

	if (!strcmp(mod_name, "CA"))
	{
		mod->value.mod0_B_cop = 0;
	}
	else if (!strcmp(mod_name, "CG"))
	{
		mod->value.mod0_B_cop = 1;
	}
	else if (!strcmp(mod_name, "LU"))
	{
		mod->value.mod0_B_cop = 2;
	}
	else if (!strcmp(mod_name, "CV"))
	{
		mod->value.mod0_B_cop = 3;
	}
	else
	{
		printf("wrong mod0_b_cop!\n");
	}

	return mod;
}
static int parse_symmetric_cipher(const char* name) {
    if ( strcmp(name, "aes-128-ecb") == 0 ) {
        module_context->symmetric_cipher.openssl_cipher_name = "aes-128-ecb";
        module_context->symmetric_cipher.kernel_cipher_name = "aes";
        module_context->symmetric_cipher.key_length = 16;
        return 0;
    }

    if ( strcmp(name, "aes-192-ecb") == 0 ) {
        module_context->symmetric_cipher.openssl_cipher_name = "aes-192-ecb";
        module_context->symmetric_cipher.kernel_cipher_name = "aes";
        module_context->symmetric_cipher.key_length = 24;
        return 0;
    }

    if ( strcmp(name, "aes-256-ecb") == 0 ) {
        module_context->symmetric_cipher.openssl_cipher_name = "aes-256-ecb";
        module_context->symmetric_cipher.kernel_cipher_name = "aes";
        module_context->symmetric_cipher.key_length = 32;
        return 0;
    }

    if ( strcmp(name, "bf-ecb") == 0 ) {
        module_context->symmetric_cipher.openssl_cipher_name = "bf-ecb";
        module_context->symmetric_cipher.kernel_cipher_name = "blowfish";
        module_context->symmetric_cipher.key_length = 16;
        return 0;
    }

    printf("Unknown alogorithm: %s\n", name);

    return -EINVAL;
}
Example #27
0
struct frm_mod_t *frm_mod_create_gen0_src1_dtype(char* mod_name)
{
	struct frm_mod_t *mod;

	mod = frm_mod_create();
	mod->type = frm_token_gen0_src1_dtype;

	if (!strcmp(mod_name, "F16"))
	{
		mod->value.gen0_src1_dtype = 1;
	}
	else if (!strcmp(mod_name, "F32"))
	{
		mod->value.gen0_src1_dtype = 2;
	}
	else if (!strcmp(mod_name, "F64"))
	{
		mod->value.gen0_src1_dtype = 3;
	}
	else
	{
		mod->value.gen0_src1_dtype = 0;
	}

	return mod;
}
Example #28
0
/* Determine if the given date format is a timestamp.
 *
 * On error, 0 is returned.
 * On success, 1 is returned. */
int
has_timestamp (const char *fmt)
{
  if (strcmp ("%s", fmt) == 0 || strcmp ("%f", fmt) == 0)
    return 1;
  return 0;
}
Example #29
0
struct sio_hdl *
sio_open(const char *str, unsigned int mode, int nbio)
{
    static char devany[] = SIO_DEVANY;
    struct sio_hdl *hdl;
    const char *p;

#ifdef DEBUG
    _sndio_debug_init();
#endif
    if ((mode & (SIO_PLAY | SIO_REC)) == 0)
        return NULL;
    if (str == NULL) /* backward compat */
        str = devany;
    if (strcmp(str, devany) == 0 && !issetugid()) {
        str = getenv("AUDIODEVICE");
        if (str == NULL)
            str = devany;
    }
    if (strcmp(str, devany) == 0) {
        hdl = _sio_aucat_open("/0", mode, nbio);
        if (hdl != NULL)
            return hdl;
        return _sio_sun_open("/0", mode, nbio);
    }
    if ((p = _sndio_parsetype(str, "snd")) != NULL ||
            (p = _sndio_parsetype(str, "aucat")) != NULL)
        return _sio_aucat_open(p, mode, nbio);
    if ((p = _sndio_parsetype(str, "rsnd")) != NULL ||
            (p = _sndio_parsetype(str, "sun")) != NULL) {
        return _sio_sun_open(p, mode, nbio);
    }
    DPRINTF("sio_open: %s: unknown device type\n", str);
    return NULL;
}
Example #30
0
static int ServicesSanityChecks(Attributes a, const Promise *pp)
{
    Rlist *dep;

    switch (a.service.service_policy)
    {
    case SERVICE_POLICY_START:
        break;

    case SERVICE_POLICY_STOP:
    case SERVICE_POLICY_DISABLE:
    case SERVICE_POLICY_RESTART:
    case SERVICE_POLICY_RELOAD:
        if (strcmp(a.service.service_autostart_policy, "none") != 0)
        {
            Log(LOG_LEVEL_ERR,
                "!! Autostart policy of service promiser '%s' needs to be 'none' when service policy is not 'start', but is '%s'",
                  pp->promiser, a.service.service_autostart_policy);
            PromiseRef(LOG_LEVEL_ERR, pp);
            return false;
        }
        break;

    default:
        Log(LOG_LEVEL_ERR, "Invalid service policy for service '%s'", pp->promiser);
        PromiseRef(LOG_LEVEL_ERR, pp);
        return false;
    }

    for (dep = a.service.service_depend; dep != NULL; dep = dep->next)
    {
        if (strcmp(pp->promiser, RlistScalarValue(dep)) == 0)
        {
            Log(LOG_LEVEL_ERR, "Service promiser '%s' has itself as dependency", pp->promiser);
            PromiseRef(LOG_LEVEL_ERR, pp);
            return false;
        }
    }

    if (a.service.service_type == NULL)
    {
        Log(LOG_LEVEL_ERR, "Service type for service '%s' is not known", pp->promiser);
        PromiseRef(LOG_LEVEL_ERR, pp);
        return false;
    }

#ifdef __MINGW32__

    if (strcmp(a.service.service_type, "windows") != 0)
    {
        Log(LOG_LEVEL_ERR, "Service type for promiser '%s' must be 'windows' on this system, but is '%s'",
              pp->promiser, a.service.service_type);
        PromiseRef(LOG_LEVEL_ERR, pp);
        return false;
    }

#endif /* __MINGW32__ */

    return true;
}